[Tracer] Add API to extract SpanContext#2694
Merged
Merged
Conversation
pierotibou
force-pushed
the
pierre/new-extraction-api
branch
from
April 19, 2022 09:18
3801c4c to
0721193
Compare
andrewlock
approved these changes
Apr 19, 2022
andrewlock
left a comment
Member
There was a problem hiding this comment.
LGTM, though not a fan of the name. How about SpanContextExtractor?
Also, although we don't need tests per-se, it would be good to do one or both of:
- Update the sample app (tracer/samples/RabbitMQ.DistributedTracing) to use this API
- Maybe update the kafka tests to use the API too?
This comment has been minimized.
This comment has been minimized.
pierotibou
force-pushed
the
pierre/new-extraction-api
branch
from
April 19, 2022 13:05
003fbac to
1b1c81f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Member
Benchmarks Report 🐌Benchmarks for #2694 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️
|
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 | 1.161 | 1,296.46 | 1,116.51 | |
| Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net472 | 1.152 | 1,256.46 | 1,090.36 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net472 | 947ns | 4.61ns | 18.4ns | 0.0717 | 0 | 0 | 457 B |
| master | StartFinishSpan |
netcoreapp3.1 | 884ns | 4.26ns | 16.5ns | 0.00632 | 0 | 0 | 456 B |
| master | StartFinishScope |
net472 | 1.26μs | 7.19ns | 54.8ns | 0.0845 | 0 | 0 | 538 B |
| master | StartFinishScope |
netcoreapp3.1 | 1.3μs | 6.73ns | 32.3ns | 0.00786 | 0 | 0 | 576 B |
| #2694 | StartFinishSpan |
net472 | 975ns | 4.98ns | 22.3ns | 0.0715 | 0 | 0 | 457 B |
| #2694 | StartFinishSpan |
netcoreapp3.1 | 874ns | 4.01ns | 17.5ns | 0.0062 | 0 | 0 | 456 B |
| #2694 | StartFinishScope |
net472 | 1.1μs | 5.48ns | 25.1ns | 0.0845 | 0 | 0 | 538 B |
| #2694 | StartFinishScope |
netcoreapp3.1 | 1.12μs | 3.38ns | 13.1ns | 0.00769 | 0 | 0 | 576 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 |
net472 | 1.37μs | 5.36ns | 20.1ns | 0.0838 | 0 | 0 | 538 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.25μs | 7.29ns | 65.2ns | 0.00798 | 0 | 0 | 576 B |
| #2694 | RunOnMethodBegin |
net472 | 1.27μs | 5.62ns | 28.1ns | 0.0845 | 0 | 0 | 538 B |
| #2694 | RunOnMethodBegin |
netcoreapp3.1 | 1.24μs | 7.02ns | 46ns | 0.00789 | 0 | 0 | 576 B |
pierotibou
force-pushed
the
pierre/new-extraction-api
branch
from
April 20, 2022 22:08
bd68fa8 to
dc57737
Compare
pierotibou
force-pushed
the
pierre/new-extraction-api
branch
from
April 20, 2022 22:18
61fbf92 to
15eb8c5
Compare
zacharycmontoya
approved these changes
Apr 20, 2022
Member
Code Coverage Report 📊
View the full report for further details: Datadog.Trace Breakdown
|
| master | #2694 | Change | |
|---|---|---|---|
| Lines % | 73% |
71% |
-2% |
| Branches % | 70% |
68% |
-2% |
| Complexity | 12433 |
12454 |
21 ⛔ |
The following classes have significant coverage changes.
The following classes were added in #2694:
| File | Line coverage | Branch coverage | Complexity |
|---|---|---|---|
| Datadog.Trace.SpanContextExtractor | 0% |
100% |
1 |
View the full reports for further details:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Introduce an API to allow the extraction of the SpanContext when the Tracer couldn't do it.
Api:
Calling code:
Where
GetHeaderValueswill depend on the underlying system used. Here are a few examples:Reason for change
In some cases, propagation cannot happen. For instance, Streamiz, a library implemented above the Confluent Kafka, enqueues messages before spans are created, and thus before context can be propagated.
This API gives the liberty of extracting such context and passing it to custom spans.
Implementation details
A new API called
SpanContextExtractorcalls ourSpanContextPropagatorgiven a carrier and a getter. It is basically a public API above an internal one.I've chosen to make it non static and to add an interface as some of our customers ask to be given ways to mock our APIs. It is located in
Datadog.Tracenamespace for better usability for users.We had discussed other ways to provide this API, but this one seemed the most simple and relevant.
Test coverage
No Utests as it would be testing what we already do.
Changed our RabbitMq tests to validate that distributed tracing is working in both cases
Other details
Fixes APMS-7021