Connect Iris to Bugsink

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

Initialize the SDK

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

"github.com/getsentry/sentry-go"
    sentryiris "github.com/getsentry/sentry-go/iris"
    "github.com/kataras/iris/v12"

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)

Set SENTRY_DSN in the environment where the service runs:

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

Add the Iris middleware

iris.Default() already installs Iris’s recovery middleware. Add the SDK middleware next; it captures the panic and request, then Repanic lets Iris’s recovery path produce the normal HTTP 500 response:

application := iris.Default()
    application.Use(sentryiris.New(sentryiris.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 iris.Context) {
    sku := context.Params().Get("sku")
    if _, exists := inventory[sku]; !exists {
        panic(ProductNotFound{SKU: sku})
    }
    context.JSON(iris.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 Iris as usual, then request a product that does not exist:

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

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