-
Notifications
You must be signed in to change notification settings - Fork 440
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
Adding Span Link support for compound header tag extractions with conflicting trace IDs #2948
Conversation
BenchmarksBenchmark execution time: 2024-12-09 12:43:26 Comparing candidate commit 08f578a in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 57 metrics, 0 unstable metrics. scenario:BenchmarkSetTagMetric-24
scenario:BenchmarkSetTagStringer-24
|
3a74a18
to
b6e05e6
Compare
0aec80a
to
4f7ef39
Compare
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.
Requesting various changes, lmk if anything unclear!
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.
Requesting various changes, lmk if anything unclear!
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.
Mostly nits...
Just be sure all the existing extract tests pass, like in textmap_test.go etc.
18a3541
to
54ad062
Compare
54ad062
to
ec2d4f1
Compare
ddtrace/tracer/textmap.go
Outdated
} | ||
} else { // Trace IDs do not match - create span links | ||
link := ddtrace.SpanLink{TraceID: extractedCtx2.TraceID(), SpanID: extractedCtx2.SpanID(), TraceIDHigh: extractedCtx2.TraceIDUpper(), Attributes: map[string]string{"reason": "terminated_context", "context_headers": "tracecontext"}} |
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.
@mtoffl01 FYI the context_headers
field is supposed to hold whichever propagator type was used to extract the violating context. For instance, if the propagator type was Datadog
and we have violating trace IDs, we want context_headers
to have the value of datadog
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.
@mhlidd , make sure you update the expected "context_headers" in TestSpanLinks::Links_on_divergent_trace_IDs test!
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.
A few small comments!
ddtrace/tracer/textmap.go
Outdated
extractedCtx2, ok1 := extractedCtx.(*spanContext) | ||
ctx2, ok2 := ctx.(*spanContext) | ||
// If we can't cast to SpanContextW3C, we can't propgate tracestate or create span links |
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.
What is the reason for casting to spanContext
struct? We had conversation in the past to use SpanContextW3C
instead of spanContext
so I'm wondering what the motivation to change it back is.
PS: Should update the comment below if the decision is to cast to spanContext
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.
To my memory, I think the cast to SpanContextW3C was never even used except to further cast to spanContext.
(Like for example, pW3C.propagateTracestate requires spanContext type)
I do remember that casting directly to spanContext made this code a lot easier to read.
Co-authored-by: mhlidd <matthew.li@datadoghq.com>
Co-authored-by: mhlidd <matthew.li@datadoghq.com>
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 can't approve my own PR but LGTM! The flow is a lot clearer, thanks for helping out!
Datadog ReportBranch report: ✅ 0 Failed, 5100 Passed, 67 Skipped, 2m 54.86s Total Time |
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
What does this PR do?
Adds support for span links when trace propagators extract headers with conflicting trace IDs.
(*chainedPropagator).Extract
function now appends spanLinks to the returned SpanContexttracer.WithSpanLinks
as a StartSpanOption.Motivation
Make distrubuted tracing with span links consistent across Datadog libraries according the following RFC.
APMAPI-762
Reviewer's Checklist
Unsure? Have a question? Request a review!