Expand description
rootle’s opt-in diagnostic session sink: one private, bounded JSONL file per session, written by a dedicated thread.
Producers never perform file I/O, never wait for the writer, and never
wait for queue capacity — a full queue, an oversize record, a cap or a
writer failure is an explicit capture failure surfaced through
take_failure and TraceSession::finish, never a silent drop.
Only the writer thread touches the file, flushing every batch it
receives, and every file it closes ends with a terminal trace_end
marker stating whether the capture is complete and why. A capped,
failed, panicked or abandoned capture can never look complete, and a
crash that prevents the marker leaves its absence as the verdict.
Envelopes carry schema_version, the writer-owned seq, elapsed_us,
a thread label, the thread’s optional operation_id correlation, the
event kind and producer fields; sequence and timestamps agree with
admission order under concurrent producers.
Metadata capture is diagnostic, not anonymous: paths, repository
identities, revisions and timing can still be sensitive — inspect files
before sharing. Nothing here ever prints to stdout/stderr; the only
outputs are the file and explicit Results.
Structs§
- Limits
- Bounded capture: total bytes, total events, per-record bytes.
- Operation
Id - Correlation identity linking a job’s lifecycle records across threads. Serializes as its bare number inside envelopes and producer payloads.
- Trace
Options - Startup controls for
crate::start. - Trace
Session - The owning lifetime of a trace.
TraceSession::finishis the explicit reporting boundary;Dropstill finalizes the file durably, but as an abandoned capture, never a complete one.
Enums§
- Content
Policy - What producer payloads may carry.
- Event
Kind - The closed event vocabulary. Payloads are producer-defined
fields; the kind only fixes the category so files stay joinable across crates. - Trace
Error
Constants§
- MAX_
CAPTURE_ BYTES - Hard upper bounds a capture may use. They exist so a runaway producer
cannot fill the disk;
startrefuses anything outside them. - MAX_
CAPTURE_ EVENTS - MAX_
RECORD_ BYTES - SCHEMA_
VERSION - Envelope schema version for every rootle session trace.
- TERMINAL_
RESERVE - The writer always reserves this much of the byte budget for the terminal marker, so a capture that hits its cap still ends legibly.
Functions§
- capture_
content - Whether
ContentPolicy::Fullwas selected: producers gate sensitive input/UI text and provider stderr on this. - enabled
- in_
operation - Run
workwithidas this thread’s correlation identity, restoring whatever was installed before — including on panic unwind, so a panicking worker cannot leak its identity into unrelated records. - mark_
incomplete - A producer could not observe an explicitly requested surface. Preserve the failure verdict and stop admission rather than writing a complete-looking log.
- operation_
id - Allocate a fresh correlation identity, but only while a trace is
enabled. Returns
None(and allocates nothing) for disabled capture; pass theOptionstraight through toin_operation. - panic_
record - Best-effort panic capture, safe to call from a panic hook.
- record
- record_
with - Lazy producer: no payload construction or allocation when disabled.
- start
- Start the process’s single trace session, creating
pathexclusively. - take_
failure - Report a capture failure once (for a status line);
TraceSession::finishstill returns it as an error.