Skip to content

fix(sdk-trace): sample ratio 1 upper-bound trace IDs - #6890

Merged
pichlermarc merged 2 commits into
open-telemetry:mainfrom
LarryHu0217:codex/fix-ratio-sampler-6879
Jul 8, 2026
Merged

fix(sdk-trace): sample ratio 1 upper-bound trace IDs#6890
pichlermarc merged 2 commits into
open-telemetry:mainfrom
LarryHu0217:codex/fix-ratio-sampler-6879

Conversation

@LarryHu0217

@LarryHu0217 LarryHu0217 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix TraceIdRatioBasedSampler(1) so trace IDs whose accumulated value is 0xffffffff are sampled.
  • Keep the existing strict < comparison by using an exclusive upper bound of 0x100000000 when the normalized ratio is 1.
  • Add a regression assertion for the ffffffff boundary trace ID.

Fixes #6879.

Testing

  • npm run compile --workspace @opentelemetry/sdk-trace
  • npm run test --workspace @opentelemetry/sdk-trace -- --grep TraceIdRatioBasedSampler
  • npm run lint --workspace @opentelemetry/sdk-trace (passes with existing no-console warnings in benchmark files)

@LarryHu0217
LarryHu0217 requested a review from a team as a code owner July 7, 2026 20:52
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 7, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: LarryHu0217 / name: Liang Hu (499fcc5)

@LarryHu0217

Copy link
Copy Markdown
Contributor Author

I have signed that CLA

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.08%. Comparing base (0fd7fac) to head (8cc5862).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6890   +/-   ##
=======================================
  Coverage   95.08%   95.08%           
=======================================
  Files         394      394           
  Lines       13992    13993    +1     
  Branches     3223     3224    +1     
=======================================
+ Hits        13304    13305    +1     
  Misses        688      688           
Files with missing lines Coverage Δ
.../sdk-trace/src/sampler/TraceIdRatioBasedSampler.ts 100.00% <100.00%> (ø)
🚀 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.

@pichlermarc pichlermarc 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.

thanks!

@pichlermarc
pichlermarc added this pull request to the merge queue Jul 8, 2026
Merged via the queue into open-telemetry:main with commit 3394c3e Jul 8, 2026
29 checks passed
@otelbot

otelbot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @LarryHu0217! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

@otelbot-js otelbot-js Bot mentioned this pull request Jul 21, 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.

TraceIdRatioBasedSampler drops traces at ratio 1.0 (off-by-one on the upper bound)

2 participants