server: report HTTP handler panics to Sentry (closes #107)
check / check (push) Successful in 1m35s
check / check (push) Successful in 1m35s
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. Client reports are off, so only panics are sent. The DSN is checked at server start, not in config, so the config test is unchanged. sentry-go raises several golang.org/x modules and moves go-spew and go-difflib to untagged commits. Model: opus-5-5
This commit was merged in pull request #184.
This commit is contained in:
@@ -17,18 +17,13 @@ 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.
|
||||
func buildServer(t *testing.T) *server.Server {
|
||||
t.Helper()
|
||||
|
||||
var srv *server.Server
|
||||
|
||||
app := fx.New(
|
||||
// newServerApp builds an fx app holding a *server.Server wired exactly
|
||||
// as cmd/dnswatcher wires it, minus the watcher/resolver subtree that
|
||||
// would touch live DNS, plus the given option. config.New reads viper,
|
||||
// so the caller must first configure it, which is also why the caller
|
||||
// cannot run in parallel.
|
||||
func newServerApp(option fx.Option) *fx.App {
|
||||
return fx.New(
|
||||
fx.NopLogger,
|
||||
fx.Provide(
|
||||
globals.New,
|
||||
@@ -41,8 +36,18 @@ func buildServer(t *testing.T) *server.Server {
|
||||
handlers.New,
|
||||
server.New,
|
||||
),
|
||||
fx.Populate(&srv),
|
||||
option,
|
||||
)
|
||||
}
|
||||
|
||||
// buildServer builds the server without starting the app's lifecycle,
|
||||
// so no OnStart hook runs and nothing listens or resolves.
|
||||
func buildServer(t *testing.T) *server.Server {
|
||||
t.Helper()
|
||||
|
||||
var srv *server.Server
|
||||
|
||||
app := newServerApp(fx.Populate(&srv))
|
||||
|
||||
err := app.Err()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user