Skip to content

fix(tracing): preserve valid W3C tracestate elements - #19840

Draft
mabdinur wants to merge 3 commits into
mainfrom
codex/fix-w3c-tracestate-leniency
Draft

mabdinur wants to merge 3 commits into
mainfrom
codex/fix-w3c-tracestate-leniency

Conversation

@mabdinur

@mabdinur mabdinur commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Parse semicolon-delimited Datadog W3C tracestate elements independently so empty or malformed elements no longer discard valid sampling priority and origin data.

Fixes APMAPI-2294. This addresses the Python failures documented in DataDog/system-tests#7569.

Testing

Risks

Low. The change only makes malformed sub-element handling more lenient; known valid fields retain their existing parsing and validation.

Additional Notes

The regression test covers every malformed or empty dd element variant added by the system-tests PR.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

.github/workflows/system-tests.yml                                      @DataDog/python-guild @DataDog/apm-core-python
ddtrace/propagation/http.py                                             @DataDog/apm-sdk-capabilities-python
releasenotes/notes/fix-w3c-tracestate-parsing-90f37b6cdb0492b0.yaml     @DataDog/apm-python
tests/tracer/test_propagation.py                                        @DataDog/apm-sdk-capabilities-python @DataDog/asm-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 1 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 207 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 207 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=133)
ddtrace.llmobs._integrations.bedrock -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)
ddtrace.llmobs._integrations.vertexai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)
ddtrace.internal.ci_visibility.recorder -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=131)
ddtrace.llmobs._integrations.langchain -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-official

datadog-official Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build macos amd64: [3.9 3.10 3.11] — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

Team freeze guard | Team freeze guard

View more details · View in GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e3115b2 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Aug 24, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-24 19:16:47

Comparing candidate commit 2ce944c in PR branch codex/fix-w3c-tracestate-leniency with baseline commit f26fe3f in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 9 performance regressions! Performance is the same for 577 metrics, 10 unstable metrics, 2 known flaky benchmarks, 16 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 ----------------------------------'

scenario:httppropagationextract-wsgi_valid_headers_all

  • 🟥 execution_time [+406.024ns; +456.852ns] or [+7.533%; +8.476%]

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.104µs; +2.265µs] or [+11.214%; +12.068%]

scenario:iastaspects-add_aspect

  • 🟥 execution_time [+13.740µs; +17.633µs] or [+13.450%; +17.261%]

scenario:iastaspects-join_aspect

  • 🟥 execution_time [+49.339µs; +53.689µs] or [+23.524%; +25.597%]

scenario:iastaspects-title_aspect

  • 🟥 execution_time [+59.960µs; +66.637µs] or [+22.350%; +24.839%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+130.984µs; +138.043µs] or [+31.004%; +32.675%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+18.865µs; +22.177µs] or [+13.057%; +15.350%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+404.530ns; +482.217ns] or [+14.805%; +17.648%]

scenario:tracer-small

  • 🟥 execution_time [+30.791µs; +32.895µs] or [+9.518%; +10.169%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-729.091ns; +756.094ns] or [-6.617%; +6.862%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-36.763ns; +29.463ns] or [-5.981%; +4.794%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1823.387ns; +1533.831ns] or [-10.553%; +8.877%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1297.604ns; +1201.391ns] or [-9.948%; +9.210%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-337.261ns; +317.696ns] or [-9.164%; +8.633%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-259.125ns; +248.603ns] or [-8.885%; +8.524%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-65.918ns; +78.966ns] or [-5.849%; +7.006%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3925.298ns; +3875.610ns] or [-9.771%; +9.647%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-828.443ns; +704.082ns] or [-10.272%; +8.730%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-59635.626ns; +58402.349ns] or [-9.546%; +9.348%]

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.

scenario:iastaspects-ljust_noaspect

  • 🟥 execution_time [+50.101µs; +54.604µs] or [+16.913%; +18.433%]

scenario:span-start

  • 🟥 execution_time [+1.641ms; +1.800ms] or [+10.970%; +12.031%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-casefold_noaspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_aspect
  • scenario:iastaspects-translate_noaspect
  • scenario:iastaspects-upper_noaspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

@github-actions github-actions Bot added the stale label Sep 24, 2026
@github-actions github-actions Bot removed the stale label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant