Expand description
§ErrSight — Rust client
Captures panics, errors, and log/tracing events and ships them to the ErrSight API from a background thread. Capture is non-blocking; delivery is batched, bounded, and drained on shutdown.
use errsight::{Config, Level};
fn main() {
// Keep the guard alive for the life of the process — dropping it flushes
// and shuts the client down.
let _guard = errsight::init(
Config::builder()
.api_key("elp_your_key")
.environment("production")
.release(env!("CARGO_PKG_VERSION"))
.build(),
);
errsight::configure_scope(|scope| {
scope.set_tag("service", "checkout");
});
if let Err(e) = do_work() {
// `e` is a boxed trait object here, so use the `_dyn` variant.
// For a concrete error type, `capture_error(&err)` also records
// its type name.
errsight::capture_error_dyn(&*e);
}
errsight::capture_message("checkout completed", Level::Info);
}
fn do_work() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}§What gets captured
- Panics — via a hook installed on
init(opt out withConfigBuilder::panic_hook). Captured asfatalwith the panic backtrace. - Errors —
capture_errorrecords the message, type name, thesource()cause chain, and a backtrace (captured at the call site; enable theanyhowfeature and usecapture_anyhowfor the error’s origin backtrace). - Messages —
capture_messagefor arbitrary log lines. log/tracing— optional integrations behind thelogandtracingfeatures.
§Configuration
Build a Config explicitly or seed it from ERRSIGHT_* environment
variables (see Config::from_env). The client is a cheap no-op until a
non-blank API key is present, so capture_* calls are safe to ship
unconditionally.
Re-exports§
pub use integrations::anyhow::capture_anyhow;anyhow
Modules§
- integrations
anyhoworlogortracing - Optional integrations, each behind a cargo feature.
- panic
- Panic capture.
Structs§
- Breadcrumb
- A timestamped activity record leading up to an event. The backend keeps the most recent 50.
- Cause
- An entry in an error’s
source()/ cause chain. The backend surfaces these on the issue detail page as “caused by”. - Client
- The capture/transport client. Held behind an
Arc; cheap to share. - Client
Guard - Guard returned by
init. Flushes and closes the client on drop. - Config
- Immutable client configuration. Build with
Config::builderorConfig::from_env; once handed tocrate::initit lives behind anArcand never changes. - Config
Builder - Fluent builder for
Config. Every setter returnsself; finish withConfigBuilder::build. - Event
- A single error/log event, serialized to the JSON the backend ingests.
- Frame
- One resolved stack frame. Shipped inside
metadata["exception_frames"].in_appframes (your code, not dependencies) are the ones the UI highlights and shows source context for. - Scope
- Ambient context layered onto events: the current user, string tags, and a bounded breadcrumb trail. Cheap to clone (that’s how the hub forks scopes).
- User
- The signed-in user an event is attributed to. All fields optional; the
backend derives a display identifier from
id→email→username.
Enums§
- Level
- An event’s severity. Variants are ordered
Debug < Info < Warning < Error < Fatal, which is what makeslevel >= config.min_levela correct threshold check. - Send
Outcome - What happened to a send attempt. The worker uses this to decide whether to drop the batch, pause, or just log.
Constants§
- VERSION
- The SDK version (
CARGO_PKG_VERSION). Sent in theUser-Agent.
Traits§
- Transport
- Sends a serialized JSON batch to the ingestion endpoint.
Functions§
- add_
breadcrumb - Add a breadcrumb to the current scope.
- capture_
error - Capture a concrete error at
errorlevel, recording its type name, message,source()cause chain, and a backtrace captured at this call site. - capture_
error_ at_ level - Capture a concrete error at an explicit level (e.g. a recovered error you want recorded as a warning).
- capture_
error_ dyn - Like
capture_errorbut for a&dyn Error. The concrete type name isn’t recoverable from a trait object, soexception_classis omitted. - capture_
event - Capture a fully-constructed
Eventfor advanced use. Applies themin_levelgate, config defaults, current scope, andbefore_send. - capture_
message - Capture a free-form message at the given level. Returns the event’s
ingestion_idif it was queued. No-op (returnsNone) when disabled or belowmin_level. - close
- Shut down the global client, draining queued events. Idempotent. Called for
you when the
initguard drops. - configure_
scope - Run
fagainst the current effective scope, mutating in place. If awith_scopeframe is active it’s mutated; otherwise the base scope is. - flush
- Block until queued events are delivered, or
timeoutelapses (default: the configured shutdown timeout). Returns true if the flush was acknowledged. - init
- Initialize the global client and return a guard that flushes and shuts it down when dropped.
- register_
panic_ hook - Install the panic-capturing hook manually. Idempotent; normally done for you
by
init. Useful if you construct aClientwithoutinit, or setpanic_hook(false)and want to install it later. - with_
scope - Push a fresh scope frame (forked from the current effective scope), run
body, then pop — even on panic. Mutations made inside viaconfigure_scopeapply only to the duration of the block.
Type Aliases§
- Before
Send - A
before_sendhook: final-mile filter run on the calling thread before an event is queued. ReturnSome(event)(possibly mutated) to send, orNoneto drop.