Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

## Unreleased
- [Fix `DisableTelemetry` not disabling metrics export: `OTEL_SDK_DISABLED` was set in IConfiguration too late (during options callback) after the OTel MeterProvider had already been constructed. Moved the check to a hosted service that runs before OpenTelemetry's TelemetryHostedService.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3156)
- [Fix `OTEL_SDK_DISABLED` not being honored when `TelemetryConfiguration.DisableTelemetry` is set in DI scenarios.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3156), [#3157](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3157)
- [Fix `TrackAvailability` ignoring user-specified `Timestamp` on `AvailabilityTelemetry`. The timestamp is now emitted as `microsoft.availability.testTimestamp` so downstream exporters can use the correct event time.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3153)
- [Added `netstandard2.0` target framework to `Microsoft.ApplicationInsights` package to support customers with shared libraries targeting netstandard2.0.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3142)
- [Fix `TelemetryClient.Context.Cloud.RoleName` set after construction now applies to all telemetry.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3129)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
.WithApplicationInsights()
.UseApplicationInsightsTelemetry();

AddTelemetryConfigAndClient(services, VersionUtils.ExtensionLabelShimAspNetCore + VersionUtils.GetVersion(typeof(ApplicationInsightsExtensions)));

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 102 in NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)
services.AddSingleton<IJavaScriptSnippet, JavaScriptSnippet>();
services.AddSingleton<JavaScriptSnippet>();
}
Expand Down Expand Up @@ -205,6 +205,12 @@
{
var serviceOptions = aiOptions.Value;

// Set OTEL_SDK_DISABLED in configuration if DisableTelemetry is true
if (telemetryConfig.DisableTelemetry)
{
config["OTEL_SDK_DISABLED"] = "true";
}

if (!string.IsNullOrEmpty(telemetryConfig.StorageDirectory))
{
exporterOptions.StorageDirectory = telemetryConfig.StorageDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
.WithApplicationInsights()
.UseApplicationInsightsTelemetry();

AddTelemetryConfigAndClient(services, VersionUtils.ExtensionLabelShimWorkerService + VersionUtils.GetVersion(typeof(ApplicationInsightsExtensions)));

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check warning on line 101 in NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

In externally visible method 'IServiceCollection ApplicationInsightsExtensions.AddApplicationInsightsTelemetryWorkerService(IServiceCollection services)', validate parameter 'services' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)
}

return services;
Expand Down Expand Up @@ -200,6 +200,12 @@
{
var serviceOptions = aiOptions.Value;

// Set OTEL_SDK_DISABLED in configuration if DisableTelemetry is true
if (telemetryConfig.DisableTelemetry)
{
config["OTEL_SDK_DISABLED"] = "true";
}

Comment on lines +203 to +208
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

This OTEL_SDK_DISABLED assignment is redundant: AddTelemetryConfigAndClient already sets IConfiguration["OTEL_SDK_DISABLED"] = "true" during TelemetryConfiguration resolution when DisableTelemetry is true (NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs:125-134). Since telemetryConfig is resolved before this callback executes, this block doesn’t change behavior and adds another place to maintain this logic; consider removing it and keeping the setting centralized in the shared TelemetryConfiguration factory.

Suggested change
// Set OTEL_SDK_DISABLED in configuration if DisableTelemetry is true
if (telemetryConfig.DisableTelemetry)
{
config["OTEL_SDK_DISABLED"] = "true";
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Intentionally keeping this as defense-in-depth. The TelemetryConfiguration factory covers MeterProvider, but TracerProvider may resolve through a different path. Setting the same value twice in IConfiguration is harmless and this was the original behavior on main before #3156.

if (!string.IsNullOrEmpty(telemetryConfig.StorageDirectory))
{
exporterOptions.StorageDirectory = telemetryConfig.StorageDirectory;
Expand Down
12 changes: 12 additions & 0 deletions NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;

/// <summary>
Expand Down Expand Up @@ -92,6 +93,17 @@ private static void AddTelemetryConfigAndClient(IServiceCollection services, str
{
services.AddOptions();

// Register a no-op ILoggerProvider at position 0 that depends on TelemetryConfiguration.
// ILoggerFactory resolves all ILoggerProvider instances in registration order during host
// construction. By inserting this first, TelemetryConfiguration is resolved (which sets
// OTEL_SDK_DISABLED in IConfiguration) before OpenTelemetry's LoggerProvider factory runs.
// Without this, LoggerProvider checks IConfiguration before OTEL_SDK_DISABLED is set.
services.Insert(0, ServiceDescriptor.Singleton<ILoggerProvider>(sp =>
{
_ = sp.GetRequiredService<TelemetryConfiguration>();
return NullLoggerProvider.Instance;
}));

// Register TelemetryConfiguration singleton with factory that creates it for DI scenarios
// We use a factory to ensure skipDefaultBuilderConfiguration: true is passed
services.AddSingleton<TelemetryConfiguration>(provider =>
Expand Down
Loading