Skip to content

test(cpp): enable otel tracestate sampling - #7522

Merged
MilanGarnier merged 2 commits into
mainfrom
milan.garnier/enable-cpp-otel-tracestate-sampling
Aug 26, 2026
Merged

test(cpp): enable otel tracestate sampling#7522
MilanGarnier merged 2 commits into
mainfrom
milan.garnier/enable-cpp-otel-tracestate-sampling

Conversation

@MilanGarnier

Copy link
Copy Markdown
Contributor

Enables C++ OpenTelemetry tracestate sampling coverage. Stacked on #7518.

@MilanGarnier
MilanGarnier requested a review from a team as a code owner August 14, 2026 13:17
@MilanGarnier
MilanGarnier requested review from xlamorlette-datadog and removed request for a team August 14, 2026 13:17
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

manifests/cpp.yml                                                       @DataDog/system-tests-reviewers

Comment thread manifests/cpp.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0378ec0860

ℹ️ 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".

Comment thread manifests/cpp.yml Outdated
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Tests

All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@MilanGarnier
MilanGarnier force-pushed the milan.garnier/enable-cpp-otel-tracestate-sampling branch from 8f5e665 to 7038c67 Compare August 14, 2026 14:22
@MilanGarnier
MilanGarnier force-pushed the milan.garnier/otel-tracestate-ot-th branch from b02e7fd to 90f5085 Compare August 18, 2026 08:26
@MilanGarnier
MilanGarnier requested review from a team as code owners August 18, 2026 08:26
@MilanGarnier
MilanGarnier requested review from ZStriker19, christophe-papazian, claponcet and dromanol and removed request for a team August 18, 2026 08:26
@MilanGarnier
MilanGarnier requested review from dougqh and mtoffl01 and removed request for a team August 18, 2026 08:26
@dougqh

dougqh commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🤖 Comment from Claude (via Claude Code), reviewing this PR at a user's request.

I think test_precision_boundary_decisions in tests/parametric/test_otel_tracestate_sampling.py has incorrect hardcoded expected values for both parametrized cases.

I reimplemented the sampling formula documented in tests/test_otel_tracestate_sampling.py's module docstring:

h = (trace_id * 1111111111111111111) mod 2**64
rv = (~h & (2**64-1)) >> 8
th = round((1 - rate) * 2**56)
sampled = rv >= th

and verified it reproduces the existing, already-verified SAMPLING_RATE_0_1 fixtures exactly (rv matches to the hex digit, and the sampled/dropped decision derived from rv >= th matches too, for trace IDs 1, 10, 100, 1000, 83).

Applying that same validated formula to the two new boundary vectors:

  • rate-0.1-kept (trace_id 0x03A93EE8B1999F00): I get rv = e6666666666666, sampled = False — but the test asserts rv = e6666666666668 (equal to th) and expected_sampled = True.
  • rate-0.05-dropped (trace_id 5401449561355763072): I get rv = f3333333333331, sampled = True — but the test asserts rv = f333333333332f and expected_sampled = False.

In both cases the rv value and the sampled/dropped direction come out flipped relative to what the test expects. This should fail against a tracer that implements the algorithm correctly (or could mask a bug in one that doesn't). Might be worth regenerating these two vectors — unlike the pre-existing SAMPLING_RATE_* tables, these weren't cross-checked against the verified sampling_rates.csv.

@MilanGarnier

Copy link
Copy Markdown
Contributor Author

Applying that same validated formula to the two new boundary vectors:

  • rate-0.1-kept (trace_id 0x03A93EE8B1999F00): I get rv = e6666666666666, sampled = False — but the test asserts rv = e6666666666668 (equal to th) and expected_sampled = True.
  • rate-0.05-dropped (trace_id 5401449561355763072): I get rv = f3333333333331, sampled = True — but the test asserts rv = f333333333332f and expected_sampled = False.

In both cases the rv value and the sampled/dropped direction come out flipped relative to what the test expects. This should fail against a tracer that implements the algorithm correctly (or could mask a bug in one that doesn't). Might be worth regenerating these two vectors — unlike the pre-existing SAMPLING_RATE_* tables, these weren't cross-checked against the verified sampling_rates.csv.

@dougqh This is intentional. In these edge cases the imprecision comes initially from computing th, so rv is set to a value explicitly agreeing the sampling decision made internally using dd sampling.

@MilanGarnier
MilanGarnier force-pushed the milan.garnier/enable-cpp-otel-tracestate-sampling branch from 7038c67 to cb69bdf Compare August 19, 2026 11:44
@MilanGarnier
MilanGarnier force-pushed the milan.garnier/enable-cpp-otel-tracestate-sampling branch 2 times, most recently from 9066827 to ca247bc Compare August 19, 2026 13:02
Base automatically changed from milan.garnier/otel-tracestate-ot-th to main August 19, 2026 18:45
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot requested a review from a team as a code owner August 19, 2026 18:45
test(cpp): enable otel tracestate sampling

test(cpp): require tracestate sampling after 2.2.0

test(cpp): disable otlp tracestate sampling
@MilanGarnier
MilanGarnier force-pushed the milan.garnier/enable-cpp-otel-tracestate-sampling branch from ca247bc to 87118b9 Compare August 26, 2026 11:56
@MilanGarnier
MilanGarnier requested a review from a team as a code owner August 26, 2026 11:56
@MilanGarnier MilanGarnier changed the title test(cpp): enable otel tracestate sampling [cpp@milan.garnier/otel-tracestate-ot-th] test(cpp): enable otel tracestate sampling Aug 26, 2026
@MilanGarnier
MilanGarnier enabled auto-merge (squash) August 26, 2026 12:01
@MilanGarnier
MilanGarnier disabled auto-merge August 26, 2026 12:04
@MilanGarnier
MilanGarnier enabled auto-merge (squash) August 26, 2026 12:07
@MilanGarnier
MilanGarnier merged commit fc026d3 into main Aug 26, 2026
24 checks passed
@MilanGarnier
MilanGarnier deleted the milan.garnier/enable-cpp-otel-tracestate-sampling branch August 26, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants