oluso
AI-powered error monitoring for Rust applications: automatic panic reporting, breadcrumb tracking, and intelligent error grouping.
Installation
Requires an async runtime -- built on tokio and reqwest.
Usage
use ;
async
async
install_panic_hook reports any panic as a critical error (with a full backtrace, and without replacing Rust's normal "thread panicked at ..." stderr output) and needs no further wiring, as long as the panic happens with a Tokio runtime current -- see Panics below for the one case it can't cover.
Breadcrumbs & User Context
use ;
client.set_user_context;
client.add_breadcrumb;
if let Err = do_checkout.await
Request-scoped context
A single process handles many concurrent requests, so a plain global breadcrumb list would mix up breadcrumbs from different requests. Wrap each unit of work (a request handler, typically) in [Client::run_in_scope] to isolate it:
client
.run_in_scope
.await;
This is built on [tokio::task_local!], which -- unlike Node's AsyncLocalStorage -- only follows a single top-level task's .awaits. It does not propagate into a tokio::spawned task; re-enter the scope explicitly inside spawned work if it should still report against the same request.
Calling add_breadcrumb/set_user_context/set_custom_context outside run_in_scope (e.g. at startup) falls back to a single shared store rather than silently dropping the data -- fine for a one-off script, not meant for concurrent request handling.
Panics
install_panic_hook reports a panic by spawning onto whatever Tokio runtime is current at the moment it happens (tokio::runtime::Handle::try_current()), since panic hooks are synchronous but reporting needs an .await. That covers the overwhelmingly common case -- a panic inside a request handler on an async web framework -- but if a panic happens on a plain std::thread with no Tokio runtime around it, there's nothing to spawn the send onto, so it's logged to stderr only, not reported.
Manual Reporting
use Severity;
// A concrete error type: reports as its own type name (`std::io::Error`, etc).
client.capture_error.await;
// A type-erased error (`Box<dyn Error>`, `anyhow::Error`, ...): the concrete
// type name is already gone by the time you have one of these, so supply it.
client.capture_dyn_error.await;
// Not tied to a Rust error value at all.
client.capture_message.await;
Attaching a request
There's no framework-specific RequestContext builder in this crate -- construct one from whatever your framework hands you and attach it:
use RequestContext;
client
.capture_error_with_request
.await;
Advanced Configuration
use ;
use Duration;
let options = new
.endpoint
.environment
.default_severity
.max_breadcrumbs
.max_errors_per_minute
.timeout
.sensitive_keys
.should_report;
Monitor outcomes, heartbeats, and workflows
Create the matching monitor under Project → Monitors, then use the existing client:
use ;
use json;
client
.heartbeat
.await?;
let mut assertion = new;
assertion.expected = json!;
assertion.actual = json!;
assertion.duration_ms = Some;
assertion.context = json!;
client.assert_outcome.await?;
let mut deployment = client.workflow;
deployment.checkpoint.await?;
deployment.checkpoint.await?;
deployment.checkpoint.await?;
deployment.complete.await?;
Use MonitorReference::by_id("...") for an immutable reference. The heartbeat URL is a monitor-specific secret shown once at creation. Evidence is recursively redacted and bounded; transient failures retry with exponential backoff, permanent 4xx responses do not, and the project connection string is never attached to a heartbeat request.
Error Report Structure
Reports sent to the API include:
- Metadata: Title, message, stack trace (for panics), severity, tags.
- Context: Request details when attached, server details (hostname, OS, arch, pid).
- History: Breadcrumbs leading up to the error.
- Identification: Fingerprint for deduplication and user ID.
License
MIT