Add DisableTelemetry support using OpenTelemetry OTEL_SDK_DISABLED#3084
Merged
rajkumar-rangaraj merged 5 commits intomainfrom Jan 24, 2026
Merged
Add DisableTelemetry support using OpenTelemetry OTEL_SDK_DISABLED#3084rajkumar-rangaraj merged 5 commits intomainfrom
rajkumar-rangaraj merged 5 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for disabling telemetry collection via the TelemetryConfiguration.DisableTelemetry property by leveraging OpenTelemetry SDK 1.15.0's OTEL_SDK_DISABLED environment variable.
Changes:
- Added
DisableTelemetryproperty support in non-DI scenarios by settingOTEL_SDK_DISABLEDenvironment variable inTelemetryConfiguration.Build() - Extended DI support to apply
IConfigureOptions<TelemetryConfiguration>callbacks in the TelemetryConfiguration factory - Implemented DI telemetry disabling by setting
OTEL_SDK_DISABLEDin IConfiguration via AzureMonitorExporterOptions Configure callback - Added tests for non-DI scenarios and updated documentation
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs | Sets OTEL_SDK_DISABLED environment variable when building SDK; removes CreateFromConfiguration method |
| BASE/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs | Changes StartOperation to return null instead of throwing ArgumentNullException when activity is null |
| NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs | Updates TelemetryConfiguration factory to apply IConfigureOptions and IPostConfigureOptions callbacks |
| NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs | Sets OTEL_SDK_DISABLED in IConfiguration when DisableTelemetry is true |
| NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs | Sets OTEL_SDK_DISABLED in IConfiguration when DisableTelemetry is true |
| BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryConfigurationOtelSdkDisabledTests.cs | Adds tests for DisableTelemetry in non-DI scenarios |
| docs/concepts.md | Documents DisableTelemetry usage for both non-DI and DI scenarios |
| CHANGELOG.md | Updates changelog with new feature entry |
| examples/AspNetCoreWebApp/Startup.cs | Adds commented example showing DisableTelemetry usage in DI |
| .publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt | Removes CreateFromConfiguration method from public API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs
Show resolved
Hide resolved
...ORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs
Show resolved
Hide resolved
...ights.Test/Microsoft.ApplicationInsights.Tests/TelemetryConfigurationOtelSdkDisabledTests.cs
Show resolved
Hide resolved
BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs
Show resolved
Hide resolved
...ights.Test/Microsoft.ApplicationInsights.Tests/TelemetryConfigurationOtelSdkDisabledTests.cs
Show resolved
Hide resolved
...ights.Test/Microsoft.ApplicationInsights.Tests/TelemetryConfigurationOtelSdkDisabledTests.cs
Show resolved
Hide resolved
harsimar
reviewed
Jan 23, 2026
harsimar
reviewed
Jan 23, 2026
harsimar
approved these changes
Jan 23, 2026
This was referenced Feb 1, 2026
Open
Open
Open
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.
Summary
Adds support for disabling telemetry via
TelemetryConfiguration.DisableTelemetryproperty by leveraging OpenTelemetry SDK 1.15.0'sOTEL_SDK_DISABLEDenvironment variable.Changes
Core Implementation
DisableTelemetryistrue, setsOTEL_SDK_DISABLED=trueenvironment variable before creating the OpenTelemetry SDK, causing it to return no-op implementationsDI Support (AspNetCore/WorkerService)
AddTelemetryConfigAndClient()to applyIConfigureOptions<TelemetryConfiguration>andIPostConfigureOptions<TelemetryConfiguration>callbacks, enablingservices.Configure<TelemetryConfiguration>()patternTelemetryConfigurationinjection inAzureMonitorExporterOptions.Configureto setOTEL_SDK_DISABLEDin IConfiguration whenDisableTelemetryis trueTests
TelemetryConfigurationOtelSdkDisabledTestswith 2 tests validating the feature for non-DI scenarios[Collection("TelemetryClientTests")]to prevent parallel execution issues with environment variable manipulationDocumentation
docs/concepts.mdwith usage examples for both direct and DI scenariosCHANGELOG.mdUsage
Non-DI:
DI (ASP.NET Core / Worker Service):
Notes