Connect Fiber to Bugsink
When a Fiber handler panics, Bugsink shows you the error, the application frame that raised it, and the HTTP request that reached the route.
This guide covers the initial setup and Fiber’s automatic capture of handler panics. You’ll add the SDK middleware to an existing Fiber 2 application, then make one request fail to confirm that it reaches Bugsink.
To follow along, create a Bugsink project and copy its DSN. The quickstart guide shows where to find it.
Install the SDK
The current SDK integration supports Fiber 2; its handler and context types are not compatible with Fiber 3. In an existing Fiber 2 module, add the open-source integration:
go get github.com/getsentry/sentry-go/fibergo get github.com/getsentry/sentry-go/fiber
Initialize the SDK
Import the base SDK, Fiber integration, and Fiber 2 recovery middleware where you create the application:
"github.com/getsentry/sentry-go" sentryfiber "github.com/getsentry/sentry-go/fiber" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/recover""github.com/getsentry/sentry-go" sentryfiber "github.com/getsentry/sentry-go/fiber" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/recover"
Initialize the SDK before creating the application. Reading the DSN from the environment keeps it out of source control:
err := sentry.Init(sentry.ClientOptions{ Dsn: os.Getenv("SENTRY_DSN"), }) if err != nil { log.Fatal(err) } defer sentry.Flush(5 * time.Second)err := sentry.Init(sentry.ClientOptions{ Dsn: os.Getenv("SENTRY_DSN"), }) if err != nil { log.Fatal(err) } defer sentry.Flush(5 * time.Second)
Set SENTRY_DSN in the environment where the service runs:
export SENTRY_DSN=https://key@bugsink.example/1export SENTRY_DSN=https://key@bugsink.example/1
Add the Fiber middleware
Add Fiber’s recovery middleware before the SDK middleware. The SDK captures the
panic and request, then Repanic lets Fiber’s recovery path produce the usual
HTTP 500 response:
application := fiber.New() application.Use(recover.New()) application.Use(sentryfiber.New(sentryfiber.Options{ Repanic: true, }))application := fiber.New() application.Use(recover.New()) application.Use(sentryfiber.New(sentryfiber.Options{ Repanic: true, }))
Register your routes after the middleware so matching requests run through it.
Trigger a handler panic
There is no Bugsink call inside a handler. To verify the setup, this checkout handler panics with an error value when the requested product is missing:
func checkout(context *fiber.Ctx) error { sku := context.Params("sku") if _, exists := inventory[sku]; !exists { panic(ProductNotFound{SKU: sku}) } return context.JSON(fiber.Map{"reserved": sku}) }func checkout(context *fiber.Ctx) error { sku := context.Params("sku") if _, exists := inventory[sku]; !exists { panic(ProductNotFound{SKU: sku}) } return context.JSON(fiber.Map{"reserved": sku}) }
The error value gives the SDK an exception type and panic stack. A plain string panic becomes a fatal message without a stack by default.
Start Fiber as usual, then request a product that does not exist:
go run . :::bash curl http://127.0.0.1:8080/checkout/fiber-missinggo run . :::bash curl http://127.0.0.1:8080/checkout/fiber-missing
Fiber returns HTTP 500 and the middleware reports the panic.
See the error in Bugsink
Open your Bugsink project and select the new main.ProductNotFound issue. Its
event identifies the failing checkout handler and includes the GET request.
main.ProductNotFound
That’s it: panics from Fiber 2 handlers will now be reported to Bugsink. The handler stays ordinary application code while the middleware adds its panic stack and request context.
For handled errors, messages, tags, structured context, and breadcrumbs, continue with the Go guide.
