Fix attributes override in Rate Limited Sampler#45592
Merged
rads-1996 merged 4 commits intoAzure:mainfrom Mar 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes RateLimitedSampler.should_sample() so it preserves existing span attributes instead of overwriting them when the computed sampling percentage is 100%, and adds regression tests to cover the expected attribute behavior.
Changes:
- Preserve incoming
attributesby always copying them intonew_attributes, and only add_MS.sampleRatewhen sampling percentage is not 100%. - Add tests verifying
_MS.sampleRateis not added at 100% and that original attributes are not mutated. - Update the package changelog with a bug-fix entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_rate_limited_sampling.py | Fixes attribute handling so 100% sampling doesn’t wipe user-provided attributes. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_rate_limited_sampling.py | Adds regression tests for 100% vs non-100% sampling attribute behavior. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md | Records the bug fix in the changelog (but currently placed under a released version). |
You can also share your feedback on Copilot code review. Take the survey.
cc9a55d to
87170a7
Compare
87170a7 to
a23cec4
Compare
hectorhdzg
approved these changes
Mar 10, 2026
aprilk-ms
pushed a commit
that referenced
this pull request
Mar 11, 2026
* Fix attributes override in Rate Limited Sampler * Update CHANGELOG * Update CHANGELOG and fix format * Retrigger CI/CD pipeline
singankit
pushed a commit
that referenced
this pull request
Mar 16, 2026
* Fix attributes override in Rate Limited Sampler * Update CHANGELOG * Update CHANGELOG and fix format * Retrigger CI/CD pipeline
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.
Description
Fixes an issue where the attributes were being overwritten in the rate limited sampler.
All SDK Contribution checklist:
General Guidelines and Best Practices