open-telemetry/opentelemetry-dotnet

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

Open

#6,231 opened on 2025年4月4日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)C# (889 forks)auto 404
bughelp wantedpkg:OpenTelemetry.Exporter.OpenTelemetryProtocol

Repository metrics

Stars
 (3,725 stars)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド