Skip to content

Fix W3C tracestate parsing - #360

Draft
bm1549 wants to merge 2 commits into
mainfrom
dd/apms-20291-fix-w3c-tracestate-cpp-202608251606
Draft

Fix W3C tracestate parsing#360
bm1549 wants to merge 2 commits into
mainfrom
dd/apms-20291-fix-w3c-tracestate-cpp-202608251606

Conversation

@bm1549

@bm1549 bm1549 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Reject the full dd member when a semicolon-delimited submember contains optional whitespace. Empty separator-generated submembers remain valid.
  • Canonicalize preserved tracestate siblings when dd is present, including empty-member removal and whitespace trimming.
  • Preserve the position of ot state during extraction and reinjection.
  • Add extraction and inject-after-extract coverage for these cases.

Motivation

Malformed dd submembers could be partially parsed, and sibling tracestate values could be reinjected with invalid padding. This makes dd parsing all-or-nothing without changing valid empty-separator behavior.

Additional Notes

Validation:

  • git diff --check
  • clang-format 14.0.6 dry run
  • C++17 syntax-only compilation of src/datadog/w3c_propagation.cpp
  • Dependency-free extraction and reinjection harness covering empty separators, whitespace-only and padded submembers, outer-member canonicalization, no-dd behavior, and ot state ordering

The full CMake test build could not complete because a public dependency download stalled.

Jira ticket: APMS-20291

Co-authored-by: bm1549 <12128670+bm1549@users.noreply.github.com>
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 25, 2026

Copy link
Copy Markdown

View session in Datadog

Bits Code status: ✅ Done

CI Auto-fix: Disabled | Enable

Comment @DataDog to request changes

@bm1549
bm1549 requested review from a team as code owners August 25, 2026 16:08
@bm1549 bm1549 added the Bits AI label Aug 25, 2026
@datadog-datadog-us1-prod

Copy link
Copy Markdown

I can only run on private repositories.

@bm1549
bm1549 marked this pull request as draft August 25, 2026 16:10
@datadog-datadog-prod-us1

This comment has been minimized.

@pr-commenter

pr-commenter Bot commented Aug 25, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-28 12:11:20

Comparing candidate commit 6a84a5e in PR branch dd/apms-20291-fix-w3c-tracestate-cpp-202608251606 with baseline commit b258927 in branch main.

Found 2 performance improvements and 1 performance regressions! Performance is the same for 5 metrics, 0 unstable metrics.

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:BM_HexPadded_uint64/NoPadding

  • 🟩 execution_time [-1.751ns; -1.674ns] or [-3.160%; -3.022%]

scenario:BM_Hex_uint64

  • 🟥 execution_time [+0.981ns; +1.010ns] or [+4.339%; +4.467%]

scenario:BM_TraceTinyCCSource

  • 🟩 execution_time [-3.799ms; -3.555ms] or [-4.872%; -4.559%]

@MilanGarnier

Copy link
Copy Markdown
Contributor

@bm1549 I merged yesterday a PR which slightly changed the way the tracestate was being parsed and generated, it might be cleaner (and easier) to regenerate a fix from the newer branch.

@bm1549 bm1549 added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Aug 28, 2026
@bm1549 bm1549 changed the title APMS-20291 Fix W3C tracestate parsing Fix W3C tracestate parsing Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos Bits AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants