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

Prevent duplicates when using OTel + Sentry

Open jamescrosswell opened this issue 3 months ago • 1 comments

Description

There are frameworks that we don't have any specific Sentry integration for but that are instrumented with OTel... so in those cases people want to mix and match (they want to use OTel for the stuff we haven't instrumented but might want to use Sentry.Extensions.AI for our AI stuff or whatever.

That works, as long as people don't add the default sources from Microsoft... generally done via extension methods like:

        .WithTracing(tcb =>
        {
            tcb.AddSource("MyCompany.MyProduct.MyService") // Add your custom ActivitySource name
               .AddAspNetCoreInstrumentation()
               .AddHttpClientInstrumentation()
               .AddSentry(); 
        })

Above the calls to AddAspNetCoreInstrumentation and AddHttpClientInstrumentation wire up some Microsoft sources under the hood (similar to the call to AddSource but without requiring SDK users to know the specific names of the sources to add and not allowing them to make a typo when adding these).

We could try to drop/skip spans from those sources if we have a Sentry integration active that would effectively be adding instrumentation for the same thing. Since all of this happens in the SpanProcessor in the Sentry.OpenTelemetry integration, we'd need:

  1. A way for our other integrations to be able to inject span filters that get used by the span processor (which won't know anything about the specifics of those other integrations)
  2. A way to reliably identify the spans that we want to filter out (hopefully the source name is available)

jamescrosswell avatar Oct 06 '25 02:10 jamescrosswell

NET-479

linear[bot] avatar Oct 06 '25 02:10 linear[bot]