Skip to main content

Crate allstak

Crate allstak 

Source
Expand description

§allstak

Native Rust SDK for the AllStak observability platform. It implements the AllStak ingest wire protocol directly — error monitoring, performance tracing, structured logging and release-health sessions — with a familiar Hub / Scope / Client model.

§Quick start

let _guard = allstak::init(allstak::ClientOptions {
    api_key: "<your-key>".into(),
    release: Some("my-service@1.0.0".into()),
    environment: Some("production".into()),
    ..Default::default()
});

allstak::configure_scope(|scope| {
    scope.set_tag("region", "eu-central");
});

allstak::capture_message("service started", allstak::Level::Info);
// `_guard` flushes pending events when it drops.

For the least possible configuration, init_from_env reads options from the environment and installs the panic hook plus (on the tracing feature) the global tracing subscriber so logs, spans and database queries are captured automatically.

§Features

  • panic (default): install a global panic hook that captures crashes.
  • tracing: a tracing_subscriber layer bridging events and spans.
  • axum: a tower layer that records inbound requests and handler errors.
  • actix: actix-web middleware with the same behavior.
  • reqwest-middleware: outbound HTTP auto-instrumentation — an http.client span, trace-context header injection, and an outbound HTTP request record, per call, with no per-call code.
  • sqlx: database auto-instrumentation — a tracing layer that turns sqlx’s query telemetry into DB query records tied to the active span.
  • anyhow: capture an anyhow::Error chain.

Re-exports§

pub use db::capture_query as capture_db_query;
pub use db::normalize_query;
pub use db::query_hash;
pub use db::query_type;
pub use diagnostics::Diagnostics;
pub use options::ClientOptions;
pub use options::IntoClientOptions;
pub use options::SessionMode;
pub use options::DEFAULT_HOST;
pub use protocol::Breadcrumb;
pub use protocol::ErrorEvent;
pub use protocol::Frame;
pub use protocol::Heartbeat;
pub use protocol::Level;
pub use protocol::RequestContext;
pub use protocol::SessionStatus;
pub use protocol::User;
pub use integrations::reqwest::instrumented_client as instrumented_http_client;
pub use integrations::reqwest::instrumented_client_from as instrumented_http_client_from;
pub use integrations::reqwest::AllstakHttpMiddleware;

Modules§

backtrace
Backtrace capture and in-app frame marking.
db
Database query helpers: statement normalization, fingerprinting, and a convenience for recording a DbQueryRecord tied to the active span.
diagnostics
Privacy-safe SDK diagnostics.
envelope
Envelope: a typed unit of work the transport delivers to a single ingest endpoint. Each variant carries an already-serialized JSON body plus its data category (used for rate-limit accounting).
integrations
Feature-gated framework and logging integrations.
options
Client configuration.
panic
Panic integration.
propagation
Distributed-trace propagation header parsing and stamping.
protocol
Wire-protocol types for the AllStak ingest API.
scrub
Value-pattern PII scrubbing.
transport
Transport layer.
util
Small helpers: timestamps, ids, and the SDK identity constants.

Structs§

Client
A bound client: configuration + transport + integration pipeline.
ClientInitGuard
RAII guard returned by init. Flushes pending events and ends the active application session when dropped.
Hub
Central manager binding a Client to a stack of Scopes.
Scope
Contextual data applied to events captured while it is active.
ScopeGuard
Pops the top scope off its hub when dropped.
Session
A single in-flight release-health session.
Span
An in-flight span. On Span::finish (or drop) it is sent to the active client as a span record.

Traits§

Integration
An installable extension that participates in the event pipeline.

Functions§

add_breadcrumb
Add a breadcrumb to the current scope.
capture_anyhow
Capture an anyhow::Error, walking its chain into the message and attaching the formatted backtrace lines.
capture_error
Capture a std::error::Error.
capture_event
Capture a pre-built error event.
capture_message
Capture a message at level.
configure_scope
Mutate the current scope.
end_session
End the active session.
end_session_with_status
End the active session with an explicit status.
event_from_error
Build an event from a std::error::Error without capturing it.
flush
Flush the current hub’s transport queue.
get_diagnostics
Privacy-safe SDK diagnostics. Contains counters and queue sizes only.
init
Initialize the SDK and bind a client to the main hub.
init_from_env
Zero-config initialization from the process environment.
last_event_id
The last accepted event id on any hub.
set_user
Set the active user on the current scope.
start_session
Start a release-health session on the current hub.
start_span
Start a standalone span. Convenience for Span::transaction.
start_transaction
Start a root transaction. Convenience for Span::transaction.
with_scope
Run body with a temporary scope configured by scope_fn.