-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sentry tracing middleware should be added automatically #2202
Comments
We think this is an important item, because it helps customers fall into the pit of success with setting up Sentry for ASP.NET Core. |
Before starting anything, we should validate that. The last few aspnet core apps I've written don't even have those, so I'm not sure exactly which set of middlewares need to run before / after ours and why. I believe it has much to do with getting the correct transaction name based on the route, but this needs more investigation. Thanks |
We may need to rethink this in the context of opentelemetry... |
Problem Statement
In an ASP.NET Core app, enabling Sentry tracing currently requires two parts:
EnableTracing
,TracesSampleRate
, orTracesSampler
app.UseSentryTracing()
to add the ASP.NET Core tracing middlewareIt's easy to forget adding one step or the other. It's also easy to place the middleware at the wrong location, since it has to be after
UseRouting
and beforeUseEndpoints
.Solution Brainstorm
If tracing is enabled, we can add the tracing middleware automatically at the correct location. We could then deprecate
UseSentryTracing
.There's a detailed example of how to do this in the following blog posts:
Alternative solution
Andrew's solution is quite ingenious... a simpler partial solution would be to create an extension that people would use instead of
UseRouting
:And then when people are wiring up their middleware they could just do this (see commented code... which is what gets replaced):
This doesn't solve the problem of also requiring
EnableTracing
,TracesSampleRate
, orTracesSampler
to be set on the options however, so Tracing still needs to be configured in two locations with this solution.The text was updated successfully, but these errors were encountered: