opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

[otlp] UseOtlpExporter and AddOtlpExporter extensions don't play nice together

Open CodeBlanch opened this issue 1 year ago • 3 comments

In 1.8.0 we introduced the UseOtlpExporter extension which will turn on OtlpExporter for all signals. If UseOtlpExporter is called more than once, or AddOtlpExporter is called in addition, exceptions will be thrown:

  • NotSupportedException: Multiple calls to UseOtlpExporter on the same IServiceCollection are not supported.

    https://github.com/open-telemetry/opentelemetry-dotnet/blob/57c442cc7b2fe93c81ca877de28f5204fdb11ebb/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderServiceProviderExtensions.cs#L15

  • NotSupportedException: Signal-specific AddOtlpExporter methods and the cross-cutting UseOtlpExporter method being invoked on the same IServiceCollection is not supported.

    https://github.com/open-telemetry/opentelemetry-dotnet/blob/57c442cc7b2fe93c81ca877de28f5204fdb11ebb/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderServiceProviderExtensions.cs#L24

This was intentionally done but some users have run into issues:

  • https://github.com/dotnet/aspire/pull/3697#issuecomment-2058028632

Opening this issue to track the demand for changing the behavior.

CodeBlanch avatar Apr 16 '24 17:04 CodeBlanch

See https://github.com/open-telemetry/opentelemetry-dotnet/issues/5537

liammclennan avatar Apr 16 '24 23:04 liammclennan