Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
{
var serviceOptions = aiOptions.Value;

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

Comment thread
rajkumar-rangaraj marked this conversation as resolved.
if (!string.IsNullOrEmpty(telemetryConfig.StorageDirectory))
{
exporterOptions.StorageDirectory = telemetryConfig.StorageDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
{
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

Copilot AI Mar 31, 2026

Copy link

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
Loading