-
Hi, trying to switch over to Open Telemetry from Is there a way to dynamically add or remove instruments, at runtime? How about same for Metrics? My application can hot reload configuration that determined what metrics and instruments are created, so not sure how to do this if its not know at startup. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@Simonl9l OTel SDK officially does not support this. You may do similar what we do in OTel Auto for "lazy instrumentation". Start from here https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/main/src/OpenTelemetry.AutoInstrumentation/Loading/LazyInstrumentationLoader.cs |
Beta Was this translation helpful? Give feedback.
It's a standalone part. No connection to
AddOpenTelemetry()
butAddSource()
.LazyInstrumentationLoader
is just stateholder of Initializers (for exampleHttpClientInitializer
). Initializer specifies when an specific instrumentation instance is created and when invoked, then creates the instance.For eg
HttpClientInitializer
is waiting forSystem.Net.Http.dll
to load. If loaded it creates instance ofOpenTelemetry.Instrumentation.Http.HttpClientInstrumentation
.EnvironmentConfigurationTracerHelper.Wrappers.AddHttpClientInstrumentation()
wires up all the parts. First adds a lazy initializer to listen for assembly load events. Second always subscribes to System.Diagnostic.DiagnosticSource sou…