Skip to content

[Monitor] Preserve rate-limited sampler local child span decisions - #49569

Merged
Radhika Gupta (rads-1996) merged 6 commits into
Azure:mainfrom
huong8373tt-beep:fix/rate-limited-sampler-parent-spans
Oct 26, 2026
Merged

Radhika Gupta (rads-1996) merged 6 commits into
Azure:mainfrom
huong8373tt-beep:fix/rate-limited-sampler-parent-spans

Conversation

@huong8373tt-beep

Copy link
Copy Markdown
Contributor

Description

Fixes #49541.

Radhika Gupta (@rads-1996) I completed this draft before I noticed the issue had been assigned to you. If you are already implementing it or prefer a different approach, please feel free to close this PR; I am sharing the tested implementation and regression coverage in case it is useful.

RateLimitedSampler now resolves the implicit current context before evaluating a parent and follows the sampled trace flag of a valid local parent. A sampled local parent is no longer sent through the rate limiter again; its _MS.sampleRate is inherited when present, while a missing attribute is treated as the existing 100% sampling case. A non-sampled local parent drops its child based on trace_flags.sampled, rather than Span.is_recording().

The regression coverage verifies:

  • implicit TracerProvider parent/child creation consumes the rate limiter only once;
  • sampled local parents inherit their rate without consuming the limiter;
  • dropped local parents remain dropped even if a mock reports is_recording();
  • sampled parents without _MS.sampleRate keep children as the 100% case.

Validation

  • pytest tests/trace/test_rate_limited_sampling.py -q — 23 passed, 9 subtests passed
  • pytest tests/ -q — 1085 passed, 10 skipped, 195 subtests passed
  • git diff --check

Slai Agent Runtime assisted with investigation, implementation, and tests. The account owner reviewed and authorized this contribution.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG / release-note metadata is updated for this bug fix.
  • 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.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
7 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution Slai.life (@huong8373tt-beep)! We will review the pull request and get back to you soon.

@huong8373tt-beep
Slai.life (huong8373tt-beep) force-pushed the fix/rate-limited-sampler-parent-spans branch from 990578c to 3a95749 Compare October 15, 2026 21:29
@huong8373tt-beep
Slai.life (huong8373tt-beep) force-pushed the fix/rate-limited-sampler-parent-spans branch from 3a95749 to e4adc29 Compare October 15, 2026 21:31

@rads-1996 Radhika Gupta (rads-1996) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix covers both reported failure paths with regression tests and no identified blockers; tests were not independently rerun.

No open issues 🎉

What changed in this PR

Fixes #49541 by preserving local parent sampling decisions in Azure Monitor’s rate-limited sampler, preventing incomplete traces and unnecessary rate-limit consumption.

Changes:

  • Resolves implicit parents and inherits local parent sampling flags and rates.
  • Adds regression coverage and release-note metadata.
File Description
sdk/​monitor/​azure-monitor-opentelemetry-exporter/​tests/​trace/​test_rate_limited_sampling.py Tests parent inheritance and limiter usage.
sdk/​monitor/​azure-monitor-opentelemetry-exporter/​azure/​monitor/​opentelemetry/​exporter/​export/​trace/​_utils.py Preserves local parent decisions, including 100% sampling.
sdk/​monitor/​azure-monitor-opentelemetry-exporter/​azure/​monitor/​opentelemetry/​exporter/​export/​trace/​_rate_limited_sampling.py Checks implicit parent context before rate limiting.
.chronus/​changes/​azure-monitor-opentelemetry-exporter-rate-limited-child-sampling-2026-10-15.md Records the sampling fix.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 26, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation and regression coverage address both reported resampling paths, with no unresolved blocking findings.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 26, 2026 19:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix and regression coverage address both reported resampling paths, with no identified blocking issues.

No open issues 🎉

Review effort: Balanced

@rads-1996
Radhika Gupta (rads-1996) merged commit 1ea3d76 into Azure:main Oct 26, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RateLimitedSampler re-samples child spans of a kept parent, producing incomplete traces

4 participants