Skip to content

Move sampler argument logic to respective samplers#45849

Draft
rads-1996 wants to merge 18 commits intoAzure:mainfrom
rads-1996:modify_sampler_logic
Draft

Move sampler argument logic to respective samplers#45849
rads-1996 wants to merge 18 commits intoAzure:mainfrom
rads-1996:modify_sampler_logic

Conversation

@rads-1996
Copy link
Member

@rads-1996 rads-1996 commented Mar 23, 2026

Description

Fixes - #32499

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.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions bot added Monitor - Distro Monitor OpenTelemetry Distro Monitor - Exporter Monitor OpenTelemetry Exporter labels Mar 23, 2026
@rads-1996 rads-1996 force-pushed the modify_sampler_logic branch 5 times, most recently from e94131a to 22ad132 Compare March 24, 2026 20:17
@rads-1996 rads-1996 marked this pull request as ready for review March 24, 2026 21:52
Copilot AI review requested due to automatic review settings March 24, 2026 21:52
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 moves OTEL_TRACES_SAMPLER_ARG parsing/defaulting logic into the sampler implementations themselves (ApplicationInsightsSampler and RateLimitedSampler), aligning behavior with the referenced issue and reducing reliance on higher-level configuration layers.

Changes:

  • Updated ApplicationInsightsSampler to optionally read OTEL_TRACES_SAMPLER_ARG when no explicit ratio is provided, and to default (log) on invalid inputs rather than raising.
  • Updated RateLimitedSampler to optionally read OTEL_TRACES_SAMPLER_ARG when no explicit traces-per-second value is provided, and to default (log) on invalid inputs rather than raising.
  • Expanded unit tests to cover env-var and invalid-input behaviors for both samplers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_sampling.py Updates tests for ApplicationInsightsSampler’s new env-var/defaulting behavior.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_rate_limited_sampling.py Adds tests for RateLimitedSampler’s new env-var/defaulting behavior and invalid inputs.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_sampling.py Implements env-var parsing and defaulting within ApplicationInsightsSampler.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_rate_limited_sampling.py Implements env-var parsing and defaulting within RateLimitedSampler.

@rads-1996 rads-1996 marked this pull request as draft March 24, 2026 22:07
@rads-1996 rads-1996 force-pushed the modify_sampler_logic branch from 22ad132 to 3cd96ee Compare March 24, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Distro Monitor OpenTelemetry Distro Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants