Skip to content

feat: trace context propagation behavior#4635

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 58 commits into
mainfrom
augusto/trace-context-propagation-extraction-modes
May 28, 2026
Merged

feat: trace context propagation behavior#4635
gh-worker-dd-mergequeue-cf854d[bot] merged 58 commits into
mainfrom
augusto/trace-context-propagation-extraction-modes

Conversation

@igoragoli

@igoragoli igoragoli commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT for dd-trace-go.

See RFC.

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 with reason=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.

When DD_TRACE_PROPAGATION_EXTRACT_FIRST=true is combined with restart, baggage is explicitly extracted after the first propagator returns, since the RFC requires baggage to be propagated in restart mode regardless.

Motivation

See RFC: Trace Context Propagation Extraction Modes
System-tests PR: DataDog/system-tests#6757

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.

Note: Still working on it: DataDog/system-tests#6757

  • There is a benchmark for any new code, or changes to existing code.

Note: Benchmarking is explicitly out of scope per the RFC ("the processing overhead is minimal in comparison to the rest of the context extraction operation").

  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

@igoragoli
igoragoli force-pushed the augusto/trace-context-propagation-extraction-modes branch from 547e777 to b2227f3 Compare April 9, 2026 09:41
@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.57%. Comparing base (fb4f2a1) to head (3243ac6).

Files with missing lines Patch % Lines
ddtrace/tracer/textmap.go 91.30% 4 Missing and 2 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/spancontext.go 93.76% <100.00%> (ø)
ddtrace/tracer/telemetry.go 89.15% <100.00%> (ø)
ddtrace/tracer/textmap.go 84.57% <91.30%> (ø)

... and 452 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter

pr-commenter Bot commented Apr 9, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-05-27 12:58:09

Comparing candidate commit 3243ac6 in PR branch augusto/trace-context-propagation-extraction-modes with baseline commit fb4f2a1 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 297 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

Known flaky benchmarks without significant changes:

  • scenario:BenchmarkOTLPTraceWriterFlush

@igoragoli
igoragoli force-pushed the augusto/trace-context-propagation-extraction-modes branch from b2227f3 to e86bc01 Compare April 15, 2026 06:12
@datadog-official

datadog-official Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 91.43%
Overall Coverage: 61.86% (+3.74%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3243ac6 | Docs | Datadog PR Page | Give us feedback!

@spiliopoulos

Copy link
Copy Markdown

👋 from a DD customer at figma. Can we do anything to help this PR along?

@kakkoyun

Copy link
Copy Markdown
Member

👋 from a DD customer at figma. Can we do anything to help this PR along?

@spiliopoulos Thanks for chiming in. We will do our best to push this forward.

@igoragoli @genesor Do you need any help with this?

@genesor

genesor commented May 19, 2026

Copy link
Copy Markdown
Member

Heya @kakkoyun @spiliopoulos

This PR is a mentorship project with @igoragoli, we will work on having it merged by EOW.

Once merged it will either land in v2.9.0 (ongoing release) or have to wait for the next v2.10.0 release (june)

@darccio darccio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 74d3c06 into main May 28, 2026
191 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the augusto/trace-context-propagation-extraction-modes branch May 28, 2026 14:11
@spiliopoulos

Copy link
Copy Markdown

Thanks for the work @igoragoli and @genesor. We will wait to see what release picks it up and give it a spin. I do expect this will give us a lot of flexibility in decomposing our traces into more manageable chunks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done team:apm-go

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants