Feature Request
Is your feature request related to a problem?
OpenTelemetry .NET Auto-Instrumentation dynamically loads OpenTelemetry .NET SDK and its instrumentation to user process and helps collect telemetry from an application without modifying the code. Issue happens when the application has a reference to OpenTelemetry SDK and user want to enable Auto-Instrumentation. In this case both user application and Auto-Instrumentation will have its own instance of TracerProvider or MeterProvider and could collect duplicate telemetries.
Describe the solution you'd like:
Auto-Instrumentation uses .NET startup hook to load the OpenTelemetry SDK and initialize TracerProvider/MeterProvider before the main application's entry point. SDK providing an option to disable the creation of the TracerProvider/MeterProvider for user-initiated providers should solve this issue. This could be implemented by adding a static bool flag in TracerProvider/ MeterProvider to stop creation of these providers. This flag can be private or public, auto-instrumentation has ability to set this through reflection. If customer use auto-instrumentation, this flag could be set by auto-instrumentation in startup and it will avoid creation of TracerProvider from user application.
Additional Context
https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/633
cc: @open-telemetry/dotnet-instrumentation-approvers
Feature Request
Is your feature request related to a problem?
OpenTelemetry .NET Auto-Instrumentation dynamically loads OpenTelemetry .NET SDK and its instrumentation to user process and helps collect telemetry from an application without modifying the code. Issue happens when the application has a reference to OpenTelemetry SDK and user want to enable Auto-Instrumentation. In this case both user application and Auto-Instrumentation will have its own instance of
TracerProviderorMeterProviderand could collect duplicate telemetries.Describe the solution you'd like:
Auto-Instrumentation uses .NET startup hook to load the OpenTelemetry SDK and initialize
TracerProvider/MeterProviderbefore the main application's entry point. SDK providing an option to disable the creation of theTracerProvider/MeterProviderfor user-initiated providers should solve this issue. This could be implemented by adding a static bool flag inTracerProvider/MeterProviderto stop creation of these providers. This flag can be private or public, auto-instrumentation has ability to set this through reflection. If customer use auto-instrumentation, this flag could be set by auto-instrumentation in startup and it will avoid creation of TracerProvider from user application.Additional Context
https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/633
cc: @open-telemetry/dotnet-instrumentation-approvers