Skip to content

[AzureMonitorExporter] [AzureMonitorDistro] Change default to rate limited sampler without api change#54942

Merged
harsimar merged 2 commits intoAzure:mainfrom
harsimar:harskaur/sampling2
Jan 9, 2026
Merged

[AzureMonitorExporter] [AzureMonitorDistro] Change default to rate limited sampler without api change#54942
harsimar merged 2 commits intoAzure:mainfrom
harsimar:harskaur/sampling2

Conversation

@harsimar
Copy link
Member

@harsimar harsimar commented Jan 9, 2026

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.

Copilot AI review requested due to automatic review settings January 9, 2026 22:23
@github-actions github-actions bot added Monitor - Distro Monitor OpenTelemetry Distro Monitor - Exporter Monitor OpenTelemetry Exporter labels Jan 9, 2026
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 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.0 as the default
  • Configuration logic updated to automatically set TracesPerSecond = null when users explicitly configure only SamplingRatio via 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

Copy link
Contributor

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

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

LGTM

@harsimar harsimar enabled auto-merge (squash) January 9, 2026 22:52
@harsimar harsimar merged commit 22eaa86 into Azure:main Jan 9, 2026
21 checks passed
This was referenced Feb 3, 2026
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