detritus-client
detritus-client is the Rust SDK for sending tracing events and panic artifacts to a Detritus
receiver.
It provides a tracing-subscriber layer for OTLP log export, a process-wide panic hook that
spools crash artifacts without doing network I/O in the hook, and an offline shipper that uploads
pending crash entries on a later launch.
The public API is intentionally small so application code can install Detritus without depending
on receiver internals.
Quick start
Install a zstd-compressed tracing layer on a Tokio runtime, using a Detritus 0.2 receiver:
use ;
use ;
use SecretString;
use ;
use Url;
use Uuid;
let source = SourceId ;
let layer = builder
.endpoint
.compression
.token
.source
.queue_dir
.flush_interval
.build
.unwrap;
let subscriber = default.with;
set_global_default.unwrap;
Install crash capture separately if you want panic artifacts:
use ;
use SecretString;
use json;
use Url;
use Uuid;
let source = SourceId ;
install_panic_hook.unwrap;
Examples
install_layer- install the tracing layer and emit example events.
Run with:
Feature flags
| Feature | Default | Effect |
|---|---|---|
minidump |
yes | Enables native minidump support on non-Android targets through minidumper-child. |
Disabling default features keeps the tracing layer, panic tarball capture, and offline shipper.
Native minidumps are not used on Android; use PanicKind::PanicTarball there.
Offline spooling
The tracing layer writes failed OTLP batches into the configured queue directory.
The panic hook writes crash entries under pending/ and never performs network I/O while handling
a panic.
Call ship_pending_crashes during process startup to upload crash entries and move successful
uploads into sent/.
Each spool directory uses a filesystem lock to avoid concurrent scans by two processes.
Transport options
The log exporter reuses its HTTP/2 connection across batches and offline replay.
HTTPS endpoints use system trust roots. Use LayerBuilder::tls_config with
ClientTlsConfig, Certificate, and Identity (re-exported by detritus) for
a private CA or mutual TLS.
Use .compression(CompressionEncoding::Gzip) or
.compression(CompressionEncoding::Zstd) on the layer builder to compress log
messages. Requests are uncompressed by default; upgraded receivers accept both
algorithms and negotiate compressed responses.
CrashShipper::new(token) creates a reusable uploader with connect/read/total
timeouts of 10/30/60 seconds. Its ship_pending and ship_using_stored_config
methods share the connection pool across scans. CrashShipper::with_client
accepts a Reqwest client configured with custom timeouts, TLS, or proxy settings.
See Offline Shipping
for examples.
Native minidump reporters re-execute the application with its original arguments so command-line configuration is available in the reporter process too.
Compatibility
- Detritus protocol version:
PROTOCOL_VERSION == 1. - Receiver compatibility:
detritus-server0.1 and 0.2 with default uncompressed logs; opt-in log compression requires a 0.2 receiver. - Public OTLP types use Tonic/Prost 0.14; custom HTTP clients use Reqwest 0.13.
- MSRV: Rust 1.88.
- Edition: Rust 2024.
Related crates
- detritus-client - this client SDK.
- detritus-protocol - shared wire types and OTLP log facade.
- detritus-server - receiver binary and embeddable server.
Documentation
License
Licensed under the Apache License, Version 2.0.