@@ -47,9 +47,7 @@ struct ChunkProcessor {
4747 obfuscation_config : Arc < obfuscation_config:: ObfuscationConfig > ,
4848 tags_provider : Arc < provider:: Provider > ,
4949 span_pointers : Option < Vec < SpanPointer > > ,
50- /// Pre-computed value of `_dd.compute_stats` for this request: `"1"` if the
51- /// backend should compute stats, `"0"` if the extension or tracer already did.
52- compute_stats_value : & ' static str ,
50+ client_computed_stats : bool ,
5351}
5452
5553impl TraceChunkProcessor for ChunkProcessor {
@@ -83,10 +81,14 @@ impl TraceChunkProcessor for ChunkProcessor {
8381 span. meta . insert ( "origin" . to_string ( ) , "lambda" . to_string ( ) ) ;
8482 span. meta
8583 . insert ( "_dd.origin" . to_string ( ) , "lambda" . to_string ( ) ) ;
86- span. meta . insert (
87- COMPUTE_STATS_KEY . to_string ( ) ,
88- self . compute_stats_value . to_string ( ) ,
89- ) ;
84+ let compute_stats_value =
85+ if !self . config . compute_trace_stats_on_extension && !self . client_computed_stats {
86+ "1"
87+ } else {
88+ "0"
89+ } ;
90+ span. meta
91+ . insert ( COMPUTE_STATS_KEY . to_string ( ) , compute_stats_value. to_string ( ) ) ;
9092 obfuscate_span ( span, & self . obfuscation_config ) ;
9193 }
9294
@@ -337,16 +339,6 @@ impl TraceProcessor for ServerlessTraceProcessor {
337339 body_size : usize ,
338340 span_pointers : Option < Vec < SpanPointer > > ,
339341 ) -> ( Option < SendDataBuilderInfo > , TracerPayloadCollection ) {
340- // Tell the backend whether to compute stats for this request:
341- // - "1" if neither the tracer nor the extension is computing them
342- // - "0" if the extension or the tracer has already computed them
343- let compute_stats_value = if !config. compute_trace_stats_on_extension
344- && !header_tags. client_computed_stats
345- {
346- "1"
347- } else {
348- "0"
349- } ;
350342 let mut payload = trace_utils:: collect_pb_trace_chunks (
351343 traces,
352344 & header_tags,
@@ -355,7 +347,7 @@ impl TraceProcessor for ServerlessTraceProcessor {
355347 obfuscation_config : self . obfuscation_config . clone ( ) ,
356348 tags_provider : tags_provider. clone ( ) ,
357349 span_pointers,
358- compute_stats_value ,
350+ client_computed_stats : header_tags . client_computed_stats ,
359351 } ,
360352 true , // send agentless since we are the agent
361353 )
@@ -940,7 +932,7 @@ mod tests {
940932 ) ] ) ,
941933 ) ) ,
942934 span_pointers : None ,
943- compute_stats_value : "1" ,
935+ client_computed_stats : false ,
944936 } ;
945937
946938 processor. process ( & mut chunk, 0 ) ;
@@ -1025,7 +1017,7 @@ mod tests {
10251017 ) ] ) ,
10261018 ) ) ,
10271019 span_pointers : None ,
1028- compute_stats_value : "1" ,
1020+ client_computed_stats : false ,
10291021 } ;
10301022
10311023 processor. process ( & mut chunk, 0 ) ;
@@ -1109,7 +1101,7 @@ mod tests {
11091101 ) ] ) ,
11101102 ) ) ,
11111103 span_pointers : None ,
1112- compute_stats_value : "1" ,
1104+ client_computed_stats : false ,
11131105 } ;
11141106
11151107 processor. process ( & mut chunk, 0 ) ;
0 commit comments