Skip to content

fix(sampling): format _dd.p.ksr to 6 decimal places, not 6 significant digits#2086

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
igor/sampling/fix-format
Jun 5, 2026
Merged

fix(sampling): format _dd.p.ksr to 6 decimal places, not 6 significant digits#2086
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
igor/sampling/fix-format

Conversation

@iunanua

@iunanua iunanua commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

The cross-tracer spec for _dd.p.ksr is "up to 6 decimal digits of precision, with trailing zeros stripped" — i.e. Go's strconv.FormatFloat(rate, 'f', 6, 64). The previous implementation rounded to 6 significant digits ('g', 6, 64), which gave the right answer for every value in the original unit test but diverged for very small rates: 0.0000001 produced "0.0000001" instead of "0", and 0.00000051 produced "0.00000051" instead of "0.000001".

System-tests PR DataDog/system-tests#6466 added explicit cases for those two inputs (below_precision_rounds_to_zero, rounds_up_to_one_millionth), which started failing for dd-trace-rs once it bumped to a libdatadog containing this code (PR DataDog/dd-trace-rs#180, now living here after the sampling move-out refactor).

Replace the bespoke significant-digit rounding with a plain {rate:.6} format followed by trailing-zero strip; this gives the right rounding for free (including the "0" case, since "0.000000" trims down to "0").

…t digits

The cross-tracer spec for _dd.p.ksr is "up to 6 decimal digits of precision,
with trailing zeros stripped" — i.e. Go's strconv.FormatFloat(rate, 'f', 6, 64).
The previous implementation rounded to 6 *significant* digits ('g', 6, 64),
which gave the right answer for every value in the original unit test but
diverged for very small rates: 0.0000001 produced "0.0000001" instead of "0",
and 0.00000051 produced "0.00000051" instead of "0.000001".

System-tests PR DataDog/system-tests#6466 added explicit cases for those two
inputs (below_precision_rounds_to_zero, rounds_up_to_one_millionth), which
started failing for dd-trace-rs once it bumped to a libdatadog containing
this code (PR DataDog/dd-trace-rs#180, now living here after the sampling
move-out refactor).

Replace the bespoke significant-digit rounding with a plain `{rate:.6}` format
followed by trailing-zero strip; this gives the right rounding for free
(including the "0" case, since "0.000000" trims down to "0").

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/igor/sampling/fix-format

Summary by Rule

Rule Base Branch PR Branch Change

Annotation Counts by File

File Base Branch PR Branch Change

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 21 21 No change (0%)
datadog-live-debugger 6 6 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-remote-config 4 4 No change (0%)
datadog-sidecar 58 58 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 5 5 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 13 13 No change (0%)
Total 198 198 No change (0%)

About This Report

This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.47%. Comparing base (a76412c) to head (cf7a1e2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2086      +/-   ##
==========================================
- Coverage   73.47%   73.47%   -0.01%     
==========================================
  Files         475      475              
  Lines       78999    78992       -7     
==========================================
- Hits        58048    58042       -6     
+ Misses      20951    20950       -1     
Components Coverage Δ
libdd-crashtracker 65.32% <ø> (-0.02%) ⬇️
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-agent-client 83.79% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.07% <ø> (-0.02%) ⬇️
libdd-data-pipeline-ffi 73.02% <ø> (ø)
libdd-common 79.93% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (ø)
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.36% <ø> (ø)
libdd-profiling 81.69% <ø> (-0.03%) ⬇️
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.48% <100.00%> (+0.06%) ⬆️
datadog-sidecar 36.14% <ø> (-0.02%) ⬇️
datdog-sidecar-ffi 10.31% <ø> (ø)
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.80% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.30% <ø> (ø)
libdd-tracer-flare 86.57% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 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.

@datadog-official

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 73.48% (-0.00%)

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

@iunanua iunanua marked this pull request as ready for review June 5, 2026 12:10
@iunanua iunanua requested a review from a team as a code owner June 5, 2026 12:10
@dd-octo-sts

dd-octo-sts Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.70 MB 7.70 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 83.49 MB 83.49 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.34 MB 10.34 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 94.58 MB 94.58 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 24.73 MB 24.73 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 86.89 KB 86.89 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 179.90 MB 179.90 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 923.19 MB 923.19 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.09 MB 8.09 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 86.89 KB 86.89 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.91 MB 23.91 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 47.72 MB 47.72 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.43 MB 21.43 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 88.26 KB 88.26 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 183.88 MB 183.86 MB --.01% (-24.00 KB) 💪
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 915.95 MB 915.95 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.25 MB 6.25 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 88.26 KB 88.26 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.62 MB 25.62 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 45.35 MB 45.35 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 74.45 MB 74.45 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.58 MB 8.58 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 89.86 MB 89.86 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.43 MB 10.43 MB 0% (0 B) 👌

@iunanua

iunanua commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 5, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-05 12:14:44 UTC ℹ️ Start processing command /merge


2026-06-05 12:14:49 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 48m (p90).


2026-06-05 13:00:51 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 37891f1 into main Jun 5, 2026
89 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the igor/sampling/fix-format branch June 5, 2026 13:00
iunanua added a commit that referenced this pull request Jun 5, 2026
# Release proposal for libdd-sampling and its dependencies

This PR contains version bumps based on public API changes and commits
since last release.

## libdd-trace-utils
**Next version:** `7.0.0`
**Semver bump:** `major`
**Tag:** `libdd-trace-utils-v7.0.0`

### Commits

- feat(trace-utils)!: add dedup convenience to VecMap (#2049)
- fix(trace-utils): match the Go trace agent when parsing
`datadog-client-computed-*` bool headers (#2071)
- revert!: add from_string to span text (#2011) (#2073)
- fix(send_with_retry): follow max retries of the strategy (#2047)

## libdd-sampling (manually bumped due to breaking in #2073)
**Next version:** ~~`2.1.1`~~ `3.0.0`
**Semver bump:** ~~`patch`~~ `major`
**Tag:** ~~`libdd-sampling-v2.1.1`~~ `libdd-sampling-v3.0.0`

### Commits

- fix(sampling): format _dd.p.ksr to 6 decimal places, not 6 significant
digits (#2086)
- revert!: add from_string to span text (#2011) (#2073)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: iunanua <18325288+iunanua@users.noreply.github.com>
Co-authored-by: iunanua <igor.unanua@datadoghq.com>
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.

3 participants