Skip to content

Fix attributes override in Rate Limited Sampler#45592

Merged
rads-1996 merged 4 commits intoAzure:mainfrom
rads-1996:fix-attrib-issue-in-rls
Mar 10, 2026
Merged

Fix attributes override in Rate Limited Sampler#45592
rads-1996 merged 4 commits intoAzure:mainfrom
rads-1996:fix-attrib-issue-in-rls

Conversation

@rads-1996
Copy link
Member

Description

Fixes an issue where the attributes were being overwritten in the rate limited sampler.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Copilot AI review requested due to automatic review settings March 9, 2026 22:05
@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Mar 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 attributes by always copying them into new_attributes, and only add _MS.sampleRate when sampling percentage is not 100%.
  • Add tests verifying _MS.sampleRate is 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.

@rads-1996 rads-1996 force-pushed the fix-attrib-issue-in-rls branch from cc9a55d to 87170a7 Compare March 9, 2026 22:14
@rads-1996 rads-1996 force-pushed the fix-attrib-issue-in-rls branch from 87170a7 to a23cec4 Compare March 9, 2026 23:09
@rads-1996 rads-1996 merged commit 8b30817 into Azure:main Mar 10, 2026
20 checks passed
@rads-1996 rads-1996 deleted the fix-attrib-issue-in-rls branch March 10, 2026 15:15
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants