Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tracing] Refactor internal Span Links API #6341

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zacharycmontoya
Copy link
Collaborator

@zacharycmontoya zacharycmontoya commented Nov 22, 2024

Summary of changes

Updates the internal Datadog API for adding links to span

Reason for change

This aligns the API more closely with the OpenTelemetry Tracing API spec, as well as the Activity API

Implementation details

Test coverage

Other details

…his updated interface is eaiser to use from instrumentations when there are no Spans for incoming headers, only span contexts.
- Rename the method from AddSpanLink to AddLink (this also mirrors the suggestion from OpenTelemetry Tracing API spec)
- Return the Span object instead of returning nothing
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Nov 22, 2024

Datadog Report

Branch report: zach.montoya/refactor-span-links
Commit report: 4cfb37f
Test service: dd-trace-dotnet

❌ 1 Failed (0 Known Flaky), 454347 Passed, 2742 Skipped, 19h 12m 0.44s Total Time

❌ Failed Tests (1)

  • SnapshotBiggerThanMaxSize_TwoLevel_OneSliced - Datadog.Trace.Tests.Debugger.SnapshotSlicerTests - Details

    Expand for error
     Unexpected end of content while loading JObject. Path 'debugger', line 1, position 7755.
    

@andrewlock
Copy link
Member

Execution-Time Benchmarks Report ⏱️

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 (6341) - mean (72ms)  : 64, 79
     .   : milestone, 72,
    master - mean (72ms)  : 62, 82
     .   : milestone, 72,

    section CallTarget+Inlining+NGEN
    This PR (6341) - mean (985ms)  : 960, 1011
     .   : milestone, 985,
    master - mean (1,106ms)  : 1090, 1122
     .   : milestone, 1106,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6341) - mean (109ms)  : 107, 111
     .   : milestone, 109,
    master - mean (109ms)  : 106, 111
     .   : milestone, 109,

    section CallTarget+Inlining+NGEN
    This PR (6341) - mean (686ms)  : 671, 702
     .   : milestone, 686,
    master - mean (766ms)  : 751, 781
     .   : milestone, 766,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6341) - mean (92ms)  : 90, 94
     .   : milestone, 92,
    master - mean (92ms)  : 90, 94
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (6341) - mean (637ms)  : 623, 652
     .   : milestone, 637,
    master - mean (728ms)  : 710, 745
     .   : milestone, 728,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6341) - mean (191ms)  : 185, 197
     .   : milestone, 191,
    master - mean (191ms)  : 182, 200
     .   : milestone, 191,

    section CallTarget+Inlining+NGEN
    This PR (6341) - mean (1,100ms)  : 1074, 1126
     .   : milestone, 1100,
    master - mean (1,215ms)  : 1189, 1241
     .   : milestone, 1215,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6341) - mean (277ms)  : 273, 281
     .   : milestone, 277,
    master - mean (277ms)  : 271, 284
     .   : milestone, 277,

    section CallTarget+Inlining+NGEN
    This PR (6341) - mean (873ms)  : 848, 898
     .   : milestone, 873,
    master - mean (943ms)  : 927, 959
     .   : milestone, 943,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6341) - mean (265ms)  : 261, 268
     .   : milestone, 265,
    master - mean (265ms)  : 262, 269
     .   : milestone, 265,

    section CallTarget+Inlining+NGEN
    This PR (6341) - mean (857ms)  : 817, 898
     .   : milestone, 857,
    master - mean (927ms)  : 910, 944
     .   : milestone, 927,

Loading

@andrewlock
Copy link
Member

Benchmarks Report for tracer 🐌

Benchmarks for #6341 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.128
  • 2 benchmarks are slower, with geometric mean 1.150
  • All benchmarks have the same 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 ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.01μs 45.5ns 334ns 0.0158 0.00792 0 5.61 KB
