Gracefully Integrating Sentry-Go Middleware into Fiber v3 Projects



This content originally appeared on DEV Community and was authored by Truman

Gracefully Integrating Sentry-Go Middleware into Fiber v3 Projects

This article explains how to integrate error monitoring functionality using Sentry-Go v0.34.1 in projects built with Go 1.24.3 and Fiber v3. We’ll demonstrate how to adapt and rewrite the sentryfiber middleware to support Fiber v3 and enhance flexibility with configurable path skipping (SkipPaths).

Technology Stack

  • Go Version: 1.24.3
  • Fiber Version: v3
  • Sentry-Go Version: 0.34.1

Currently, the official sentryfiber middleware supports only Fiber v2. Given our project’s upgrade to Fiber v3, middleware adaptation and rewriting are necessary.

Overview of Custom Middleware Features

The rewritten middleware introduces these key enhancements:

  • Fiber v3 Compatibility: Ensures compatibility with all Fiber v3 APIs.
  • SkipPaths Configuration: Allows specific request paths to be ignored, reducing redundant or unnecessary logging.
  • Customizable Options: Includes common configurations such as Repanic, WaitForDelivery, and Timeout, providing a flexible integration experience.

Implementation

Here is the key implementation code:

type Options struct {
    Repanic         bool
    WaitForDelivery bool
    Timeout         time.Duration
    SkipPaths       []string
}

func New(opts Options) fiber.Handler {
    if opts.Timeout == 0 {
        opts.Timeout = 2 * time.Second
    }
    skip := opts.SkipPaths

    return func(c fiber.Ctx) error {
        if len(skip) > 0 {
            path := c.Path()
            for


This content originally appeared on DEV Community and was authored by Truman