Option for making ASP.NET Core spans root? #1773
Labels
comp:extensions.enrichment.aspnetcore
Things related to OpenTelemetry.Extensions.Enrichment.AspNetCore
enhancement
New feature or request
Option for making ASP.NET Core spans root?
In microservices architecture, it's common to have a gateway API/backend-for-frontend type API which handles authentication and whatnot and does fanout of requests to downstream microservices. Our gateway API handles requests from both users of a web-portal and external clients (APIs, background workers etc).
We want all requests to the gateway API to be root spans (not attached to a client-controlled trace context), but there is no easy way to accomplish it currently. But here's how I made it work
The
System.Diagnostics.DistributedContextPropagator
is to prevent ASP.NET Core from intializing Activity with parent from request trace context, while using theTextMapPropagator
in a similar manner for theAspNetCore.Instrumentation
package. Since parent can't be changed after anActivity
has been created, this is the only way to do it AFAIK. Are there other options that I'm overlooking?We could always create our own AspNetCore instrumentation, but that seems less then ideal as well.
I would think that this was a pretty common use case for APIs where you can't let external clients dictate the organization of traces, but couldn't find any related issue. We use tempo for trace storage currently where one should prevent traces from getting too large
The text was updated successfully, but these errors were encountered: