dd-trace-dotnet icon indicating copy to clipboard operation
dd-trace-dotnet copied to clipboard

[AWS][Lambda] send placeholder span to the extension

Open duncanista opened this issue 8 months ago • 3 comments

Summary of changes

Updated the AWS Lambda instrumentation to send the top level placeholder span.

Reason for change

So telemetry in the span created by the AWS Lambda extension is more accurate. We would get metrics, metadata, and tags (probably other stuff I'm missing here) easily.

Implementation details

Just updating the name to what the Extension expects and appending it to the context.

Test coverage

  • [ ] Integration Tests
  • [ ] Manual testing

Other details

duncanista avatar Mar 19 '25 21:03 duncanista

Datadog Report

All test runs 600c7ac :link:

:x: 2 Total Test Services: 1 Failed, 1 Passed

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Test Service View
dd-trace-dotnet 4 0 0 568482 4479 35h 45m 26.79s Link
exploration_tests 0 0 0 8612 0 2m 1.93s Link

:x: Failed Tests (4)

  • SubmitsTraces - Datadog.Trace.ClrProfiler.IntegrationTests.AWS.AwsLambdaTests - Details

    Expand for error
    xpected relevantSpans to contain at least 76 item(s) because we want to ensure that we don't timeout while waiting for spans from the mock tracer agent, but found 0: {empty}.
    
  • SubmitsTraces - Datadog.Trace.ClrProfiler.IntegrationTests.AWS.AwsLambdaTests - Details

    Expand for error
    xpected relevantSpans to contain at least 76 item(s) because we want to ensure that we don't timeout while waiting for spans from the mock tracer agent, but found 0: {empty}.
    
  • SubmitsTraces - Datadog.Trace.ClrProfiler.IntegrationTests.AWS.AwsLambdaTests - Details

    Expand for error
    xpected relevantSpans to contain at least 76 item(s) because we want to ensure that we don't timeout while waiting for spans from the mock tracer agent, but found 0: {empty}.
    
  • SubmitsTraces - Datadog.Trace.ClrProfiler.IntegrationTests.AWS.AwsLambdaTests - Details

    Expand for error
    xpected relevantSpans to contain at least 76 item(s) because we want to ensure that we don't timeout while waiting for spans from the mock tracer agent, but found 0: {empty}.
    

Execution-Time Benchmarks Report :stopwatch:

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6783) - mean (74ms)  : 69, 79
     .   : milestone, 74,
    master - mean (79ms)  : 73, 86
     .   : milestone, 79,

    section CallTarget+Inlining+NGEN
    This PR (6783) - mean (1,043ms)  : 1016, 1071
     .   : milestone, 1043,
    master - mean (1,091ms)  : 1060, 1123
     .   : milestone, 1091,

gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6783) - mean (109ms)  : 105, 114
     .   : milestone, 109,
    master - mean (118ms)  : 113, 123
     .   : milestone, 118,

    section CallTarget+Inlining+NGEN
    This PR (6783) - mean (721ms)  : 701, 740
     .   : milestone, 721,
    master - mean (771ms)  : 711, 832
     .   : milestone, 771,

gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6783) - mean (96ms)  : 93, 100
     .   : milestone, 96,
    master - mean (104ms)  : 97, 111
     .   : milestone, 104,

    section CallTarget+Inlining+NGEN
    This PR (6783) - mean (673ms)  : 657, 689
     .   : milestone, 673,
    master - mean (717ms)  : 698, 736
     .   : milestone, 717,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6783) - mean (190ms)  : 187, 194
     .   : milestone, 190,
    master - mean (191ms)  : 187, 195
     .   : milestone, 191,

    section CallTarget+Inlining+NGEN
    This PR (6783) - mean (1,107ms)  : 1082, 1131
     .   : milestone, 1107,
    master - mean (1,111ms)  : 1081, 1142
     .   : milestone, 1111,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6783) - mean (270ms)  : 266, 274
     .   : milestone, 270,
    master - mean (269ms)  : 266, 273
     .   : milestone, 269,

    section CallTarget+Inlining+NGEN
    This PR (6783) - mean (875ms)  : 851, 900
     .   : milestone, 875,
    master - mean (878ms)  : 846, 910
     .   : milestone, 878,

gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6783) - mean (263ms)  : 259, 268
     .   : milestone, 263,
    master - mean (262ms)  : 258, 265
     .   : milestone, 262,

    section CallTarget+Inlining+NGEN
    This PR (6783) - mean (853ms)  : 827, 879
     .   : milestone, 853,
    master - mean (860ms)  : 833, 886
     .   : milestone, 860,

andrewlock avatar Mar 19 '25 22:03 andrewlock

Benchmarks Report for tracer :snail:

Benchmarks for #6783 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.124
  • 1 benchmarks have fewer allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.82μs 42.6ns 310ns 0.0156 0.00779 0 5.62 KB
master StartStopWithChild netcoreapp3.1 10.4μs 58.4ns 378ns 0.0249 0.00996 0 5.8 KB
master StartStopWithChild net472 16.4μs 38ns 147ns 1.05 0.32 0.0961 6.21 KB
#6783 StartStopWithChild net6.0 8.02μs 43.8ns 248ns 0.0196 0.0118 0.00393 5.6 KB
#6783 StartStopWithChild netcoreapp3.1 10.2μs 53.8ns 269ns 0.024 0.00962 0 5.8 KB
#6783 StartStopWithChild net472 16.1μs 41.9ns 162ns 1.07 0.337 0.104 6.21 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 503μs 701ns 2.71μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 669μs 663ns 2.57μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 835μs 295ns 1.1μs 0.414 0 0 3.3 KB
#6783 WriteAndFlushEnrichedTraces net6.0 509μs 652ns 2.52μs 0 0 0 2.7 KB
#6783 WriteAndFlushEnrichedTraces netcoreapp3.1 659μs 788ns 3.05μs 0 0 0 2.7 KB
#6783 WriteAndFlushEnrichedTraces net472 857μs 791ns 3.06μs 0.428 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 128μs 379ns 1.47μs 0.131 0 0 14.47 KB
master SendRequest netcoreapp3.1 146μs 421ns 1.63μs 0.216 0 0 17.27 KB
master SendRequest net472 6.44E‑05ns 3.28E‑05ns 0.000118ns 0 0 0 0 b
#6783 SendRequest net6.0 129μs 378ns 1.47μs 0.192 0 0 14.47 KB
#6783 SendRequest netcoreapp3.1 148μs 165ns 639ns 0.22 0 0 17.27 KB
#6783 SendRequest net472 0.000809ns 0.000353ns 0.00127ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed :heavy_check_mark: Fewer allocations :tada:

