server: report HTTP handler panics to Sentry (closes #107)
check / check (push) Failing after 35s
check / check (push) Failing after 35s
DNSWATCHER_SENTRY_DSN was read but never used. This ports the Sentry integration from gohttpserver with sentry-go v0.49.0. The server's start hook calls sentry.Init when the DSN is set; a DSN Sentry cannot parse fails the hook, so startup stops with the parse error. sentryhttp, with Repanic, reports handler panics and passes them on to chi's Recoverer. Shutdown sends queued reports once the HTTP server has stopped. The client uses the older transport (DisableTelemetryBuffer): with the default one, Flush can return before sending a report made just before it. The DSN is checked at server start, not in config, so the config test is unchanged. sentry-go raises several golang.org/x modules. Model: opus-5-5
This commit is contained in:
@@ -17,12 +17,26 @@ import (
|
||||
"sneak.berlin/go/dnswatcher/internal/state"
|
||||
)
|
||||
|
||||
// buildServer wires a *server.Server exactly as cmd/dnswatcher does,
|
||||
// minus the watcher/resolver subtree that would touch live DNS. fx
|
||||
// builds the object graph but the lifecycle is never started, so no
|
||||
// OnStart hook runs and nothing listens or resolves. The caller must
|
||||
// first configure viper (config.New reads it), which is also why the
|
||||
// caller cannot run in parallel.
|
||||
// serverGraph provides a *server.Server wired exactly as cmd/dnswatcher
|
||||
// wires it, minus the watcher/resolver subtree that would touch live
|
||||
// DNS. config.New reads viper, so the caller must first configure it,
|
||||
// which is also why the caller cannot run in parallel.
|
||||
func serverGraph() fx.Option {
|
||||
return fx.Provide(
|
||||
globals.New,
|
||||
logger.New,
|
||||
config.New,
|
||||
state.New,
|
||||
healthcheck.New,
|
||||
notify.New,
|
||||
middleware.New,
|
||||
handlers.New,
|
||||
server.New,
|
||||
)
|
||||
}
|
||||
|
||||
// buildServer builds the server graph without starting its lifecycle,
|
||||
// so no OnStart hook runs and nothing listens or resolves.
|
||||
func buildServer(t *testing.T) *server.Server {
|
||||
t.Helper()
|
||||
|
||||
@@ -30,17 +44,7 @@ func buildServer(t *testing.T) *server.Server {
|
||||
|
||||
app := fx.New(
|
||||
fx.NopLogger,
|
||||
fx.Provide(
|
||||
globals.New,
|
||||
logger.New,
|
||||
config.New,
|
||||
state.New,
|
||||
healthcheck.New,
|
||||
notify.New,
|
||||
middleware.New,
|
||||
handlers.New,
|
||||
server.New,
|
||||
),
|
||||
serverGraph(),
|
||||
fx.Populate(&srv),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user