-
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
Extract Upper64 bit trace ID from extension response #6041
Extract Upper64 bit trace ID from extension response #6041
Conversation
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 (6041) - mean (69ms) : 68, 71
. : milestone, 69,
master - mean (70ms) : 67, 73
. : milestone, 70,
section CallTarget+Inlining+NGEN
This PR (6041) - mean (1,108ms) : 1084, 1133
. : milestone, 1108,
master - mean (1,109ms) : 1084, 1133
. : milestone, 1109,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6041) - mean (109ms) : 106, 112
. : milestone, 109,
master - mean (109ms) : 106, 111
. : milestone, 109,
section CallTarget+Inlining+NGEN
This PR (6041) - mean (770ms) : 754, 786
. : milestone, 770,
master - mean (769ms) : 749, 790
. : milestone, 769,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6041) - mean (92ms) : 89, 95
. : milestone, 92,
master - mean (92ms) : 89, 94
. : milestone, 92,
section CallTarget+Inlining+NGEN
This PR (6041) - mean (721ms) : 706, 736
. : milestone, 721,
master - mean (727ms) : 707, 746
. : milestone, 727,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6041) - mean (191ms) : 187, 195
. : milestone, 191,
master - mean (192ms) : 188, 196
. : milestone, 192,
section CallTarget+Inlining+NGEN
This PR (6041) - mean (1,205ms) : 1178, 1231
. : milestone, 1205,
master - mean (1,203ms) : 1180, 1226
. : milestone, 1203,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6041) - mean (276ms) : 272, 280
. : milestone, 276,
master - mean (276ms) : 272, 280
. : milestone, 276,
section CallTarget+Inlining+NGEN
This PR (6041) - mean (946ms) : 929, 962
. : milestone, 946,
master - mean (946ms) : 925, 968
. : milestone, 946,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6041) - mean (265ms) : 260, 270
. : milestone, 265,
master - mean (265ms) : 261, 269
. : milestone, 265,
section CallTarget+Inlining+NGEN
This PR (6041) - mean (927ms) : 908, 945
. : milestone, 927,
master - mean (930ms) : 912, 948
. : milestone, 930,
|
Datadog ReportBranch report: ✅ 0 Failed, 363186 Passed, 2063 Skipped, 14h 59m 32.05s Total Time |
Throughput/Crank Report ⚡Throughput results for AspNetCoreSimpleController comparing the following branches/commits: Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red. Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards! gantt
title Throughput Linux x64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6041) (11.244M) : 0, 11244059
master (11.101M) : 0, 11100941
benchmarks/2.9.0 (11.081M) : 0, 11080577
section Automatic
This PR (6041) (7.434M) : 0, 7434070
master (7.389M) : 0, 7389242
benchmarks/2.9.0 (7.732M) : 0, 7732233
section Trace stats
master (7.528M) : 0, 7528321
section Manual
master (10.986M) : 0, 10986040
section Manual + Automatic
This PR (6041) (6.862M) : 0, 6862422
master (6.820M) : 0, 6819504
section DD_TRACE_ENABLED=0
master (10.304M) : 0, 10304285
gantt
title Throughput Linux arm64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6041) (9.777M) : 0, 9777037
master (9.728M) : 0, 9727588
benchmarks/2.9.0 (9.798M) : 0, 9798067
section Automatic
This PR (6041) (6.768M) : 0, 6768161
master (6.463M) : 0, 6463228
section Trace stats
master (6.591M) : 0, 6591023
section Manual
master (9.627M) : 0, 9627166
section Manual + Automatic
This PR (6041) (6.092M) : 0, 6092230
master (6.028M) : 0, 6027833
section DD_TRACE_ENABLED=0
master (8.762M) : 0, 8761785
gantt
title Throughput Windows x64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6041) (10.002M) : 0, 10001542
master (9.966M) : 0, 9965554
benchmarks/2.9.0 (10.067M) : 0, 10067315
section Automatic
This PR (6041) (6.758M) : 0, 6757917
master (6.494M) : 0, 6493647
benchmarks/2.9.0 (7.552M) : 0, 7552193
section Trace stats
master (7.096M) : 0, 7096492
section Manual
master (9.850M) : 0, 9850046
section Manual + Automatic
This PR (6041) (6.245M) : 0, 6244577
master (5.952M) : 0, 5952386
section DD_TRACE_ENABLED=0
master (9.119M) : 0, 9118624
|
Benchmarks Report for tracer 🐌Benchmarks for #6041 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 ✔️ 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 - Slower
|
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 | 1.204 | 399.98 | 481.52 |
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 | 1.135 | 557.61 | 491.38 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 400ns | 0.175ns | 0.655ns | 0.00807 | 0 | 0 | 576 B |
master | StartFinishSpan |
netcoreapp3.1 | 595ns | 0.31ns | 1.16ns | 0.00798 | 0 | 0 | 576 B |
master | StartFinishSpan |
net472 | 667ns | 0.434ns | 1.62ns | 0.0916 | 0 | 0 | 578 B |
master | StartFinishScope |
net6.0 | 558ns | 0.48ns | 1.86ns | 0.00976 | 0 | 0 | 696 B |
master | StartFinishScope |
netcoreapp3.1 | 737ns | 0.788ns | 3.05ns | 0.0093 | 0 | 0 | 696 B |
master | StartFinishScope |
net472 | 851ns | 0.757ns | 2.83ns | 0.104 | 0 | 0 | 658 B |
#6041 | StartFinishSpan |
net6.0 | 482ns | 0.16ns | 0.598ns | 0.008 | 0 | 0 | 576 B |
#6041 | StartFinishSpan |
netcoreapp3.1 | 617ns | 0.827ns | 3.2ns | 0.00792 | 0 | 0 | 576 B |
#6041 | StartFinishSpan |
net472 | 704ns | 0.303ns | 1.17ns | 0.0916 | 0 | 0 | 578 B |
#6041 | StartFinishScope |
net6.0 | 492ns | 0.216ns | 0.838ns | 0.00965 | 0 | 0 | 696 B |
#6041 | StartFinishScope |
netcoreapp3.1 | 732ns | 1.37ns | 5.31ns | 0.00951 | 0 | 0 | 696 B |
#6041 | StartFinishScope |
net472 | 888ns | 0.906ns | 3.51ns | 0.104 | 0 | 0 | 658 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #6041
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0
1.150
593.66
682.98
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 | 1.150 | 593.66 | 682.98 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | RunOnMethodBegin |
net6.0 | 594ns | 0.286ns | 1.11ns | 0.00978 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 949ns | 1.54ns | 5.78ns | 0.00934 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
net472 | 1.15μs | 0.353ns | 1.37ns | 0.104 | 0 | 0 | 658 B |
#6041 | RunOnMethodBegin |
net6.0 | 682ns | 0.751ns | 2.91ns | 0.00984 | 0 | 0 | 696 B |
#6041 | RunOnMethodBegin |
netcoreapp3.1 | 906ns | 0.853ns | 3.31ns | 0.00939 | 0 | 0 | 696 B |
#6041 | RunOnMethodBegin |
net472 | 1.15μs | 0.492ns | 1.77ns | 0.104 | 0 | 0 | 658 B |
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
scope.Should().NotBeNull(); | ||
scope.Span.TraceId128.Should().Be((TraceId)1234); | ||
((ISpan)scope.Span).TraceId.Should().Be(1234); | ||
scope.Span.SpanId.Should().BeGreaterThan(0); | ||
} | ||
|
||
[Fact] | ||
public async Task TestCreatePlaceholderScopeSuccessWithSamplingPriorityOnly() |
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 wound up removing this test since dd-trace doesn't seem to allow a distributed trace with no trace ID.
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.
That's right. A trace id is required when extracting trace context from headers, otherwise we ignore all the other data. But what changed here? Are we now trying to propagate trace context without a trace id?
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.
But what changed here?
Oh, I see. The null
in LambdaCommon.CreatePlaceholderScope(tracer, null, "-1")
below was the trace id, and it was handled differently since the previous code was not using SpanContextPropagator
.
|
||
scope.Should().NotBeNull(); | ||
scope.Span.TraceId128.Should().Be((TraceId)1234); | ||
((ISpan)scope.Span).TraceId.Should().Be(1234); | ||
scope.Span.TraceId128.ToString().Should().Be("1914fe7789eb32be4fb6f07e011a6faf"); |
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.
This value agrees with dd-trace-java
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.
Confirmed that 1914fe7789eb32be4fb6f07e011a6faf
has
1914fe7789eb32be
in the upper 64 bits4fb6f07e011a6faf
(5744042798732701615
) in the lower 64 bits
Could you fill out the PR description? |
@bouwkast Yep! My mistake |
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
…n' of github.com:DataDog/dd-trace-dotnet into chris.agocs/parse_128_bit_trace_id_from_lambda_extension
Figuring out the null references in the tests... |
I cherry-picked from this branch back into this branch 🤦. I think no damage was done |
…n' of github.com:DataDog/dd-trace-dotnet into chris.agocs/parse_128_bit_trace_id_from_lambda_extension
This comment was marked as outdated.
This comment was marked as outdated.
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/Lambda/LambdaCommon.cs
Outdated
Show resolved
Hide resolved
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.
Just a nitpick but looks good to me!
Log($"setting the placeholder sampling priority to = {samplingPriority}"); | ||
span.Context.TraceContext?.SetSamplingPriority(Convert.ToInt32(samplingPriority), notifyDistributedTracer: false); | ||
} | ||
var span = spanContext != null ? tracer.StartSpan(PlaceholderOperationName, tags: null, parent: spanContext, serviceName: PlaceholderServiceName, addToTraceContext: false) : tracer.StartSpan(PlaceholderOperationName, tags: null, serviceName: PlaceholderServiceName, addToTraceContext: false); |
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.
nitpick
var span = spanContext != null ? tracer.StartSpan(PlaceholderOperationName, tags: null, parent: spanContext, serviceName: PlaceholderServiceName, addToTraceContext: false) : tracer.StartSpan(PlaceholderOperationName, tags: null, serviceName: PlaceholderServiceName, addToTraceContext: false); | |
var span = tracer.StartSpan(PlaceholderOperationName, tags: null, parent: spanContext, serviceName: PlaceholderServiceName, addToTraceContext: false); |
I don't think the spanContext != null
is necessary as we'll always be calling the same StartSpan
function and parent
can be set to null
- that is the default value.
## Summary of changes I've updated the Lambda extension so it is capable of returning a 128 bit trace ID when a tracer calls the `/lambda/start-invocation` endpoint [in this PR](DataDog/datadog-agent#27988) As per [the RFC](https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/3545630931/RFC+Support+128+bit+trace+IDs+in+RUM+SDKs#:~:text=For%20Datadog%20headers%2C%20the%20128%20bit%20trace%20id%20is%20sent%20in%20two%20parts%2C%20lower%2064%20bits%20in%20x%2Ddatadog%2Dtrace%2Did%20(decimal)%20and%20the%20higher%2064%20bits%20in%20x%2Ddatadog%2Dtags%20header%20under%20_dd.p.tid%20(hex)%20tag), the > lower 64 bits in `x-datadog-trace-id` (decimal) and the higher 64 bits in `x-datadog-tags` header under `_dd.p.tid` (hex) tag. This change modifies the function that calls `/lambda/start-invocation`, allowing it to pick out the upper 64 bits of the trace ID and set the resulting 128-bit trace ID in the extracted context. ## Reason for change The Lambda Extension may now return a 128 bit trace ID when a Step Function invokes a Lambda Function. ## Implementation details I rewrote LambdaCommon's `CreatePlaceholderScope` so it uses `SpanContextPropagator.Instance.Extract` rather than extracting trace context elements one by one. ## Test coverage Added a unit test for 128 bit trace IDs. Fixed existing unit tests so they pass a dictionary of headers to CreatePlaceholderScope. Removed a unit test that only passes SamplingPriority, since a distributed trace with only a sampling priority is hardly a distributed trace at all. ## Other details Backported to 2.x in (TODO) <!-- Fixes #{issue} --> <!--⚠️ Note: where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. --> --------- Co-authored-by: Lucas Pimentel <[email protected]> Co-authored-by: Andrew Lock <[email protected]> Co-authored-by: Daniel Romano <[email protected]> Co-authored-by: Steven Bouwkamp <[email protected]> Co-authored-by: Anna <[email protected]> Co-authored-by: NachoEchevarria <[email protected]> Co-authored-by: William Conti <[email protected]> Co-authored-by: Kevin Gosse <[email protected]> Co-authored-by: Tony Redondo <[email protected]> Co-authored-by: Gregory LEOCADIE <[email protected]>
…6181) ## Summary of changes I've updated the Lambda extension so it is capable of returning a 128 bit trace ID when a tracer calls the `/lambda/start-invocation` endpoint [in this PR](DataDog/datadog-agent#27988) As per [the RFC](https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/3545630931/RFC+Support+128+bit+trace+IDs+in+RUM+SDKs#:~:text=For%20Datadog%20headers%2C%20the%20128%20bit%20trace%20id%20is%20sent%20in%20two%20parts%2C%20lower%2064%20bits%20in%20x%2Ddatadog%2Dtrace%2Did%20(decimal)%20and%20the%20higher%2064%20bits%20in%20x%2Ddatadog%2Dtags%20header%20under%20_dd.p.tid%20(hex)%20tag), the > lower 64 bits in `x-datadog-trace-id` (decimal) and the higher 64 bits in `x-datadog-tags` header under `_dd.p.tid` (hex) tag. This change modifies the function that calls `/lambda/start-invocation`, allowing it to pick out the upper 64 bits of the trace ID and set the resulting 128-bit trace ID in the extracted context. ## Reason for change The Lambda Extension may now return a 128 bit trace ID when a Step Function invokes a Lambda Function. ## Implementation details I rewrote LambdaCommon's `CreatePlaceholderScope` so it uses `SpanContextPropagator.Instance.Extract` rather than extracting trace context elements one by one. ## Test coverage Added a unit test for 128 bit trace IDs. Fixed existing unit tests so they pass a dictionary of headers to CreatePlaceholderScope. Removed a unit test that only passes SamplingPriority, since a distributed trace with only a sampling priority is hardly a distributed trace at all. ## Other details Backport to 2.x of #6041 <!-- Fixes #{issue} --> <!--⚠️ Note: where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. --> --------- Co-authored-by: Lucas Pimentel <[email protected]> Co-authored-by: Andrew Lock <[email protected]> Co-authored-by: Daniel Romano <[email protected]> Co-authored-by: Steven Bouwkamp <[email protected]> Co-authored-by: Anna <[email protected]> Co-authored-by: NachoEchevarria <[email protected]> Co-authored-by: William Conti <[email protected]> Co-authored-by: Kevin Gosse <[email protected]> Co-authored-by: Tony Redondo <[email protected]> Co-authored-by: Gregory LEOCADIE <[email protected]>
Summary of changes
I've updated the Lambda extension so it is capable of returning a 128 bit trace ID when a tracer calls the
/lambda/start-invocation
endpoint in this PRAs per the RFC, the
This change modifies the function that calls
/lambda/start-invocation
, allowing it to pick out the upper 64 bits of the trace ID and set the resulting 128-bit trace ID in the extracted context.Reason for change
The Lambda Extension may now return a 128 bit trace ID when a Step Function invokes a Lambda Function.
Implementation details
I rewrote LambdaCommon's
CreatePlaceholderScope
so it usesSpanContextPropagator.Instance.Extract
rather than extracting trace context elements one by one.Test coverage
Added a unit test for 128 bit trace IDs. Fixed existing unit tests so they pass a dictionary of headers to CreatePlaceholderScope. Removed a unit test that only passes SamplingPriority, since a distributed trace with only a sampling priority is hardly a distributed trace at all.
Other details
Backported to 2.x in #6181