Fewer allocations :tada: in #6783

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 41.8 KB 41.42 KB -379 B -0.91%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 598μs 3.47μs 28.6μs 0.293 0 0 41.64 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 698μs 3.96μs 28.6μs 0.321 0 0 41.8 KB
master WriteAndFlushEnrichedTraces net472 873μs 4.29μs 17.7μs 8.3 2.62 0.437 53.36 KB
#6783 WriteAndFlushEnrichedTraces net6.0 565μs 3.24μs 26.4μs 0.587 0 0 41.5 KB
#6783 WriteAndFlushEnrichedTraces netcoreapp3.1 729μs 2.51μs 9.04μs 0.363 0 0 41.42 KB
#6783 WriteAndFlushEnrichedTraces net472 857μs 3.8μs 14.2μs 8.45 2.53 0.422 53.3 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.34μs 1.69ns 6.54ns 0.0141 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.71μs 3.38ns 13.1ns 0.0136 0 0 1.02 KB
master ExecuteNonQuery net472 2.13μs 2.5ns 9.36ns 0.156 0.00107 0 987 B
#6783 ExecuteNonQuery net6.0 1.37μs 2.49ns 9.65ns 0.0145 0 0 1.02 KB
#6783 ExecuteNonQuery netcoreapp3.1 1.83μs 2.07ns 8.01ns 0.0137 0 0 1.02 KB
#6783 ExecuteNonQuery net472 2.06μs 2.69ns 10.4ns 0.156 0.00104 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.26μs 0.596ns 2.31ns 0.0133 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.53μs 0.333ns 1.25ns 0.0131 0 0 976 B
master CallElasticsearch net472 2.62μs 1.44ns 5.39ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.23μs 1.32ns 5.1ns 0.0134 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 0.733ns 2.84ns 0.0141 0 0 1.02 KB
master CallElasticsearchAsync net472 2.72μs 1.14ns 4.4ns 0.166 0 0 1.05 KB
#6783 CallElasticsearch net6.0 1.21μs 0.279ns 1.08ns 0.0134 0 0 976 B
#6783 CallElasticsearch netcoreapp3.1 1.57μs 0.578ns 2.16ns 0.0132 0 0 976 B
#6783 CallElasticsearch net472 2.56μs 1.16ns 4.34ns 0.157 0 0 995 B
#6783 CallElasticsearchAsync net6.0 1.28μs 0.649ns 2.51ns 0.0128 0 0 952 B
#6783 CallElasticsearchAsync netcoreapp3.1 1.66μs 0.775ns 2.9ns 0.0142 0 0 1.02 KB
#6783 CallElasticsearchAsync net472 2.67μs 0.677ns 2.53ns 0.167 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.23μs 0.646ns 2.5ns 0.0135 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.66μs 0.472ns 1.77ns 0.0125 0 0 952 B
master ExecuteAsync net472 1.89μs 0.393ns 1.47ns 0.144 0 0 915 B
#6783 ExecuteAsync net6.0 1.3μs 0.645ns 2.41ns 0.0136 0 0 952 B
#6783 ExecuteAsync netcoreapp3.1 1.56μs 0.52ns 1.95ns 0.0125 0 0 952 B
#6783 ExecuteAsync net472 1.79μs 0.455ns 1.7ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.27μs 1.57ns 5.88ns 0.0321 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.37μs 1.76ns 6.59ns 0.0376 0 0 2.85 KB
master SendAsync net472 7.56μs 2.33ns 9.01ns 0.495 0 0 3.12 KB
#6783 SendAsync net6.0 4.36μs 2.95ns 11ns 0.0328 0 0 2.31 KB
#6783 SendAsync netcoreapp3.1 5.35μs 5.58ns 21.6ns 0.0375 0 0 2.85 KB
#6783 SendAsync net472 7.52μs 1.03ns 3.72ns 0.492 0 0 3.12 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.64μs 1.04ns 3.88ns 0.0238 0 0 1.69 KB
master EnrichedLog netcoreapp3.1 2.22μs 0.673ns 2.52ns 0.0223 0 0 1.69 KB
master EnrichedLog net472 2.6μs 2.64ns 10.2ns 0.258 0 0 1.62 KB
#6783 EnrichedLog net6.0 1.51μs 0.775ns 3ns 0.0234 0 0 1.69 KB
#6783 EnrichedLog netcoreapp3.1 2.21μs 2.23ns 8.63ns 0.0232 0 0 1.69 KB
#6783 EnrichedLog net472 2.68μs 2.48ns 9.28ns 0.257 0 0 1.62 KB
Benchmarks.Trace.Log4netBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 112μs 86.1ns 333ns 0.0562 0 0 4.3 KB
master EnrichedLog netcoreapp3.1 118μs 164ns 635ns 0 0 0 4.3 KB
master EnrichedLog net472 148μs 145ns 563ns 0.672 0.224 0 4.49 KB
#6783 EnrichedLog net6.0 111μs 117ns 436ns 0.0556 0 0 4.3 KB
#6783 EnrichedLog netcoreapp3.1 117μs 163ns 630ns 0.0579 0 0 4.3 KB
#6783 EnrichedLog net472 150μs 137ns 514ns 0.672 0.224 0 4.49 KB
Benchmarks.Trace.NLogBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 3.2μs 3.75ns 13.5ns 0.0305 0 0 2.25 KB
master EnrichedLog netcoreapp3.1 4.22μs 4.65ns 18ns 0.0296 0 0 2.25 KB
master EnrichedLog net472 4.89μs 0.999ns 3.87ns 0.328 0 0 2.07 KB
#6783 EnrichedLog net6.0 2.99μs 0.935ns 3.5ns 0.0313 0 0 2.25 KB
#6783 EnrichedLog netcoreapp3.1 4.32μs 5.16ns 20ns 0.0301 0 0 2.25 KB
#6783 EnrichedLog net472 4.89μs 1.02ns 3.82ns 0.329 0 0 2.07 KB
Benchmarks.Trace.RedisBenchmark - Slower :warning: Same allocations :heavy_check_mark:

