Name Sentry transactions after the route they matched (closes #185)
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:
2026-10-12 23:46:21 +00:00
parent 9199544999
commit 96d8e7c1aa
5 changed files with 179 additions and 17 deletions
+18
View File
@@ -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