Skip to main content
Source: Al0089MissingOtlpConfigurationAnalyzer.cs

Description

OTLP exporter should have its endpoint explicitly configured rather than relying on the default localhost:4317, which often does not exist in production.

Bad Code

builder.Services.AddOpenTelemetry()
    .WithTracing(t => t.AddOtlpExporter()); // default endpoint

Good Code

builder.Services.AddOpenTelemetry()
    .WithTracing(t => t.AddOtlpExporter(o =>
        o.Endpoint = new Uri("https://collector.example.com:4317")));

Properties

  • Category: OpenTelemetry
  • Severity: Warning
  • Enabled by default: True
  • Code fix available: False

Configuration

dotnet_diagnostic.AL0089.severity = warning