Connect Actix Web to Bugsink

The Actix Web integration reports server errors from the normal request lifecycle and adds the request that produced them. You keep returning Actix responses in the usual way; the middleware handles the reporting.

This guide adds Bugsink to an existing Actix Web application and returns a deliberate error from one handler so you can see the complete result.

To follow along, create a Bugsink project and copy its DSN. The quickstart guide shows where to find it.

Install the SDK and Actix integration

Add the open-source Sentry Rust SDK and its Actix Web middleware. Bugsink accepts the Sentry event protocol, so both crates can report directly to your Bugsink project:

cargo add sentry --no-default-features \
    --features backtrace,contexts,panic,reqwest,rustls
cargo add sentry-actix --no-default-features

Configure your DSN

Initialize the SDK before creating Actix’s runtime. This lets runtime threads inherit the configured hub; keeping the guard alive also lets queued events drain during shutdown:

let _sentry = sentry::init((
    env::var("SENTRY_DSN").unwrap_or_default(),
    sentry::ClientOptions::new().release("inventory-actix-web@0.1.0"),
));

Set SENTRY_DSN to the DSN shown by your Bugsink project when you start the server:

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

Use a normal fn main() and construct the runtime after initialization rather than using #[actix_web::main]:

fn main() -> std::io::Result<()> {
    let _sentry = sentry::init(env::var("SENTRY_DSN").unwrap_or_default());

    actix_web::rt::System::new().block_on(async {
        // Build and run the server here.
        Ok(())
    })
}

Add the middleware

Wrap your App with sentry_actix::Sentry. The middleware creates a separate SDK hub for each request, attaches its method, URL, headers, and route, and reports server errors returned through Actix:

App::new()
    .wrap(sentry_actix::Sentry::new())
    .service(index)
    .service(checkout)

Return a test error

Temporarily return an error from a handler. This example implements Actix’s ResponseError for ProductNotFound, so the application still controls the status and response body while the middleware sees a server error:

return Err(ProductNotFound {
    sku: sku.into_inner(),
});

Start the application and request the failing path:

cargo run --locked
curl --include http://127.0.0.1:8080/checkout/actix-missing

The application responds with HTTP 500 and its normal error text:

Product actix-missing is not in inventory

See the request error in Bugsink

Open your Bugsink project. The new ProductNotFound issue contains the error, the concrete request, and the normalized GET /checkout/{sku} route.

Bugsink preview

That’s it: server errors returned through Actix are now reported with their request while your handlers retain control of the response.

The middleware reports errors that reach Actix’s response machinery with a 5xx status. It does not turn ordinary 4xx responses into Bugsink issues. Explicit events captured inside a handler use the same request-local hub and therefore receive the request context too.

The resulting event contains the method, URL, normalized route, error type, and error value. The middleware does not change the response returned by the handler.

Limitations

The returned ProductNotFound carries its type, value, request, and route, but does not include an application stack in this setup. Automatic capture of panics or errors handled by custom outer middleware depends on where those failures enter Actix’s response machinery.

For manual capture, tags, structured context, breadcrumbs, messages, logging, release naming, and shutdown behavior, continue with the main Rust guide. It covers the SDK options shared by Actix Web and other Rust applications.