Skip to content

Add DisableTelemetry support using OpenTelemetry OTEL_SDK_DISABLED#3084

Merged
rajkumar-rangaraj merged 5 commits intomainfrom
rajrang/disablesdk
Jan 24, 2026
Merged

Add DisableTelemetry support using OpenTelemetry OTEL_SDK_DISABLED#3084
rajkumar-rangaraj merged 5 commits intomainfrom
rajrang/disablesdk

Conversation

@rajkumar-rangaraj
Copy link
Member

Summary

Adds support for disabling telemetry via TelemetryConfiguration.DisableTelemetry property by leveraging OpenTelemetry SDK 1.15.0's OTEL_SDK_DISABLED environment variable.

Changes

Core Implementation

  • TelemetryConfiguration.Build(): When DisableTelemetry is true, sets OTEL_SDK_DISABLED=true environment variable before creating the OpenTelemetry SDK, causing it to return no-op implementations

DI Support (AspNetCore/WorkerService)

  • Updated AddTelemetryConfigAndClient() to apply IConfigureOptions<TelemetryConfiguration> and IPostConfigureOptions<TelemetryConfiguration> callbacks, enabling services.Configure<TelemetryConfiguration>() pattern
  • Added TelemetryConfiguration injection in AzureMonitorExporterOptions.Configure to set OTEL_SDK_DISABLED in IConfiguration when DisableTelemetry is true

Tests

  • Added TelemetryConfigurationOtelSdkDisabledTests with 2 tests validating the feature for non-DI scenarios
  • Tests use [Collection("TelemetryClientTests")] to prevent parallel execution issues with environment variable manipulation

Documentation

  • Updated docs/concepts.md with usage examples for both direct and DI scenarios
  • Updated CHANGELOG.md

Usage

Non-DI:

var configuration = new TelemetryConfiguration
{
    ConnectionString = "...",
    DisableTelemetry = true
};
var tc = new TelemetryClient(configuration);

DI (ASP.NET Core / Worker Service):

// Must be called BEFORE AddApplicationInsightsTelemetry()
services.Configure<TelemetryConfiguration>(tc => tc.DisableTelemetry = true);
services.AddApplicationInsightsTelemetry();

Notes

  • Requires OpenTelemetry SDK 1.15.0+ which supports OTEL_SDK_DISABLED
  • For DI scenarios, DisableTelemetry must be configured before AddApplicationInsightsTelemetry() is called

Copilot AI review requested due to automatic review settings January 23, 2026 22:52
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 disabling telemetry collection via the TelemetryConfiguration.DisableTelemetry property by leveraging OpenTelemetry SDK 1.15.0's OTEL_SDK_DISABLED environment variable.

Changes:

  • Added DisableTelemetry property support in non-DI scenarios by setting OTEL_SDK_DISABLED environment variable in TelemetryConfiguration.Build()
  • Extended DI support to apply IConfigureOptions<TelemetryConfiguration> callbacks in the TelemetryConfiguration factory
  • Implemented DI telemetry disabling by setting OTEL_SDK_DISABLED in 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.

