44//! This includes the aggregation key to group spans together and the computation of stats from a
55//! span.
66use datadog_trace_protobuf:: pb;
7- use datadog_trace_utils:: span:: trace_utils;
8- use datadog_trace_utils:: span:: Span ;
9- use datadog_trace_utils:: span:: SpanText ;
7+ use datadog_trace_utils:: span:: v04:: Span ;
8+ use datadog_trace_utils:: span:: { trace_utils, SpanText , TraceData } ;
109use hashbrown:: HashMap ;
10+ use std:: borrow:: Borrow ;
1111
1212const TAG_STATUS_CODE : & str = "http.status_code" ;
1313const TAG_SYNTHETICS : & str = "synthetics" ;
@@ -101,10 +101,7 @@ impl<'a> BorrowedAggregationKey<'a> {
101101 ///
102102 /// If `peer_tags_keys` is not empty then the peer tags of the span will be included in the
103103 /// key.
104- pub ( super ) fn from_span < T > ( span : & ' a Span < T > , peer_tag_keys : & ' a [ String ] ) -> Self
105- where
106- T : SpanText ,
107- {
104+ pub ( super ) fn from_span < T : TraceData > ( span : & ' a Span < T > , peer_tag_keys : & ' a [ String ] ) -> Self {
108105 let span_kind = span
109106 . meta
110107 . get ( TAG_SPANKIND )
@@ -176,7 +173,7 @@ impl From<pb::ClientGroupedStats> for OwnedAggregationKey {
176173/// Return the status code of a span based on the metrics and meta tags.
177174fn get_status_code < T > ( span : & Span < T > ) -> u32
178175where
179- T : SpanText ,
176+ T : TraceData ,
180177{
181178 if let Some ( status_code) = span. metrics . get ( TAG_STATUS_CODE ) {
182179 * status_code as u32
@@ -205,7 +202,7 @@ fn get_peer_tags<'k, 'v, T>(
205202 peer_tag_keys : & ' k [ String ] ,
206203) -> Vec < ( & ' k str , & ' v str ) >
207204where
208- T : SpanText ,
205+ T : TraceData ,
209206{
210207 peer_tag_keys
211208 . iter ( )
@@ -228,7 +225,7 @@ impl GroupedStats {
228225 /// Update the stats of a GroupedStats by inserting a span.
229226 fn insert < T > ( & mut self , value : & Span < T > )
230227 where
231- T : SpanText ,
228+ T : TraceData ,
232229 {
233230 self . hits += 1 ;
234231 self . duration += value. duration as u64 ;
@@ -266,7 +263,7 @@ impl StatsBucket {
266263 /// not exist it creates it.
267264 pub ( super ) fn insert < T > ( & mut self , key : BorrowedAggregationKey < ' _ > , value : & Span < T > )
268265 where
269- T : SpanText ,
266+ T : TraceData ,
270267 {
271268 self . data . entry_ref ( & key) . or_default ( ) . insert ( value) ;
272269 }
@@ -326,7 +323,7 @@ fn encode_grouped_stats(key: OwnedAggregationKey, group: GroupedStats) -> pb::Cl
326323
327324#[ cfg( test) ]
328325mod tests {
329- use datadog_trace_utils:: span:: { SpanBytes , SpanSlice } ;
326+ use datadog_trace_utils:: span:: v04 :: { SpanBytes , SpanSlice } ;
330327
331328 use super :: * ;
332329 use std:: { collections:: HashMap , hash:: Hash } ;
0 commit comments