Rust with AllStak
Add error tracking and tracing to your Rust service with the AllStak crate. (The README install line still shows 0.1; the published crate is 0.2.0.)
- Source repository:
- AllStak/allstak-rust
- Source README:
- README.md
- SDK version:
- 0.2.0
- Installation source:
- crates.io
- Last verified:
- 2026-05-31
Installation
Add the dependency to Cargo.toml (with optional feature flags).
[dependencies]
allstak = { version = "0.2", features = ["tracing", "axum"] }Configuration
Initialize once and hold the returned guard for the lifetime of the program.
let _guard = allstak::init(allstak::ClientOptions {
api_key: std::env::var("ALLSTAK_API_KEY").unwrap_or_default(),
host: "https://api.allstak.sa".into(),
release: Some("[email protected]".into()),
environment: Some("production".into()),
..Default::default()
});Basic example
Or initialize from the environment with allstak::init_from_env().
let _guard = allstak::init_from_env();Capturing errors
Capture errors and messages.
allstak::capture_message("cache warmed", Level::Info);
let err = std::io::Error::new(std::io::ErrorKind::Other, "disk full");
allstak::capture_error(&err);Tracking requests
Use the framework layer/middleware (feature-gated): axum AllstakLayer, actix Allstak wrap, and reqwest-middleware for outbound. They record inbound/outbound requests and continue the distributed trace.
let app: Router = Router::new()
.route("/users/:id", get(|| async { "ok" }))
.layer(AllstakLayer::new());Best practices
- Keep the _guard alive for the program's lifetime.
- Enable only the framework features you use (axum/actix/tracing/…).
- Provide the API key via ALLSTAK_API_KEY.