[WIP] Sampling code extraction#147
Draft
bantonsson wants to merge 3 commits intoproject/sampling-extractionfrom
Draft
[WIP] Sampling code extraction#147bantonsson wants to merge 3 commits intoproject/sampling-extractionfrom
bantonsson wants to merge 3 commits intoproject/sampling-extractionfrom
Conversation
brettlangdon
reviewed
Feb 9, 2026
| pub struct TraceRootSamplingInfo { | ||
| mechanism: SamplingMechanism, | ||
| rate: f64, | ||
| rl_effective_rate: Option<i32>, |
Member
There was a problem hiding this comment.
Suggested change
| rl_effective_rate: Option<i32>, | |
| rl_effective_rate: Option<f32>, |
? don't we need the rate limiter rate to be a float between 0 and 1?
| | mechanism::LOCAL_USER_TRACE_SAMPLING_RULE | ||
| | mechanism::REMOTE_USER_TRACE_SAMPLING_RULE | ||
| | mechanism::REMOTE_DYNAMIC_TRACE_SAMPLING_RULE | ||
| | mechanism::APPSEC |
Member
There was a problem hiding this comment.
In Python we set appsec to AUTO_KEEP/AUTO_REJECT and not user, is USER_PAIR correct here for this?
Collaborator
There was a problem hiding this comment.
Good catch 👀
We ported the sampler from the python code, a bit before the change fro, user to auto was made in this commit DataDog/dd-trace-py#14043
05fa719 to
e72fef1
Compare
e72fef1 to
7dd3ba1
Compare
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 does this PR do?
This PR currently hides all the OTel specific things in the sampling code behind traits, so the sampling logic can be moved to a separate crate.
Motivation
Make the sampling code more generic and move it into a separate crate so it can be reused.
Additional Notes
The benchmarks are on par with the original code. Some improvements and a few minor regressions. There will be additional changes that move the code out.