@@ -653,16 +653,9 @@ impl Processor {
653653 trace_sender : & Arc < SendingTraceProcessor > ,
654654 context : Context ,
655655 ) {
656- let client_computed_stats = context. client_computed_stats ;
657656 let ( traces, body_size) = self . get_ctx_spans ( context) ;
658- self . send_spans (
659- traces,
660- body_size,
661- client_computed_stats,
662- tags_provider,
663- trace_sender,
664- )
665- . await ;
657+ self . send_spans ( traces, body_size, tags_provider, trace_sender)
658+ . await ;
666659 }
667660
668661 fn get_ctx_spans ( & mut self , context : Context ) -> ( Vec < Span > , usize ) {
@@ -727,7 +720,7 @@ impl Processor {
727720 let traces = vec ! [ cold_start_span. clone( ) ] ;
728721 let body_size = size_of_val ( cold_start_span) ;
729722
730- self . send_spans ( traces, body_size, false , tags_provider, trace_sender)
723+ self . send_spans ( traces, body_size, tags_provider, trace_sender)
731724 . await ;
732725 }
733726 }
@@ -739,7 +732,6 @@ impl Processor {
739732 & mut self ,
740733 traces : Vec < Span > ,
741734 body_size : usize ,
742- client_computed_stats : bool ,
743735 tags_provider : & Arc < provider:: Provider > ,
744736 trace_sender : & Arc < SendingTraceProcessor > ,
745737 ) {
@@ -752,7 +744,7 @@ impl Processor {
752744 tracer_version : "" ,
753745 container_id : "" ,
754746 client_computed_top_level : false ,
755- client_computed_stats,
747+ client_computed_stats : false ,
756748 dropped_p0_traces : 0 ,
757749 dropped_p0_spans : 0 ,
758750 } ;
@@ -1399,10 +1391,9 @@ impl Processor {
13991391 ///
14001392 /// This is used to enrich the invocation span with additional metadata from the tracers
14011393 /// top level span, since we discard the tracer span when we create the invocation span.
1402- pub fn add_tracer_span ( & mut self , span : & Span , client_computed_stats : bool ) {
1394+ pub fn add_tracer_span ( & mut self , span : & Span ) {
14031395 if let Some ( request_id) = span. meta . get ( "request_id" ) {
1404- self . context_buffer
1405- . add_tracer_span ( request_id, span, client_computed_stats) ;
1396+ self . context_buffer . add_tracer_span ( request_id, span) ;
14061397 }
14071398 }
14081399
@@ -2213,98 +2204,6 @@ mod tests {
22132204 ) ;
22142205 }
22152206
2216- /// Verifies that `client_computed_stats` set on a context via `add_tracer_span` is
2217- /// propagated all the way through `send_ctx_spans` to the `aws.lambda` payload sent
2218- /// to the backend, so the extension does not generate duplicate stats.
2219- #[ tokio:: test]
2220- #[ allow( clippy:: unwrap_used) ]
2221- async fn test_client_computed_stats_propagated_to_aws_lambda_span ( ) {
2222- use crate :: traces:: stats_concentrator_service:: StatsConcentratorService ;
2223- use crate :: traces:: stats_generator:: StatsGenerator ;
2224- use libdd_trace_obfuscation:: obfuscation_config:: ObfuscationConfig ;
2225- use tokio:: sync:: mpsc;
2226-
2227- let config = Arc :: new ( config:: Config {
2228- apm_dd_url : "https://trace.agent.datadoghq.com" . to_string ( ) ,
2229- ..config:: Config :: default ( )
2230- } ) ;
2231- let tags_provider = Arc :: new ( provider:: Provider :: new (
2232- Arc :: clone ( & config) ,
2233- LAMBDA_RUNTIME_SLUG . to_string ( ) ,
2234- & HashMap :: from ( [ ( "function_arn" . to_string ( ) , "test-arn" . to_string ( ) ) ] ) ,
2235- ) ) ;
2236- let aws_config = Arc :: new ( AwsConfig {
2237- region : "us-east-1" . into ( ) ,
2238- aws_lwa_proxy_lambda_runtime_api : None ,
2239- function_name : "test-function" . into ( ) ,
2240- sandbox_init_time : Instant :: now ( ) ,
2241- runtime_api : "***" . into ( ) ,
2242- exec_wrapper : None ,
2243- initialization_type : "on-demand" . into ( ) ,
2244- } ) ;
2245- let ( aggregator_service, aggregator_handle) =
2246- AggregatorService :: new ( EMPTY_TAGS , 1024 ) . expect ( "failed to create aggregator service" ) ;
2247- tokio:: spawn ( aggregator_service. run ( ) ) ;
2248- let propagator = Arc :: new ( DatadogCompositePropagator :: new ( Arc :: clone ( & config) ) ) ;
2249- let ( durable_context_tx, _) = tokio:: sync:: mpsc:: channel ( 1 ) ;
2250- let mut p = Processor :: new (
2251- Arc :: clone ( & tags_provider) ,
2252- Arc :: clone ( & config) ,
2253- aws_config,
2254- aggregator_handle,
2255- propagator,
2256- durable_context_tx,
2257- ) ;
2258-
2259- let ( trace_tx, mut trace_rx) = mpsc:: channel ( 10 ) ;
2260- let ( stats_concentrator_service, stats_concentrator_handle) =
2261- StatsConcentratorService :: new ( Arc :: clone ( & config) ) ;
2262- tokio:: spawn ( stats_concentrator_service. run ( ) ) ;
2263- let trace_sender = Arc :: new ( SendingTraceProcessor {
2264- appsec : None ,
2265- processor : Arc :: new ( trace_processor:: ServerlessTraceProcessor {
2266- obfuscation_config : Arc :: new (
2267- ObfuscationConfig :: new ( ) . expect ( "Failed to create ObfuscationConfig" ) ,
2268- ) ,
2269- } ) ,
2270- trace_tx,
2271- stats_generator : Arc :: new ( StatsGenerator :: new ( stats_concentrator_handle) ) ,
2272- } ) ;
2273-
2274- let mut context = Context :: from_request_id ( "req-1" ) ;
2275- context. invocation_span . trace_id = 1 ;
2276- context. invocation_span . span_id = 2 ;
2277- context. client_computed_stats = true ;
2278-
2279- p. send_ctx_spans ( & tags_provider, & trace_sender, context)
2280- . await ;
2281-
2282- let payload = trace_rx
2283- . recv ( )
2284- . await
2285- . expect ( "expected payload from trace_tx" ) ;
2286- assert ! (
2287- payload. header_tags. client_computed_stats,
2288- "client_computed_stats must be propagated to the aws.lambda span payload"
2289- ) ;
2290-
2291- // Verify _dd.compute_stats is "0" in the built payload tags: client_computed_stats=true
2292- // means the tracer has already computed stats, so neither extension nor backend should.
2293- let send_data = payload. builder . build ( ) ;
2294- let libdd_trace_utils:: tracer_payload:: TracerPayloadCollection :: V07 ( payloads) =
2295- send_data. get_payloads ( )
2296- else {
2297- panic ! ( "expected V07 payload" ) ;
2298- } ;
2299- for p in payloads {
2300- assert_eq ! (
2301- p. tags. get( crate :: tags:: lambda:: tags:: COMPUTE_STATS_KEY ) ,
2302- Some ( & "0" . to_string( ) ) ,
2303- "_dd.compute_stats must be 0 when client_computed_stats is true"
2304- ) ;
2305- }
2306- }
2307-
23082207 fn make_trace_sender ( config : Arc < config:: Config > ) -> Arc < SendingTraceProcessor > {
23092208 use libdd_trace_obfuscation:: obfuscation_config:: ObfuscationConfig ;
23102209 let ( stats_concentrator_service, stats_concentrator_handle) =
0 commit comments