feat(tracing): add DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT#3997
feat(tracing): add DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT#3997MilanGarnier wants to merge 16 commits into
Conversation
|
Adds the new `DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT` config key (values: continue, restart, ignore) with a CUSTOM(INT) parser, the corresponding C enum, and the supported-configurations.json entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds three behaviors at the single extraction chokepoint (ddtrace_apply_distributed_tracing_result): - continue (default): inherit upstream trace context unchanged - restart: start a fresh trace; upstream captured as a span link with reason=propagation_behavior_extract. When the root span doesn't exist yet at request-init time, the link is queued in DDTRACE_G(pending_upstream_span_link) and attached in ddtrace_open_span. - ignore: drop all extracted context including baggage and sampling priority Also extracts ddtrace_build_span_link_from_result() from the SpanLink fromHeaders method so it can be reused by the restart path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the three behaviors (continue, restart, ignore) and config parsing (case-insensitive values, invalid value falls back to default). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6b7e259 to
3ca8428
Compare
Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19c7dafd9f
ℹ️ 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".
| zend_hash_clean(&result->meta_tags); | ||
| zend_hash_clean(&result->propagated_tags); |
There was a problem hiding this comment.
Drop upstream tracestate on restart
When DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT=restart receives headers that include x-datadog-origin or W3C tracestate, this path only clears trace id/parent/sampling and _dd.p.*; the code below still moves result->origin, result->tracestate, and tracestate_unknown_dd_keys onto the new root/global context, and outbound injection later re-emits them. In that scenario the restarted trace continues propagating upstream trace context instead of preserving only baggage plus the span link.
Useful? React with 👍 / 👎.
Summary
Implements
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT(APMAPI-1941, feature-parity #353) for the PHP tracer, matching behavior already present in .NET, Python, Node, Java, Ruby, and Rust.Three values:
continue(default): inherit upstream trace context unchanged — no behavior changerestart: start a fresh trace; the upstream context is captured as a span link withreason=propagation_behavior_extractignore: drop all extracted context including baggage and sampling priorityDesign:
ddtrace_apply_distributed_tracing_resultindistributed_tracing_headers.c, covering both request-init andconsume_distributed_tracing_headersuserland callsrestartpath: when the root span doesn't yet exist at request-init time, the span link is queued inDDTRACE_G(pending_upstream_span_link)and consumed inddtrace_open_spanwhen the root span is createdddtrace_build_span_link_from_result()fromSpanLink::fromHeadersfor reuseTest plan
tests/ext/distributed_tracing/propagation_behavior_extract_continue.phpt— verifies trace_id inherited, no span link, baggage preservedtests/ext/distributed_tracing/propagation_behavior_extract_restart.phpt— verifies fresh trace_id, span link with correct upstream ids and reason, baggage preserved,_dd.p.*not in link attributestests/ext/distributed_tracing/propagation_behavior_extract_ignore.phpt— verifies fresh trace_id, no span link, baggage dropped, sampling priority droppedtests/ext/distributed_tracing/propagation_behavior_extract_config.phpt— verifies case-insensitive parsing, invalid value falls back tocontinueRelated
🤖 Generated with Claude Code