@rajkumar-rangaraj rajkumar-rangaraj merged commit 10ad75f into main Jan 24, 2026
22 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the rajrang/disablesdk branch January 24, 2026 00:10
This was referenced Feb 1, 2026
This was referenced Feb 10, 2026
paulvanbrenk added a commit to tinytoolsllc/ai-patch-notes that referenced this pull request Feb 15, 2026
Updated
[coverlet.collector](https://github.com/coverlet-coverage/coverlet) from
6.0.4 to 8.0.0.

<details>
<summary>Release notes</summary>

_Sourced from [coverlet.collector's
releases](https://github.com/coverlet-coverage/coverlet/releases)._

## 8.0.0

**Special Thanks:** A huge thank you to
[@​Bertk](https://github.com/Bertk) for driving the majority of the work
in this release! 🎉

### Fixed
- Fix System.CommandLine 2.0 release is available
[#​1776](coverlet-coverage/coverlet#1776)
- Fix Excluding From Coverage bad defaults from given example
[#​1764](coverlet-coverage/coverlet#1764)
- Fix branchpoint exclusion for sdk 8.0.407
[#​1741](coverlet-coverage/coverlet#1741)
- Fix missing copyright information in NuGet
[#​1794](coverlet-coverage/coverlet#1794)
- Fix bad default values in documentation
[#​1764](coverlet-coverage/coverlet#1764) by
<https://github.com/cboudereau>

### Improvements

- Coverlet MTP extension feature
[#​1788](coverlet-coverage/coverlet#1788)
- Generate SBOM for nuget packages
[#​1752](coverlet-coverage/coverlet#1752)
- Use multi targets projects for coverlet.collector,
coverlet.msbuild.tasks packages
[#​1742](coverlet-coverage/coverlet#1742)
- Use .NET 8.0 target framework for coverlet.core and remove
Newtonsoft.Json
[#​1733](coverlet-coverage/coverlet#1733)
- Use latest System.CommandLine version
[#​1660](coverlet-coverage/coverlet#1660)
- Upgraded minimum required .NET SDK and runtime to .NET 8.0 LTS (Long
Term Support) (**Breaking Change**)
- Use [xunit.v3](https://xunit.net/docs/getting-started/v3/whats-new)
for tests and example code

[Diff between 6.0.4 and
8.0.0](coverlet-coverage/coverlet@v6.0.4...v8.0.0)

Commits viewable in [compare
view](coverlet-coverage/coverlet@v6.0.4...v8.0.0).
</details>

Updated
[Microsoft.ApplicationInsights.WorkerService](https://github.com/Microsoft/ApplicationInsights-dotnet)
from 2.23.0 to 3.0.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.ApplicationInsights.WorkerService's
releases](https://github.com/Microsoft/ApplicationInsights-dotnet/releases)._

## 3.0.0

- [Replaced `netstandard2.0` with `net8.0` target framework in
`Microsoft.ApplicationInsights.NLogTarget`
package.](microsoft/ApplicationInsights-dotnet#3102)

## 3.0.0-rc1

- [Removed `netstandard2.0` target framework from
`Microsoft.ApplicationInsights`,
`Microsoft.ApplicationInsights.AspNetCore`, and
`Microsoft.ApplicationInsights.WorkerService`
packages.](microsoft/ApplicationInsights-dotnet#3091)
- [The JavaScript in `Microsoft.ApplicationInsights.AspNetCore` has been
updated to version
10.](microsoft/ApplicationInsights-dotnet#3078)
- [Centralized package version
management](microsoft/ApplicationInsights-dotnet#3080)
- [Update OpenTelemetry
dependencies](microsoft/ApplicationInsights-dotnet#3080),
[#​3092](microsoft/ApplicationInsights-dotnet#3092)
  - OpenTelemetry 1.15.0
  - OpenTelemetry.Instrumentation.AspNetCore 1.15.0
  - OpenTelemetry.Instrumentation.AspNet 1.15.1
  - OpenTelemetry.Instrumentation.Http 1.15.0
  - OpenTelemetry.Instrumentation.SqlClient 1.15.0
- [Vendored OpenTelemetry.Resources.Azure resource detectors to NETCORE
shared folder, replaced package with vendored
implementation](microsoft/ApplicationInsights-dotnet#3095),
[#​3093](microsoft/ApplicationInsights-dotnet#3093)
- [Added support to disable telemetry via
TelemetryConfiguration.DisableTelemetry](microsoft/ApplicationInsights-dotnet#3084)
- [Removed `EnabledAdaptiveSampling` and replaced with `TracesPerSecond`
and
`SamplingRatio`](microsoft/ApplicationInsights-dotnet#3085)
- [Added `EnableTraceBasedLogsSampler` property to
`ApplicationInsightsServiceOptions` for ASP.NET Core and WorkerService
packages](microsoft/ApplicationInsights-dotnet#3088)
- [Added support for `StorageDirectory` and `DisableOfflineStorage` from
`TelemetryConfiguration` in DI
scenarios](microsoft/ApplicationInsights-dotnet#3088)
- [Update Azure.Monitor.OpenTelemetry.Exporter dependency to
1.6.0](microsoft/ApplicationInsights-dotnet#3094)
 

## 3.0.0-beta2

Added
- Automatic configuration binding from "ApplicationInsights" section in
appsettings.json for both AspNetCore and WorkerService packages with
configuration precedence: environment variables > explicit configuration
> appsettings.json
- Added support for Entra ID (Azure Active Directory) authentication
using Azure.Core.TokenCredential
- Added Self Diagnostics feature
- Updated the default sampler from Fixed Rate to Rate-Limited Sampling.
- Update Azure Monitor Exporter to 1.6.0-beta.2
- Add comprehensive applicationinsights.config support
- Add properties in TelemetryConfiguration to configure underlying
exporter

Bug fix
- Fix TrackMetric(MetricTelemetry) unsupported telemetry type error

## 3.0.0-beta1

- The following Application Insights packages in this repo now use
OpenTelemetry internally. OpenTelemetry is the industry standard for
telemetry collection and provides better interoperability with other
observability tools.
  - Microsoft.ApplicationInsights
  - Microsoft.ApplicationInsights.AspNetCore
  - Microsoft.ApplicationInsights.WorkerService
  - Microsoft.ApplicationInsights.Web
  - Microsoft.ApplicationInsights.NLogTarget
- Classic APIs of the above packages are preserved; calls are translated
to OpenTelemetry telemetry.
- Other packages not listed above (such as certain auto-collectors and
logging adapters that were published from this repo previously) will not
have future versions published. See BreakingChanges.md for details.

Commits viewable in [compare
view](microsoft/ApplicationInsights-dotnet@2.23.0...v3.0.0).
</details>

Updated [Svix](https://github.com/svix/svix-webhooks) from 1.84.1 to
1.85.0.

<details>
<summary>Release notes</summary>

_Sourced from [Svix's
releases](https://github.com/svix/svix-webhooks/releases)._

## 1.85.0

## What's Changed
* Server: Fix non-determinism with regards to overrides of specific
header names
* Server: Bump MSRV to 1.88.0
* Libs/Ruby: Return nil if payload is empty, instead of attempting to
parse as JSON (thanks @​donovanlopez)
* Libs/Rust: Bump MSRV to 1.88.0
* CLI: Bump MSRV to 1.88.0

**Full Changelog**:
svix/svix-webhooks@v1.84.1...v1.85.0

Commits viewable in [compare
view](svix/svix-webhooks@v1.84.1...v1.85.0).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants