sentryfiber

package module
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 4 Imported by: 0

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:

  1. Binds a per-request Sentry hub (a clone of the current hub) onto the request context so concurrent requests don't share scope.
  2. 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.
  3. Recovers panics, reports them to Sentry, and (by default) responds 500 instead of crashing the app.
  4. 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

func CaptureError(c *fiber.Ctx, err error)

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 New

func New() fiber.Handler

New returns the middleware with default Config.

func NewWithConfig

func NewWithConfig(cfg Config) fiber.Handler

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
}

Config tunes the middleware.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL