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.
Add the crate (and an async runtime) to Cargo.toml:
[dependencies]
errorgap = "0.2"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }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):
let app = axum::Router::new()
.route("/", axum::routing::get(handler))
.layer(errorgap::tower::ErrorgapLayer::new());To report through tracing, add the subscriber layer:
use tracing_subscriber::prelude::*;
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(errorgap::tracing::ErrorgapLayer::default())
.init();Set RUST_BACKTRACE=1 so frames are captured, then:
errorgap::notify(&"Errorgap test error");
errorgap::flush().await;Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:
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.