feat: add gqlgen Recover that logs panics as one structured record
otelsetup / vulnerabilities (pull_request) Successful in 31s
otelsetup / test (pull_request) Successful in 3m41s
pre-commit / pre-commit (pull_request) Successful in 3m2s

gqlgen's DefaultRecover prints the panic and debug.PrintStack() to stderr, so the log collector stores every stack line as a separate, level-less entry. Recover logs the panic as a single ERROR record via slog.Default() with panic, stack and path attributes, records it on the active span with status Error, and returns the generic "internal system error" without leaking the panic text. Install with srv.SetRecoverFunc(otelsetup.Recover).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H6eVuR4Yt3m7TbDTDwyZJi
This commit is contained in:
argoyleandClaude Opus 5.5 committed 2026-10-17 01:04:48 +02:00
1 parent 9fe1a21c02
commit ff0585ad68
4 files changed
+167 -1

No files matched your search

+1 -1
View File
@@ -6,6 +6,7 @@ require (
codeberg.org/eventsourced/eventsourced v1.24.0
codeberg.org/eventsourced/pg/v2 v2.3.0
github.com/99designs/gqlgen v0.17.95
github.com/vektah/gqlparser/v2 v2.5.37
go.opentelemetry.io/otel v1.47.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.47.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0
@@ -30,7 +31,6 @@ require (
github.com/pressly/goose/v3 v3.28.0 // indirect
github.com/sethvargo/go-retry v0.4.0 // indirect
github.com/sosodev/duration v1.4.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.37 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
go.opentelemetry.io/otel/log v1.47.0 // indirect