Honeybadger Rust SDK

The official Honeybadger SDK for Rust is here in version 0.5.0 of the honeybadger crate. It reports errors and panics from your Rust apps, and sends custom events you can query, chart, and alert on.

Versions 0.1–0.2 of honeybadger were a community crate by Niel Drummond, who agreed to let us use the name for the official SDK. Thank you, Niel! The official SDK has a different API, so if you're upgrading from the community crate, you'll need to update your code.

To get started, add honeybadger to Cargo.toml, along with serde_json for context and event values. The SDK needs Rust 1.88 or newer.

[dependencies]
honeybadger = "0.5"
serde_json = "1"

Then call honeybadger::init near the top of main. If your account is in the EU, follow the EU setup in the Rust guide.

fn main() {
    let _guard = honeybadger::init(
        honeybadger::Config::builder()
            .api_key("PROJECT_API_KEY") // or set HONEYBADGER_API_KEY
            .env("production")
            .build()
            .unwrap(),
    )
    .unwrap();

    if let Err(e) = do_work() {
        honeybadger::notify(&e);
    }
}

Once initialized, the SDK reports panics automatically, including under panic = "abort". To report an error you've handled, pass it to honeybadger::notify. The report includes the error's causes and a backtrace. Honeybadger sends error reports in the background, so notify doesn't wait on the network, and you don't need an async runtime.

You can also add context, breadcrumbs, and tags to error reports, and redact sensitive values with filter_keys.

To send a custom event to Honeybadger, call honeybadger::event with a name and a JSON payload. Events are batched and sent in the background.

use serde_json::json;

honeybadger::event("user.created", json!({ "user_id": 7, "plan": "pro" }));

Follow the Rust guide to configure the SDK, and check out the working examples on GitHub.

Back to changelog

Try Honeybadger for FREE

Honeybadger is full-stack application monitoring that helps developers move fast and fix things. Get set up in minutes and check monitoring off your to-do list.

Easy 5-minute setup — No credit card required