Connect Echo to Bugsink

When an Echo 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 Echo’s automatic capture of handler panics. You’ll add the SDK middleware to an existing Echo 5 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

Add the open-source Sentry SDK’s Echo integration to your module. Bugsink accepts the Sentry event protocol, so the SDK can send events directly to your Bugsink project:

go get github.com/getsentry/sentry-go/echo

Initialize the SDK

Import the base SDK and Echo integration where you create the application:

"github.com/getsentry/sentry-go"
    sentryecho "github.com/getsentry/sentry-go/echo"
    "github.com/labstack/echo/v5"
    "github.com/labstack/echo/v5/middleware"

The current integration targets Echo 5. Initialize the SDK before creating the application, and read the DSN from the environment so it stays 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)

Set SENTRY_DSN in the environment where the service runs:

export SENTRY_DSN=https://key@bugsink.example/1

Add the Echo middleware

Add Echo’s recovery middleware before the SDK middleware. The SDK captures the panic and request, then Repanic lets Echo’s recovery path turn it into the usual HTTP 500 response:

application := echo.New()
    application.Use(middleware.Recover())
    application.Use(sentryecho.New(sentryecho.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 *echo.Context) error {
    sku := context.Param("sku")
    if _, exists := inventory[sku]; !exists {
        panic(ProductNotFound{SKU: sku})
    }
    return context.JSON(http.StatusOK, map[string]string{"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 Echo as usual, then request a product that does not exist:

go run .
:::bash
curl http://127.0.0.1:8080/checkout/echo-missing

Echo 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.

Bugsink preview

That’s it: panics from Echo 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.