Expand description
Span collection for the tracing ecosystem.
tracing is fire and forget: a span goes to the subscriber and nothing
comes back. That is right for logs and wrong for the three things that want
to read a unit of work whole: an error page showing what this request did
before it failed, a test asserting what a body actually called, and a
header reporting per-step cost with no collector running.
This crate is a layer that keeps them. A span marked as a root opens a trace, every span under it joins, and closing the root finishes the trace, offers it to whoever is listening and pushes it into a ring of recent ones.
It knows nothing about requests. A web server calls its root a request, a queue worker calls it a job, a build calls it a compilation.
ⓘ
let (layer, traces) = fibre_tracing::layer();
tracing_subscriber::registry().with(fibre_logging_layer).with(layer).init();
#[tracing::instrument(fields(fibre.root = true))]
fn handle() { ... }
traces.current(); // inside the root, what has happened so far
traces.recent(50); // the last finished onesStructs§
- Span
- One span of a trace, as it finished.
- Trace
- One unit of work: the root and everything that happened inside it, in the order the spans opened.
- Trace
Layer - Traces
- The handle a caller reads through, and what the layer writes into.
Enums§
- Value
- A field value, in the shapes
tracingrecords.
Constants§
- DEFAULT_
RING - How many finished traces the ring keeps by default.
- OUTCOME_
FIELD - The field naming the outcome a span finished with, when it says.
- ROOT_
FIELD - The field that marks a span as the top of a trace. Anything under it joins.