-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add support for OTEL_TRACES_SAMPLER #44535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/tests/utils/test_configurations.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Show resolved
Hide resolved
2bdcb54 to
e63d0e1
Compare
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
7769e93 to
43243ca
Compare
| 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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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:
General Guidelines and Best Practices