open-telemetry/opentelemetry-dotnet

[bug] UseOtlpExporter is not respecting services.Configure<OtlpExporterOptions> but AddOtlpExporter does

Open

#6231 aperta il 4 apr 2025

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)C# (889 fork)auto 404
bughelp wantedpkg:OpenTelemetry.Exporter.OpenTelemetryProtocol

Metriche repository

Star
 (3725 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Package

OpenTelemetry.Exporter.OpenTelemetryProtocol

Package Version

Package Name Version
OpenTelemetry.Exporter.OpenTelemetryProtocol 1.11.2
OpenTelemetry 1.11.2

Runtime Version

net8.0

Description

UseOtlpExporter() is not respecting services.Configure<OtlpExporterOptions> Endpoint

Steps to Reproduce

  1. Configure non-default Endpoint via e.g., environment variable OpenTelemetry__OtlpExporter__Endpoint
  2. services.Configure<OtlpExporterOptions>(ctx.Configuration.GetSection("OpenTelemetry:OtlpExporter"));
  3. services.AddOpenTelemetry().UseOtlpExporter()

Expected Result

UseOtlpExporter is respecting services.Configure<OtlpExporterOptions> Endpoint

Actual Result

Connecting with default URL

Exception: {1}{http://localhost:4317/opentelemetry.proto.collector.metrics.v1.MetricsService/Export}{System.Net.Http.HttpRequestException: Connection refused (localhost:4317)
 ---> System.Net.Sockets.SocketException (111): Connection refused

...but when separately adding AddOtlpExporter then Endpoint setting is read correctly.

Additional Context

No response

Guida contributor