master StartStopWithChild netcoreapp3.1 9.7μs 46.5ns 246ns 0.0194 0.00485 0 5.8 KB
master StartStopWithChild net472 16.2μs 55.5ns 215ns 1.03 0.292 0.0891 6.21 KB
#6341 StartStopWithChild net6.0 7.88μs 43.9ns 284ns 0.0189 0.00756 0 5.61 KB
#6341 StartStopWithChild netcoreapp3.1 9.95μs 55.7ns 361ns 0.025 0.00999 0 5.8 KB
#6341 StartStopWithChild net472 16.3μs 76.2ns 305ns 1.03 0.302 0.0953 6.2 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 488μs 250ns 934ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 654μs 257ns 926ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 864μs 283ns 1.06μs 0.431 0 0 3.3 KB
#6341 WriteAndFlushEnrichedTraces net6.0 476μs 250ns 935ns 0 0 0 2.7 KB
#6341 WriteAndFlushEnrichedTraces netcoreapp3.1 665μs 227ns 880ns 0 0 0 2.7 KB
#6341 WriteAndFlushEnrichedTraces net472 851μs 570ns 2.13μs 0.422 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 151μs 879ns 7.81μs 0.146 0 0 14.47 KB
master SendRequest netcoreapp3.1 173μs 1.01μs 10μs 0.155 0 0 17.27 KB
master SendRequest net472 0.000363ns 0.000352ns 0.00132ns 0 0 0 0 b
#6341 SendRequest net6.0 149μs 856ns 6.9μs 0.158 0 0 14.47 KB
#6341 SendRequest netcoreapp3.1 168μs 978ns 8.47μs 0.164 0 0 17.27 KB
#6341 SendRequest net472 0.000549ns 0.000293ns 0.0011ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 556μs 2.12μs 8.2μs 0.571 0 0 41.66 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 676μs 3.09μs 14.8μs 0.37 0 0 41.73 KB
master WriteAndFlushEnrichedTraces net472 892μs 2.61μs 10.1μs 8.04 2.23 0.446 53.32 KB
#6341 WriteAndFlushEnrichedTraces net6.0 570μs 2.17μs 8.42μs 0.566 0 0 41.73 KB
#6341 WriteAndFlushEnrichedTraces netcoreapp3.1 681μs 3.55μs 16.7μs 0.343 0 0 41.7 KB
#6341 WriteAndFlushEnrichedTraces net472 851μs 2.76μs 10.3μs 8.25 2.6 0.434 53.3 KB
Benchmarks.Trace.DbCommandBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #6341

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑net6.0 1.128 1,372.20 1,216.80

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.37μs 1.21ns 4.7ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.82μs 1.62ns 6.28ns 0.0137 0 0 1.02 KB
master ExecuteNonQuery net472 2.13μs 2.15ns 8.32ns 0.156 0.00108 0 987 B
#6341 ExecuteNonQuery net6.0 1.22μs 0.472ns 1.77ns 0.0141 0 0 1.02 KB
#6341 ExecuteNonQuery netcoreapp3.1 1.74μs 1.43ns 5.36ns 0.013 0 0 1.02 KB
#6341 ExecuteNonQuery net472 2.07μs 1.71ns 6.62ns 0.156 0.00103 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.17μs 0.499ns 1.87ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.58μs 0.727ns 2.72ns 0.0127 0 0 976 B
master CallElasticsearch net472 2.58μs 1.82ns 7.07ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.19μs 0.567ns 2.12ns 0.013 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.6μs 0.717ns 2.78ns 0.0137 0 0 1.02 KB
master CallElasticsearchAsync net472 2.69μs 1.03ns 3.85ns 0.166 0 0 1.05 KB
#6341 CallElasticsearch net6.0 1.26μs 0.501ns 1.94ns 0.0139 0 0 976 B
#6341 CallElasticsearch netcoreapp3.1 1.56μs 1.03ns 4.01ns 0.0133 0 0 976 B
#6341 CallElasticsearch net472 2.6μs 1.38ns 5.36ns 0.158 0 0 995 B
#6341 CallElasticsearchAsync net6.0 1.31μs 0.355ns 1.33ns 0.013 0 0 952 B
#6341 CallElasticsearchAsync netcoreapp3.1 1.74μs 0.78ns 3.02ns 0.0139 0 0 1.02 KB
#6341 CallElasticsearchAsync net472 2.62μs 0.79ns 3.06ns 0.167 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.41μs 0.86ns 3.33ns 0.0135 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.61μs 0.577ns 2.08ns 0.0131 0 0 952 B
master ExecuteAsync net472 1.82μs 0.762ns 2.85ns 0.145 0 0 915 B
#6341 ExecuteAsync net6.0 1.32μs 0.636ns 2.46ns 0.0132 0 0 952 B
#6341 ExecuteAsync netcoreapp3.1 1.59μs 0.873ns 3.15ns 0.0129 0 0 952 B
#6341 ExecuteAsync net472 1.79μs 0.883ns 3.42ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.28μs 1.2ns 4.47ns 0.0323 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.42μs 15.4ns 59.8ns 0.0376 0 0 2.85 KB
master SendAsync net472 7.34μs 2.32ns 9ns 0.492 0 0 3.12 KB
#6341 SendAsync net6.0 4.3μs 1.75ns 6.8ns 0.032 0 0 2.31 KB
#6341 SendAsync netcoreapp3.1 5.3μs 2.08ns 8.04ns 0.0371 0 0 2.85 KB
#6341 SendAsync net472 7.25μs 2.4ns 9.29ns 0.494 0 0 3.12 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.45μs 0.784ns 2.83ns 0.0226 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.18μs 0.945ns 3.54ns 0.0218 0 0 1.64 KB
master EnrichedLog net472 2.54μs 1.75ns 6.54ns 0.249 0 0 1.57 KB
#6341 EnrichedLog net6.0 1.59μs 1.54ns 5.95ns 0.0232 0 0 1.64 KB
#6341 EnrichedLog netcoreapp3.1 2.27μs 1.33ns 4.8ns 0.0217 0 0 1.64 KB
#6341 EnrichedLog net472 2.61μs 1.39ns 5.39ns 0.25 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 121μs 127ns 492ns 0.0609 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 125μs 212ns 820ns 0 0 0 4.28 KB
master EnrichedLog net472 152μs 141ns 545ns 0.684 0.228 0 4.46 KB
#6341 EnrichedLog net6.0 119μs 124ns 482ns 0.0605 0 0 4.28 KB
#6341 EnrichedLog netcoreapp3.1 123μs 218ns 845ns 0 0 0 4.28 KB
#6341 EnrichedLog net472 152μs 142ns 548ns 0.685 0.228 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 3.2μs 1ns 3.87ns 0.0304 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.18μs 1.04ns 3.91ns 0.0293 0 0 2.2 KB
master EnrichedLog net472 4.79μs 1.61ns 5.57ns 0.318 0 0 2.02 KB
#6341 EnrichedLog net6.0 3.19μs 2.66ns 9.96ns 0.0303 0 0 2.2 KB
#6341 EnrichedLog netcoreapp3.1 4.24μs 1.89ns 7.33ns 0.0297 0 0 2.2 KB
#6341 EnrichedLog net472 4.91μs 1.6ns 5.97ns 0.32 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.33μs 0.772ns 2.99ns 0.0158 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.86μs 0.538ns 2.08ns 0.0148 0 0 1.14 KB
master SendReceive net472 2.06μs 1.59ns 5.95ns 0.183 0 0 1.16 KB
#6341 SendReceive net6.0 1.26μs 0.733ns 2.84ns 0.0158 0 0 1.14 KB
#6341 SendReceive netcoreapp3.1 1.79μs 0.503ns 1.88ns 0.0151 0 0 1.14 KB
#6341 SendReceive net472 2.2μs 1.97ns 7.62ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.73μs 0.649ns 2.43ns 0.0218 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.99μs 2.16ns 8.38ns 0.022 0 0 1.65 KB
master EnrichedLog net472 4.29μs 2.27ns 8.48ns 0.322 0 0 2.04 KB
#6341 EnrichedLog net6.0 2.94μs 0.834ns 3.23ns 0.022 0 0 1.6 KB
#6341 EnrichedLog netcoreapp3.1 3.88μs 1.77ns 6.63ns 0.0213 0 0 1.65 KB
#6341 EnrichedLog net472 4.49μs 2.29ns 8.89ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6341

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.174 397.97 467.41
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.125 599.32 674.47

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 398ns 0.624ns 2.42ns 0.008 0 0 576 B
master StartFinishSpan netcoreapp3.1 612ns 0.604ns 2.26ns 0.00772 0 0 576 B
master StartFinishSpan net472 599ns 0.633ns 2.37ns 0.0917 0 0 578 B
master StartFinishScope net6.0 482ns 0.756ns 2.93ns 0.00971 0 0 696 B
master StartFinishScope netcoreapp3.1 759ns 0.973ns 3.77ns 0.00945 0 0 696 B
master StartFinishScope net472 919ns 1.84ns 7.11ns 0.104 0 0 658 B
#6341 StartFinishSpan net6.0 467ns 0.821ns 3.18ns 0.00801 0 0 576 B
#6341 StartFinishSpan netcoreapp3.1 563ns 0.856ns 3.32ns 0.00762 0 0 576 B
#6341 StartFinishSpan net472 675ns 1.45ns 5.61ns 0.0918 0 0 578 B
#6341 StartFinishScope net6.0 494ns 0.716ns 2.77ns 0.00988 0 0 696 B
#6341 StartFinishScope netcoreapp3.1 788ns 0.441ns 1.71ns 0.00918 0 0 696 B
#6341 StartFinishScope net472 848ns 1.4ns 5.44ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 599ns 0.34ns 1.32ns 0.00976 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 930ns 1.45ns 5.23ns 0.00935 0 0 696 B
master RunOnMethodBegin net472 1.13μs 2.19ns 8.49ns 0.104 0 0 658 B
#6341 RunOnMethodBegin net6.0 654ns 1.06ns 4.1ns 0.00987 0 0 696 B
#6341 RunOnMethodBegin netcoreapp3.1 930ns 1.49ns 5.76ns 0.00927 0 0 696 B
#6341 RunOnMethodBegin net472 1.1μs 2.14ns 8.29ns 0.104 0 0 658 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants