Documentation
¶
Overview ¶
Package sentryfiber is the Fiber v2 adapter for the sentrycore Sentry error/crash reporting engine. See the sibling sentryfiberv3 package for Fiber v3.
The middleware:
- Binds a per-request Sentry hub (a clone of the current hub) onto the request context so concurrent requests don't share scope.
- Enriches the scope with the HTTP request and the active APM trace tags (trace_id / transaction_id) via sentrycore, so a captured error links back to its Kibana trace.
- Recovers panics, reports them to Sentry, and (by default) responds 500 instead of crashing the app.
- Captures errors bubbled from handlers to Fiber's ErrorHandler.
It never blocks the request: when Sentry is disabled (empty DSN) the middleware still calls c.Next() and every capture is a no-op.
Pitfall: place this middleware AFTER apmfiber.Middleware() so the APM transaction already exists on c.Context() when sentrycore reads the trace tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureError ¶
CaptureError reports err against the current request's Sentry hub. Use it from handlers that map errors inline (without returning them to Fiber's ErrorHandler). No-op when err is nil or Sentry is disabled.
func NewWithConfig ¶
NewWithConfig returns the middleware configured by cfg.
Types ¶
type Config ¶
type Config struct {
// Repanic re-panics after reporting so an upstream recover middleware
// (or the Fiber default) can handle it. Default false: the panic is
// swallowed and a 500 is returned.
Repanic bool
// WaitForDelivery blocks the response until the event is delivered.
// Default false (events are flushed asynchronously / at shutdown).
WaitForDelivery bool
// Redactor masks sensitive request headers and query params before they
// are attached to the Sentry event. Nil uses logcore.DefaultRedactor()
// so the Sentry payload shares the exact policy applied to the logs.
//
// Pass the SAME *logcore.Redactor you gave logcore.Options.Redactor so a
// custom denylist reflects in both places. setup.Builder does this
// automatically when WithSentry and WithLogger are both configured.
Redactor *logcore.Redactor
}
Config tunes the middleware.