Feature: Add support for DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT#5844
Conversation
|
Thank you for updating Change log entry section 👏 Visited at: 2026-06-05 13:04:49 UTC |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 42d832d | Docs | Datadog PR Page | Give us feedback! |
Typing analysisNote: Ignored files are excluded from the next sections. Untyped methodsThis PR introduces 1 partially typed method, and clears 1 untyped method. Untyped methods (+0-1)✅ Cleared:Partially typed methods (+1-0)❌ Introduced:Untyped other declarationsThis PR introduces 16 untyped other declarations, and clears 16 untyped other declarations. It increases the percentage of typed other declarations from 82.62% to 82.63% (+0.01%). Untyped other declarations (+16-16)❌ Introduced:If you believe a method or an attribute is rightfully untyped or partially typed, you can add |
db2c892 to
f4655b6
Compare
BenchmarksBenchmark execution time: 2026-06-19 08:41:26 Comparing candidate commit 42d832d in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 47 metrics, 1 unstable metrics.
|
09af49d to
806c966
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77458c41aa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@MilanGarnier I have converted PR into Draft, please use draft pr's for unfinished work, thanks! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0f897e3f9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@MilanGarnier Please disclose – was this PR AI generated and if yes, you suppose to write about it in description and we will put a tag on it. |
f2126d3 to
c5eec1c
Compare
Per Strech's review on #5844 (which targets the same helper as #5867): the prior name implied a normalization the method does not perform. The method re-tags the input via String#force_encoding(UTF-8) and returns nil when the bytes are not a valid UTF-8 sequence. The new name reads off the underlying operation without overpromising success. Also collapses the body: the previous `if value.encoding == UTF_8` early-return branch merges into a single conditional re-encode followed by one `valid_encoding?` check at the end. Behavior unchanged: already-UTF-8 input is returned by object identity (no dup), input is never mutated, frozen input is handled via the dup in the non-UTF-8 branch — all covered by helpers_spec. Updates the helper, the RBS signature, both call sites (TraceContext#extract_tracestate, OTel SpanProcessor span-link path), and the helpers spec describe/subject.
bm1549
left a comment
There was a problem hiding this comment.
Reviewing on behalf of apm-sdk-capabilities-ruby - I have no expertise in the Ruby tracer, but am looking from the perspective of feature parity
First off, nice work for a first PR here!
When reviewed this against .NET and Java, the core HTTP propagation path matches: config, the three modes, span-link attrs (reason / context_headers), per-mode baggage, and dropping _dd.p.* on restart all line up. The system-tests (Test_ExtractBehavior_Restart and friends) hit /make_distant_call, so they only cover that HTTP path - they should all pass.
The OTel-API extraction path is where Ruby diverges, and the system tests don't cover it. Under restart, propagator.rb bails early when digest.trace_id is nil (before continue_trace!), so the span link to the upstream context gets dropped. .NET and Java attach it no matter which API starts the trace
It's worth adding a system test in DataDog/system-tests#7076 that runs restart through the OTel extraction API and asserts the same span link (reason / context_headers) the HTTP cases check, so the gap gets caught across every tracer
…langarnier-feature_DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
@bm1549 This was indeed something I missed and it wasn't covered by the tests. I have added a new system-test in DataDog/system-tests#7076 (passing on dotnet and Java), which only passes with this change. |
|
Hey! I just saw this new feature and I'm really excited about it! Thanks for the work on it @MilanGarnier What we're interested on is changing the context propagation behaviour only in traces from a particular integration (WaterDrop / Karafka distributed tracing). Would that be possible? |
|
Hey, thanks for the kind words and for raising this!
That's a good feature request. Right now the setting applies globally, so scoping it to a specific integration isn't supported yet. Technically it's not far off, the question is what it should look like. |
What does this PR do?
Implements
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACTfor dd-trace-rb.Three modes:
continue(default): existing behavior -- incoming trace context is used as the local trace context. Baggage is propagated.restart: starts a new trace with a fresh trace ID and sampling decision. The incoming context is referenced via a span link withreason=propagation_behavior_extract. Baggage is propagated.ignore: discards the entire incoming trace context. Returns nil, nil from Extract() so callers produce a fresh root span with no parent, no span links, and no baggage.Motivation:
RFC on Trace Context Propagation Extraction Modes
System-tests PR: DataDog/system-tests#6757
Change log entry
Yes. Tracing: Adds support for the
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACTconfiguration key. The default value iscontinue(preserving previous behavior), but the newrestart/ignorevalues allow new traces to be started, either keeping or discarding baggage and trace context.Additional Notes:
If there needs to be more testing implemented let me know, this is my first PR here so I am still unsure about the amount of testing that needs to be done
How to test the change?
ignoreandrestart