open-telemetry/opentelemetry-dotnet

There is no method to remove the Source

harshchaurasia2020 opened this issue · 2 comments

Bug Report

We have AddSource feature in TraceProviderBuilder which is used for adding source.
But there is no feature available to Remove the source.

For example, if I need to enable/disable tracing for a particular source, there is no way to do it.

Also, I using HasListener property to determine if Source is added/removed.

if I need to enable/disable tracing for a particular source, there is no way to do it.

All sources are opt-in. If a particular source is not desired, then simply not add it !

Or are you asking about how do I AddSource(), and then change mind, and RemoveSource()? Can you give a example scenario, so we can understand better what is the end goal.

Adding context with specific scenario:

E.g. I do AddSource("Azure.*") and then I get all the sources emitted by Azure SDK.
Then I find that Azure.Http.Request is noisy and not helpful and want to exclude it. Then my alternative is to find out what are all the sources I listen to from Azure SDK and enable them with AddSource("Azure.Storage.*) AddSource("Azure.ServiceBus.*").
Now also every time I add something I need to explicitly list new sources.

Another similar case: distro enables a bunch or sources for me but I want to exclude some.

I'd like to have AddSource(Predicate<string> filter) API in addition to (undocumented?) wildcards which could resolve at least some of those cases.

Removing a source would be more controversial and could better be done via extra filter:
e.g. distro calls into AddSource("Azure.*")
user can override it with something like ConfigureTracingProvider(tp -> tp.FilterSources(Predicate<string> filter))