[AzureMonitorExporter] [AzureMonitorDistro] Change default to rate limited sampler without api change#54942
Merged
harsimar merged 2 commits intoAzure:mainfrom Jan 9, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the default sampling behavior from 100% sampling (ApplicationInsightsSampler) to rate-limited sampling with 5.0 traces per second (RateLimitedSampler) to reduce telemetry costs for high-traffic applications. The change is implemented by setting the default value of TracesPerSecond property to 5.0 in both AzureMonitorExporterOptions and AzureMonitorOptions classes.
Key changes:
- Default sampler changed from 100% to rate-limited (5.0 traces/second) by setting
TracesPerSecond = 5.0as the default - Configuration logic updated to automatically set
TracesPerSecond = nullwhen users explicitly configure onlySamplingRatiovia JSON configuration or environment variables - All existing tests updated to reflect new defaults, and E2E tests explicitly configured for 100% sampling
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/AzureMonitorExporterOptions.cs | Changed default value of TracesPerSecond from null to 5.0 and removed documentation stating 100% default |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/DefaultAzureMonitorExporterOptions.cs | Added logic to set TracesPerSecond = null when only SamplingRatio is configured, enabling percentage-based sampling |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/AzureMonitorOptions.cs | Changed default value of TracesPerSecond from null to 5.0 and removed documentation stating 100% default |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/DefaultAzureMonitorOptions.cs | Added logic to set TracesPerSecond = null when only SamplingRatio is configured |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/DefaultAzureMonitorExporterOptionsTests.cs | Updated tests to expect 5.0 as default and added new tests for configuration scenarios |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/DefaultAzureMonitorOptionsTests.cs | Updated tests to expect 5.0 as default and added new test for TracesPerSecond configuration |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/DefaultAzureMonitorOptionsSamplerTests.cs | Updated invalid argument tests to expect 5.0 as default |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/InitializationTests.cs | Updated to expect rate-limited sampler as default |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/E2ETests/*.cs | E2E tests configured to use 100% sampling for deterministic test results |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/README.md | Added documentation for default sampling behavior and configuration examples |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/README.md | Added documentation for default sampling behavior and configuration examples |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/CHANGELOG.md | Documented breaking change with migration instructions |
| sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/CHANGELOG.md | Documented breaking change with migration instructions |
sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/DefaultAzureMonitorOptions.cs
Outdated
Show resolved
Hide resolved
...etCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/DefaultAzureMonitorOptionsTests.cs
Outdated
Show resolved
Hide resolved
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/DefaultAzureMonitorExporterOptions.cs
Outdated
Show resolved
Hide resolved
rajkumar-rangaraj
approved these changes
Jan 9, 2026
This was referenced Jan 29, 2026
This was referenced Feb 1, 2026
Merged
This was referenced Feb 3, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes the default sampler to rate limited. When we choose to do a major version bump, we will consider changing this implementation to have a nullable sample ratio so that the user doesn't have to set tracespersecond to null.