Slower :warning: in #6783

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.RedisBenchmark.SendReceive‑net6.0 1.124 1,274.34 1,431.98

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.27μs 0.48ns 1.86ns 0.016 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.83μs 0.661ns 2.47ns 0.0155 0 0 1.14 KB
master SendReceive net472 2.15μs 1.18ns 4.57ns 0.183 0 0 1.16 KB
#6783 SendReceive net6.0 1.43μs 0.762ns 2.95ns 0.0165 0 0 1.14 KB
#6783 SendReceive netcoreapp3.1 1.81μs 1.12ns 4.34ns 0.0153 0 0 1.14 KB
#6783 SendReceive net472 2.15μs 0.512ns 1.85ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.9μs 0.761ns 2.95ns 0.0232 0 0 1.62 KB
master EnrichedLog netcoreapp3.1 4.03μs 2.81ns 10.9ns 0.0222 0 0 1.67 KB
master EnrichedLog net472 4.59μs 2.83ns 10.6ns 0.328 0 0 2.07 KB
#6783 EnrichedLog net6.0 2.68μs 0.795ns 2.97ns 0.0227 0 0 1.62 KB
#6783 EnrichedLog netcoreapp3.1 3.95μs 2.53ns 9.81ns 0.0219 0 0 1.67 KB
#6783 EnrichedLog net472 4.31μs 1.71ns 6.63ns 0.327 0 0 2.07 KB
Benchmarks.Trace.SpanBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 401ns 0.137ns 0.531ns 0.00819 0 0 576 B
master StartFinishSpan netcoreapp3.1 565ns 0.56ns 2.17ns 0.00758 0 0 576 B
master StartFinishSpan net472 641ns 0.29ns 1.08ns 0.0918 0 0 578 B
master StartFinishScope net6.0 502ns 0.119ns 0.459ns 0.00974 0 0 696 B
master StartFinishScope netcoreapp3.1 686ns 0.225ns 0.78ns 0.00938 0 0 696 B
master StartFinishScope net472 863ns 0.335ns 1.3ns 0.105 0 0 658 B
#6783 StartFinishSpan net6.0 403ns 0.0938ns 0.325ns 0.00808 0 0 576 B
#6783 StartFinishSpan netcoreapp3.1 568ns 0.274ns 1.03ns 0.00763 0 0 576 B
#6783 StartFinishSpan net472 668ns 0.595ns 2.31ns 0.0917 0 0 578 B
#6783 StartFinishScope net6.0 501ns 0.328ns 1.23ns 0.00965 0 0 696 B
#6783 StartFinishScope netcoreapp3.1 723ns 0.262ns 0.98ns 0.00938 0 0 696 B
#6783 StartFinishScope net472 861ns 1.34ns 5.2ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 638ns 0.347ns 1.34ns 0.00962 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 912ns 0.593ns 2.3ns 0.00957 0 0 696 B
master RunOnMethodBegin net472 1.2μs 0.283ns 1.09ns 0.104 0 0 658 B
#6783 RunOnMethodBegin net6.0 704ns 0.367ns 1.42ns 0.0099 0 0 696 B
#6783 RunOnMethodBegin netcoreapp3.1 928ns 0.575ns 2.23ns 0.00933 0 0 696 B
#6783 RunOnMethodBegin net472 1.1μs 0.293ns 1.13ns 0.105 0 0 658 B

andrewlock avatar Mar 20 '25 00:03 andrewlock