Skip to main content

Crate fibre_tracing

Crate fibre_tracing 

Source
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 ones

Structs§

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.
TraceLayer
Traces
The handle a caller reads through, and what the layer writes into.

Enums§

Value
A field value, in the shapes tracing records.

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.

Functions§

layer
The layer and the handle to read it through. Compose the layer into a registry beside whatever else is listening.
with_ring
layer with the ring sized. Zero keeps nothing, which is what a process that only exports wants.