Report handler panics to Sentry when SENTRY_DSN is set (closes #95)
check / check (push) Successful in 3m12s
check / check (push) Successful in 3m12s
With SENTRY_DSN set, the server initialises sentry-go with the release netwatch-server-<version>, adds the sentryhttp middleware with Repanic as the last router-wide middleware, after the timeout, and flushes Sentry for 2 seconds on shutdown. A DSN Sentry refuses stops the start with an error naming SENTRY_DSN. With it empty, nothing is set up. The metrics middleware stays on the matched routes only, so it runs inside the Sentry middleware rather than before it. Model: opus-5-5
This commit is contained in:
@@ -115,6 +115,28 @@ func TestMalformedConfigFileStopsTheStart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRefusedSentryDSNStopsTheStart: a SENTRY_DSN that Sentry refuses
|
||||
// stops the start, and the error, naming SENTRY_DSN, is logged as JSON.
|
||||
func TestRefusedSentryDSNStopsTheStart(t *testing.T) {
|
||||
t.Setenv("SENTRY_DSN", "not-a-dsn")
|
||||
|
||||
ctx, cancel := context.WithTimeout(t.Context(), childTimeout)
|
||||
defer cancel()
|
||||
|
||||
child, stdout, stderr := startServer(ctx, t, t.TempDir(), freePort(ctx, t))
|
||||
|
||||
err := child.Wait()
|
||||
if child.ProcessState.ExitCode() != 1 {
|
||||
t.Fatalf("server exit = %v, want exit status 1", err)
|
||||
}
|
||||
|
||||
requireJSONLines(t, stdout, stderr)
|
||||
|
||||
if !strings.Contains(stdout.String(), "SENTRY_DSN") {
|
||||
t.Fatalf("no error naming SENTRY_DSN in stdout:\n%s", stdout)
|
||||
}
|
||||
}
|
||||
|
||||
// startServer runs main() in a child process listening on
|
||||
// 127.0.0.1:port, with home as its HOME and working directory and its
|
||||
// data directory in home, so it touches nothing outside home. Its
|
||||
|
||||
Reference in New Issue
Block a user