fix(sampling): record rate limiter's effective rate on allow, not just drop - #2288
Open
MilanGarnier wants to merge 1 commit into
Open
fix(sampling): record rate limiter's effective rate on allow, not just drop#2288MilanGarnier wants to merge 1 commit into
MilanGarnier wants to merge 1 commit into
Conversation
Contributor
📚 Documentation Check Results📦
|
Contributor
🔒 Cargo Deny Results📦
|
MilanGarnier
changed the base branch from
milan.garnier/otel-consistent-sampling
to
main
July 28, 2026 16:30
BenchmarksComparisonCandidateCandidate benchmark detailsBaselineBaseline benchmark details |
MilanGarnier
changed the base branch from
main
to
milan.garnier/otel-consistent-sampling
July 28, 2026 16:32
…t drop dd-trace-rb and dd-trace-go both stamp the rate limiter's effective rate unconditionally once the limiter is consulted, regardless of allow/drop. libdatadog only recorded it on drop, diverging from other tracers.
MilanGarnier
force-pushed
the
milan.garnier/otel-rate-limiter-effective-rate
branch
from
July 28, 2026 16:34
286da37 to
c01edb8
Compare
MilanGarnier
changed the base branch from
milan.garnier/otel-consistent-sampling
to
main
July 28, 2026 16:34
|
VianneyRuhlmann
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
DatadogSampler::sample_rootonly recordedrl_effective_rate(the ratelimiter's effective accept rate, wired as
_dd.limit_psr) when the ratelimiter dropped a trace. It should be recorded whenever the limiter is
consulted, regardless of outcome.
Why this doesn't follow other tracers
rule_sampler.rb,apply_rule!): callsrate_limiter.allow?.tap { |allowed| ... set_limiter_metrics(trace, rate_limiter.effective_rate) ... }— the effective rate is set inside the.tapblock unconditionally, for bothallowed == trueandfalse.span.go): callslimiter.AllowOne(now)and then alwayscalls
setMetricLocked(keyRulesSamplerLimiterRate, limiterRate)rightafter, independent of the allow/drop outcome.
libdatadog:
_dd.limit_psrwas only emitted onrate-limiter-drop, silently omitting it on allow. This matters for the
Datadog Agent's stats extrapolation (
1/psr), which needs the tag wheneverthe limiter was in play, not just when it rejected the trace.
Change
sample_root: once a rule matches and keeps the trace, always callself.rate_limiter.effective_rate()afteris_allowed(), whether or notthe limiter allowed it.
Tests
cargo test -p libdd-sampling: 104 lib + 2 doctests pass. fmt and clippyclean.