This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
Runtime version (e.g. net462, net48, net6.0, net7.0 etc. You can
find this information from the *.csproj file):
net8.0
Is this a feature request or a bug?
[X] Feature Request
[ ] Bug
What is the expected behavior?
I was hoping there was a way to support having multiple unit tests where the SUT calls AddWcfInstrumentation() (e.g. as part of a host configuration).
What is the actual behavior?
You get the following exception:
System.NotSupportedException : WCF instrumentation has already been registered and doesn't support multiple registrations.
at OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddWcfInstrumentation(TracerProviderBuilder builder, Action`1 configure)
at OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddWcfInstrumentation(TracerProviderBuilder builder)
Additional Context
I can see that internally the library makes this call to reset the static reference causing the exception fire:
It's probably worth adding that you might normally exclude the OpenTelemetry from being configured during your unit tests, so this isn't that high a priority.
Issue with OpenTelemetry.Instrumentation.Wcf
List of all OpenTelemetry NuGet packages and version that you are using (e.g.
OpenTelemetry 1.3.2
):OpenTelemetry.Instrumentation.Wcf 1.0.0-rc.15
Runtime version (e.g.
net462
,net48
,net6.0
,net7.0
etc. You can find this information from the*.csproj
file):Is this a feature request or a bug?
What is the expected behavior?
I was hoping there was a way to support having multiple unit tests where the SUT calls
AddWcfInstrumentation()
(e.g. as part of a host configuration).What is the actual behavior?
You get the following exception:
Additional Context
I can see that internally the library makes this call to reset the static reference causing the exception fire:
https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/de135415f5de21c0a565f3fb3b0570484e7a2bae/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForHttpTests.cs#L227C13-L227C61
But
WcfInstrumentationActivitySource
is an internal class, so we can't reference it from our tests.