fix(sampling): format _dd.p.ksr to 6 decimal places, not 6 significant digits#2086
Conversation
…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>
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis 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 Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: cf7a1e2 | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
# 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>
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").