Skip to content

feat: add _dd.p.ksr propagated tag for Knuth sampling rate#180

Draft
bm1549 wants to merge 3 commits intomainfrom
brian.marks/add-ksr-tag
Draft

feat: add _dd.p.ksr propagated tag for Knuth sampling rate#180
bm1549 wants to merge 3 commits intomainfrom
brian.marks/add-ksr-tag

Conversation

@bm1549
Copy link

@bm1549 bm1549 commented Mar 11, 2026

What does this PR do?

Adds _dd.p.ksr (Knuth Sampling Rate) as a propagated tag set when agent-based or rule-based sampling decisions are made. The tag is stored in span meta (string type) with up to 6 significant digits and no trailing zeros.

Motivation

To enable consistent sampling across tracers and backend retention filters, the backend needs to know the sampling rate applied by the tracer. Without transmitting the tracer's rate via _dd.p.ksr, backend resampling cannot correctly compute effective rates in multi-stage sampling scenarios.

See RFC: "Transmit Knuth sampling rate to backend"

Additional Notes

Key files changed:

  • datadog-opentelemetry/src/core/constants.rs — Added SAMPLING_KNUTH_RATE_TAG_KEY constant
  • datadog-opentelemetry/src/sampling/datadog_sampler.rs — Added format_sampling_rate() helper and set ksr in agent/rule sampling paths
  • Updated 2 snapshot JSON files

Related PRs across tracers:

🤖 Generated with Claude Code

bm1549 and others added 2 commits March 10, 2026 21:44
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expand assert! macro call to multi-line format required by rustfmt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.

1 participant