Server SDK

Error monitoring for Rust

A builder-configured client with a Tower layer for axum and tonic, a tracing subscriber layer, and a manual `notify` call. Async-first, with explicit flush and shutdown.

Frameworks axum · Actix · tonic · tracingRequires Rust 1.75+Package errorgapSource ↗Package ↗Agent guide ↗
Install

Install

Add the crate (and an async runtime) to Cargo.toml:

toml
[dependencies]
errorgap = "0.2"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
Configure

Configure

rust
use errorgap::Configuration;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    errorgap::init(
        Configuration::builder()
            .endpoint(std::env::var("ERRORGAP_ENDPOINT")?)
            .project_slug(std::env::var("ERRORGAP_PROJECT_SLUG")?)
            .api_key(std::env::var("ERRORGAP_API_KEY")?)
            .build()?,
    )?;

    run_app().await?;

    errorgap::flush().await;
    errorgap::shutdown().await;
    Ok(())
}

For axum or tonic, add the Tower layer (default feature):

rust
let app = axum::Router::new()
    .route("/", axum::routing::get(handler))
    .layer(errorgap::tower::ErrorgapLayer::new());

To report through tracing, add the subscriber layer:

rust
use tracing_subscriber::prelude::*;

tracing_subscriber::registry()
    .with(tracing_subscriber::fmt::layer())
    .with(errorgap::tracing::ErrorgapLayer::default())
    .init();
Keep the key in an environment variable (or your framework's secret store) — never commit it to source control.
Trigger a test error

Trigger a test error

Set RUST_BACKTRACE=1 so frames are captured, then:

rust
errorgap::notify(&"Errorgap test error");
errorgap::flush().await;
Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'

A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.

Next: the full ingestion API, or browse every SDK.