4
4
//! This includes the aggregation key to group spans together and the computation of stats from a
5
5
//! span.
6
6
use 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 } ;
10
9
use hashbrown:: HashMap ;
10
+ use std:: borrow:: Borrow ;
11
11
12
12
const TAG_STATUS_CODE : & str = "http.status_code" ;
13
13
const TAG_SYNTHETICS : & str = "synthetics" ;
@@ -101,10 +101,7 @@ impl<'a> BorrowedAggregationKey<'a> {
101
101
///
102
102
/// If `peer_tags_keys` is not empty then the peer tags of the span will be included in the
103
103
/// 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 {
108
105
let span_kind = span
109
106
. meta
110
107
. get ( TAG_SPANKIND )
@@ -176,7 +173,7 @@ impl From<pb::ClientGroupedStats> for OwnedAggregationKey {
176
173
/// Return the status code of a span based on the metrics and meta tags.
177
174
fn get_status_code < T > ( span : & Span < T > ) -> u32
178
175
where
179
- T : SpanText ,
176
+ T : TraceData ,
180
177
{
181
178
if let Some ( status_code) = span. metrics . get ( TAG_STATUS_CODE ) {
182
179
* status_code as u32
@@ -205,7 +202,7 @@ fn get_peer_tags<'k, 'v, T>(
205
202
peer_tag_keys : & ' k [ String ] ,
206
203
) -> Vec < ( & ' k str , & ' v str ) >
207
204
where
208
- T : SpanText ,
205
+ T : TraceData ,
209
206
{
210
207
peer_tag_keys
211
208
. iter ( )
@@ -228,7 +225,7 @@ impl GroupedStats {
228
225
/// Update the stats of a GroupedStats by inserting a span.
229
226
fn insert < T > ( & mut self , value : & Span < T > )
230
227
where
231
- T : SpanText ,
228
+ T : TraceData ,
232
229
{
233
230
self . hits += 1 ;
234
231
self . duration += value. duration as u64 ;
@@ -266,7 +263,7 @@ impl StatsBucket {
266
263
/// not exist it creates it.
267
264
pub ( super ) fn insert < T > ( & mut self , key : BorrowedAggregationKey < ' _ > , value : & Span < T > )
268
265
where
269
- T : SpanText ,
266
+ T : TraceData ,
270
267
{
271
268
self . data . entry_ref ( & key) . or_default ( ) . insert ( value) ;
272
269
}
@@ -326,7 +323,7 @@ fn encode_grouped_stats(key: OwnedAggregationKey, group: GroupedStats) -> pb::Cl
326
323
327
324
#[ cfg( test) ]
328
325
mod tests {
329
- use datadog_trace_utils:: span:: { SpanBytes , SpanSlice } ;
326
+ use datadog_trace_utils:: span:: v04 :: { SpanBytes , SpanSlice } ;
330
327
331
328
use super :: * ;
332
329
use std:: { collections:: HashMap , hash:: Hash } ;
0 commit comments