-
Notifications
You must be signed in to change notification settings - Fork 145
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] Provide default implementation for OpenTelemetry.Context.Propagation.Propagators.DefaultTextMapPropagator [AIDM-504] #6544
base: master
Are you sure you want to change the base?
Conversation
Snapshots difference summaryThe following differences have been observed in committed snapshots. It is meant to help the reviewer. 1 occurrences of : + custom.opentelemetry.defaulttextmappropagator.baggage: key=value,
|
@@ -329,6 +329,9 @@ internal static void InitializeNoNativeParts(Stopwatch sw = null) | |||
{ | |||
Log.Debug("Initializing activity listener."); | |||
Activity.ActivityListener.Initialize(); | |||
|
|||
Log.Debug("Initializing OpenTelemetry components."); | |||
OpenTelemetry.Sdk.Initialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named this Datadog.Trace.OpenTelemetry.Sdk
to better map the concepts to the OpenTelemetry SDK namespacing/file structure, but I'm open to feedback!
Datadog ReportBranch report: ✅ 0 Failed, 202070 Passed, 729 Skipped, 2h 35m 56.49s Total Time |
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:
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 (6544) - mean (69ms) : 65, 72
. : milestone, 69,
master - mean (69ms) : 65, 72
. : milestone, 69,
section CallTarget+Inlining+NGEN
This PR (6544) - mean (981ms) : 962, 1000
. : milestone, 981,
master - mean (976ms) : 956, 996
. : milestone, 976,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6544) - mean (108ms) : 105, 110
. : milestone, 108,
master - mean (107ms) : 105, 109
. : milestone, 107,
section CallTarget+Inlining+NGEN
This PR (6544) - mean (677ms) : 665, 689
. : milestone, 677,
master - mean (672ms) : 658, 687
. : milestone, 672,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6544) - mean (91ms) : 90, 93
. : milestone, 91,
master - mean (91ms) : 89, 93
. : milestone, 91,
section CallTarget+Inlining+NGEN
This PR (6544) - mean (630ms) : 613, 647
. : milestone, 630,
master - mean (632ms) : 619, 646
. : milestone, 632,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6544) - mean (193ms) : 189, 197
. : milestone, 193,
master - mean (193ms) : 188, 198
. : milestone, 193,
section CallTarget+Inlining+NGEN
This PR (6544) - mean (1,097ms) : 1068, 1126
. : milestone, 1097,
master - mean (1,103ms) : 1074, 1132
. : milestone, 1103,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6544) - mean (278ms) : 274, 281
. : milestone, 278,
master - mean (280ms) : 275, 285
. : milestone, 280,
section CallTarget+Inlining+NGEN
This PR (6544) - mean (867ms) : 839, 895
. : milestone, 867,
master - mean (870ms) : 838, 903
. : milestone, 870,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6544) - mean (266ms) : 262, 270
. : milestone, 266,
master - mean (267ms) : 263, 270
. : milestone, 267,
section CallTarget+Inlining+NGEN
This PR (6544) - mean (846ms) : 814, 877
. : milestone, 846,
master - mean (850ms) : 820, 880
. : milestone, 850,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ForceDefaultIdFormat
should be removed as it seems to change the IDs of Hierarchical Activities to be W3C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Benchmarks Report for tracer 🐌Benchmarks for #6544 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Fewer allocations 🎉
|
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 | 41.84 KB | 41.48 KB | -359 B | -0.86% |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | WriteAndFlushEnrichedTraces |
net6.0 | 595μs | 3.43μs | 27.9μs | 0.573 | 0 | 0 | 41.84 KB |
master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 675μs | 3.78μs | 24.8μs | 0.322 | 0 | 0 | 41.76 KB |
master | WriteAndFlushEnrichedTraces |
net472 | 820μs | 2.17μs | 7.84μs | 8.47 | 2.82 | 0.403 | 53.27 KB |
#6544 | WriteAndFlushEnrichedTraces |
net6.0 | 570μs | 2.56μs | 9.57μs | 0.598 | 0 | 0 | 41.48 KB |
#6544 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 683μs | 3.78μs | 22.4μs | 0.321 | 0 | 0 | 41.86 KB |
#6544 | WriteAndFlushEnrichedTraces |
net472 | 842μs | 3.66μs | 14.2μs | 8.52 | 2.44 | 0.406 | 53.28 KB |
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | ExecuteNonQuery |
net6.0 | 1.24μs | 0.971ns | 3.63ns | 0.0144 | 0 | 0 | 1.02 KB |
master | ExecuteNonQuery |
netcoreapp3.1 | 1.86μs | 1.94ns | 7.51ns | 0.0141 | 0 | 0 | 1.02 KB |
master | ExecuteNonQuery |
net472 | 2.07μs | 1.76ns | 6.84ns | 0.156 | 0.00103 | 0 | 987 B |
#6544 | ExecuteNonQuery |
net6.0 | 1.28μs | 1.41ns | 5.29ns | 0.0143 | 0 | 0 | 1.02 KB |
#6544 | ExecuteNonQuery |
netcoreapp3.1 | 1.79μs | 1.28ns | 4.78ns | 0.0143 | 0 | 0 | 1.02 KB |
#6544 | ExecuteNonQuery |
net472 | 2.07μs | 1.9ns | 7.37ns | 0.157 | 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.28μs | 0.474ns | 1.77ns | 0.0135 | 0 | 0 | 976 B |
master | CallElasticsearch |
netcoreapp3.1 | 1.56μs | 1.01ns | 3.79ns | 0.0128 | 0 | 0 | 976 B |
master | CallElasticsearch |
net472 | 2.53μs | 2.86ns | 11.1ns | 0.158 | 0 | 0 | 995 B |
master | CallElasticsearchAsync |
net6.0 | 1.26μs | 0.437ns | 1.63ns | 0.0132 | 0 | 0 | 952 B |
master | CallElasticsearchAsync |
netcoreapp3.1 | 1.62μs | 0.691ns | 2.59ns | 0.014 | 0 | 0 | 1.02 KB |
master | CallElasticsearchAsync |
net472 | 2.57μs | 2.41ns | 9.33ns | 0.166 | 0 | 0 | 1.05 KB |
#6544 | CallElasticsearch |
net6.0 | 1.29μs | 0.521ns | 1.95ns | 0.0136 | 0 | 0 | 976 B |
#6544 | CallElasticsearch |
netcoreapp3.1 | 1.52μs | 0.625ns | 2.34ns | 0.0129 | 0 | 0 | 976 B |
#6544 | CallElasticsearch |
net472 | 2.63μs | 1.89ns | 7.08ns | 0.157 | 0 | 0 | 995 B |
#6544 | CallElasticsearchAsync |
net6.0 | 1.35μs | 0.773ns | 2.99ns | 0.0135 | 0 | 0 | 952 B |
#6544 | CallElasticsearchAsync |
netcoreapp3.1 | 1.62μs | 0.683ns | 2.56ns | 0.0138 | 0 | 0 | 1.02 KB |
#6544 | CallElasticsearchAsync |
net472 | 2.71μs | 1.68ns | 6.5ns | 0.166 | 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.27μs | 0.418ns | 1.62ns | 0.0134 | 0 | 0 | 952 B |
master | ExecuteAsync |
netcoreapp3.1 | 1.62μs | 2.09ns | 8.11ns | 0.0129 | 0 | 0 | 952 B |
master | ExecuteAsync |
net472 | 1.87μs | 0.384ns | 1.44ns | 0.145 | 0 | 0 | 915 B |
#6544 | ExecuteAsync |
net6.0 | 1.39μs | 0.652ns | 2.44ns | 0.0133 | 0 | 0 | 952 B |
#6544 | ExecuteAsync |
netcoreapp3.1 | 1.62μs | 1.11ns | 4.14ns | 0.0129 | 0 | 0 | 952 B |
#6544 | ExecuteAsync |
net472 | 1.81μs | 0.701ns | 2.71ns | 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.6μs | 1.67ns | 6.25ns | 0.0323 | 0 | 0 | 2.31 KB |
master | SendAsync |
netcoreapp3.1 | 5.35μs | 2.31ns | 8.94ns | 0.0375 | 0 | 0 | 2.85 KB |
master | SendAsync |
net472 | 7.48μs | 3.08ns | 11.9ns | 0.493 | 0 | 0 | 3.12 KB |
#6544 | SendAsync |
net6.0 | 4.34μs | 1.8ns | 6.75ns | 0.0305 | 0 | 0 | 2.31 KB |
#6544 | SendAsync |
netcoreapp3.1 | 5.32μs | 3.55ns | 13.8ns | 0.0373 | 0 | 0 | 2.85 KB |
#6544 | SendAsync |
net472 | 7.33μs | 1.73ns | 6.68ns | 0.495 | 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.49μs | 1.11ns | 4.14ns | 0.0231 | 0 | 0 | 1.64 KB |
master | EnrichedLog |
netcoreapp3.1 | 2.14μs | 0.921ns | 3.32ns | 0.0224 | 0 | 0 | 1.64 KB |
master | EnrichedLog |
net472 | 2.78μs | 0.944ns | 3.53ns | 0.249 | 0 | 0 | 1.57 KB |
#6544 | EnrichedLog |
net6.0 | 1.49μs | 1.37ns | 5.32ns | 0.023 | 0 | 0 | 1.64 KB |
#6544 | EnrichedLog |
netcoreapp3.1 | 2.22μs | 9.77ns | 37.8ns | 0.0219 | 0 | 0 | 1.64 KB |
#6544 | EnrichedLog |
net472 | 2.8μs | 1.22ns | 4.55ns | 0.249 | 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 | 116μs | 152ns | 589ns | 0.0579 | 0 | 0 | 4.28 KB |
master | EnrichedLog |
netcoreapp3.1 | 121μs | 143ns | 552ns | 0.0603 | 0 | 0 | 4.28 KB |
master | EnrichedLog |
net472 | 152μs | 137ns | 529ns | 0.684 | 0.228 | 0 | 4.46 KB |
#6544 | EnrichedLog |
net6.0 | 116μs | 159ns | 616ns | 0.0582 | 0 | 0 | 4.28 KB |
#6544 | EnrichedLog |
netcoreapp3.1 | 121μs | 221ns | 857ns | 0 | 0 | 0 | 4.28 KB |
#6544 | EnrichedLog |
net472 | 151μs | 133ns | 516ns | 0.675 | 0.225 | 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.18μs | 1.35ns | 5.23ns | 0.0308 | 0 | 0 | 2.2 KB |
master | EnrichedLog |
netcoreapp3.1 | 4.15μs | 3.25ns | 12.6ns | 0.029 | 0 | 0 | 2.2 KB |
master | EnrichedLog |
net472 | 4.86μs | 1.52ns | 5.88ns | 0.32 | 0 | 0 | 2.02 KB |
#6544 | EnrichedLog |
net6.0 | 3μs | 0.845ns | 3.27ns | 0.03 | 0 | 0 | 2.2 KB |
#6544 | EnrichedLog |
netcoreapp3.1 | 4.34μs | 1.78ns | 6.18ns | 0.0285 | 0 | 0 | 2.2 KB |
#6544 | EnrichedLog |
net472 | 4.95μs | 1.71ns | 6.61ns | 0.318 | 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.29μs | 0.673ns | 2.61ns | 0.0162 | 0 | 0 | 1.14 KB |
master | SendReceive |
netcoreapp3.1 | 1.75μs | 1.02ns | 3.94ns | 0.0157 | 0 | 0 | 1.14 KB |
master | SendReceive |
net472 | 2.06μs | 0.975ns | 3.78ns | 0.184 | 0 | 0 | 1.16 KB |
#6544 | SendReceive |
net6.0 | 1.32μs | 0.687ns | 2.57ns | 0.0158 | 0 | 0 | 1.14 KB |
#6544 | SendReceive |
netcoreapp3.1 | 1.76μs | 0.7ns | 2.71ns | 0.0158 | 0 | 0 | 1.14 KB |
#6544 | SendReceive |
net472 | 2.09μs | 0.553ns | 2.07ns | 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.76μs | 3.03ns | 11.7ns | 0.0219 | 0 | 0 | 1.6 KB |
master | EnrichedLog |
netcoreapp3.1 | 3.98μs | 1.12ns | 4.35ns | 0.0218 | 0 | 0 | 1.65 KB |
master | EnrichedLog |
net472 | 4.33μs | 2.73ns | 10.2ns | 0.324 | 0 | 0 | 2.04 KB |
#6544 | EnrichedLog |
net6.0 | 2.81μs | 1.23ns | 4.77ns | 0.0226 | 0 | 0 | 1.6 KB |
#6544 | EnrichedLog |
netcoreapp3.1 | 3.8μs | 2.65ns | 10.2ns | 0.0229 | 0 | 0 | 1.65 KB |
#6544 | EnrichedLog |
net472 | 4.25μs | 4.23ns | 16.4ns | 0.323 | 0 | 0 | 2.04 KB |
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️
Faster 🎉 in #6544
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1
1.114
636.02
570.76
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 | 1.114 | 636.02 | 570.76 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 399ns | 0.141ns | 0.526ns | 0.008 | 0 | 0 | 576 B |
master | StartFinishSpan |
netcoreapp3.1 | 636ns | 0.276ns | 1.03ns | 0.00763 | 0 | 0 | 576 B |
master | StartFinishSpan |
net472 | 666ns | 0.542ns | 2.1ns | 0.0917 | 0 | 0 | 578 B |
master | StartFinishScope |
net6.0 | 481ns | 0.318ns | 1.23ns | 0.00986 | 0 | 0 | 696 B |
master | StartFinishScope |
netcoreapp3.1 | 718ns | 0.334ns | 1.25ns | 0.00932 | 0 | 0 | 696 B |
master | StartFinishScope |
net472 | 837ns | 0.656ns | 2.54ns | 0.104 | 0 | 0 | 658 B |
#6544 | StartFinishSpan |
net6.0 | 399ns | 0.18ns | 0.675ns | 0.00808 | 0 | 0 | 576 B |
#6544 | StartFinishSpan |
netcoreapp3.1 | 571ns | 0.497ns | 1.86ns | 0.00788 | 0 | 0 | 576 B |
#6544 | StartFinishSpan |
net472 | 738ns | 0.815ns | 3.16ns | 0.0918 | 0 | 0 | 578 B |
#6544 | StartFinishScope |
net6.0 | 483ns | 0.32ns | 1.24ns | 0.00971 | 0 | 0 | 696 B |
#6544 | StartFinishScope |
netcoreapp3.1 | 706ns | 0.457ns | 1.77ns | 0.00926 | 0 | 0 | 696 B |
#6544 | StartFinishScope |
net472 | 851ns | 0.947ns | 3.67ns | 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 | 690ns | 0.524ns | 2.03ns | 0.0098 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 859ns | 0.616ns | 2.39ns | 0.00955 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
net472 | 1.03μs | 0.655ns | 2.54ns | 0.105 | 0 | 0 | 658 B |
#6544 | RunOnMethodBegin |
net6.0 | 659ns | 0.364ns | 1.41ns | 0.00978 | 0 | 0 | 696 B |
#6544 | RunOnMethodBegin |
netcoreapp3.1 | 946ns | 0.45ns | 1.74ns | 0.009 | 0 | 0 | 696 B |
#6544 | RunOnMethodBegin |
net472 | 1.06μs | 0.688ns | 2.66ns | 0.104 | 0 | 0 | 658 B |
Summary of changes
At instrumentation startup, if
OpenTelemetry.Api v1.0.0+
is present, replace theOpenTelemetry.Context.Propagation.Propagators.DefaultTextMapPropagator
implementation (defaults to aNoopTextMapPropagator
) with the following:Reason for change
There is a current feature gap when the user tries to use
OpenTelemetry.Context.Propagation.Propagators.DefaultTextMapPropagator
.If the user is using the OpenTelemetry SDK, the static property gets overwritten with a functioning implementation when the OpenTelemetry.Sdk type is loaded.
However, if the user removes the OpenTelemetry SDK from their application and relies on the Datadog .NET Tracer for implementing the OpenTelemetry Tracing API, the default propagator no longer gets a functional implementation. This change addresses that gap.
Implementation details
At instrumentation initialization, if the OpenTelemetry support is enabled (
DD_TRACE_OTEL_ENABLED=true
), use reflection to call into the staticOpenTelemetry.Context.Propagation.Propagators
class and overwrite theDefaultTextMapPropagator
property in the same way as the OpenTelemetry SDK would, with a propagator that propagates W3C Tracecontext and W3C Baggage.Test coverage
This PR adds to the snapshot testing of the
Samples.NetActivitySdk
application, asserting that the context propagation has a functioning implementation.Other details