Skip to content

Conversation

@rads-1996
Copy link
Member

@rads-1996 rads-1996 commented Dec 31, 2025

Description

Add support for OTEL_TRACES_SAMPLER. Follows the sampler types specified in upstream opentelemetry - https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler in addition to the Application Insights Sampler and 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 December 31, 2025 23:32
@github-actions github-actions bot added the Monitor - Distro Monitor OpenTelemetry Distro label Dec 31, 2025
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 adds support for the OTEL_TRACES_SAMPLER environment variable, implementing standard OpenTelemetry sampler types (always_on, always_off, trace_id_ratio, and their parent-based variants) in addition to the existing Application Insights and Rate Limited samplers.

Key Changes:

  • Added six new standard OpenTelemetry sampler types that can be configured via environment variables
  • Implemented validation and error handling for sampler configuration parameters
  • Added comprehensive test coverage for all new sampler types

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_constants.py Defines new sampler type constants and tuple of supported samplers
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py Implements sampler configuration logic with validation and adds helper function to instantiate sampler objects
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py Integrates new sampler selection logic into tracing setup
sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py Adds comprehensive test cases for all new sampler types and validation scenarios
sdk/monitor/azure-monitor-opentelemetry/README.md Updates documentation to include new sampler options

@rads-1996 rads-1996 force-pushed the support_otel_traces_sampler branch from 2bdcb54 to e63d0e1 Compare January 7, 2026 21:28
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-monitor-opentelemetry

@rads-1996 rads-1996 force-pushed the support_otel_traces_sampler branch from 7769e93 to 43243ca Compare January 7, 2026 23:07
sampler_type = configurations[SAMPLER_TYPE]
sampler = _get_sampler_from_name(sampler_type, sampler_arg)
tracer_provider = TracerProvider(sampler=sampler, resource=resource)
elif SAMPLING_TRACES_PER_SECOND_ARG in configurations:
Copy link
Member

Choose a reason for hiding this comment

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

Disto sampling now has a lot of different and overlapping ways of configuring the sampler. Could you add one more samples to the repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I will include all the possible ways to set it.

@rads-1996 rads-1996 requested a review from jeremydvoss January 8, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Distro Monitor OpenTelemetry Distro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants