Back to all reviewers

Use higher-level telemetry

Azure/azure-sdk-for-net
Based on 2 comments
Markdown

When implementing observability for Azure services, prefer higher-level telemetry packages and configuration methods over low-level implementations. For Azure Monitor integration, use the Azure.Monitor.OpenTelemetry.AspNetCore package instead of the lower-level Azure.Monitor.OpenTelemetry.Exporter, as it provides simpler integration and is the recommended...

Observability Markdown

Reviewer Prompt

When implementing observability for Azure services, prefer higher-level telemetry packages and configuration methods over low-level implementations. For Azure Monitor integration, use the Azure.Monitor.OpenTelemetry.AspNetCore package instead of the lower-level Azure.Monitor.OpenTelemetry.Exporter, as it provides simpler integration and is the recommended approach for most scenarios.

For enabling OpenTelemetry support, you can use either environment variables or programmatic configuration:

// Option 1: Set environment variable (before application starts)
// AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE=true

// Option 2: Use AppContext.SetSwitch (preferred for programmatic control)
AppContext.SetSwitch("Azure.Experimental.EnableActivitySource", true);

// Use the recommended higher-level package
// Install: dotnet add package Azure.Monitor.OpenTelemetry.AspNetCore
// Instead of the lower-level: Azure.Monitor.OpenTelemetry.Exporter

Using higher-level telemetry packages simplifies implementation, provides better defaults, and follows Azure SDK best practices for observability. This approach reduces the complexity of monitoring code and improves maintainability while ensuring comprehensive system visibility.

2
Comments Analyzed
Markdown
Primary Language
Observability
Category

Source Discussions