Name Sentry transactions after the route they matched (closes #185)
check / check (push) Successful in 14m13s
check / check (push) Successful in 14m13s
sentryhttp names each transaction after the concrete path, which the BeforeSendTransaction hook has to withhold, so with tracing on every transaction would land in one Sentry group, POST /(redacted). A middleware installed beside every sentryhttp handler now renames the transaction to the method and chi route pattern once the request is routed, and sets its source to route. The hook keeps a route-sourced name and withholds every other name as before, so a request that matched no route still reads POST /(redacted). Tracing stays off. Model: opus-5-5
This commit is contained in:
@@ -91,6 +91,24 @@ func NewRouterForTest(
|
||||
return s.router
|
||||
}
|
||||
|
||||
// NewRouterWithSentryForTest is NewRouterForTest with the sentryhttp
|
||||
// handler registered, as a set SENTRY_DSN does in production.
|
||||
func NewRouterWithSentryForTest(
|
||||
t *testing.T,
|
||||
log *logger.Logger,
|
||||
cfg *config.Config,
|
||||
mw *middleware.Middleware,
|
||||
h *handlers.Handlers,
|
||||
) http.Handler {
|
||||
t.Helper()
|
||||
|
||||
s := newServerForTest(t, log, cfg, mw, h)
|
||||
s.sentryEnabled.Store(true)
|
||||
s.SetupRoutes()
|
||||
|
||||
return s.router
|
||||
}
|
||||
|
||||
// ListenAddrForTest exposes the address the HTTP listener binds for
|
||||
// a given Config, so the rendering of host and port — IPv6
|
||||
// bracketing above all — can be pinned without standing up a
|
||||
|
||||
Reference in New Issue
Block a user