tracing-wide
[!CAUTION] This is NOT an official tokio / tokio-tracing product or associated crate.
This crate enables wide events for tokio tracing. It enables additional functionality for tracing but does not implement / replace it.
Wide events are built as one struct per event, carrying every observability-relevant field for that event. The message text of such an event stays static; all variance lives in typed fields.
The core of the crate is no_std and runs in WASM.
Highlights include:
- Typed wide events: one struct per event via
#[message];event!checks required fields, fills unsetOptions from the ambient span, fans out to subscribers, then records totracingat the type's level. - Flexible serialization: none,
serde, orfacet; opt-in per type, never a bound onMessage. - Catalogue: every message a binary can emit, auto-registered and walkable,
including messages defined in libraries or member crates as long as they're
linked in. The catalogue is representation-agnostic - it's plain data you can
serialize to any format (or none): a manifest (
msgis the unique join key) that non-technical stakeholders can reason about, with duplicate keys detectable in a test. - Automatic origin: crate / module / file / line / column captured per message, object-safe and drift-free.
- Ambient autocapture:
Optionfields fill at emit time from same-named fields on the surroundingtracing::instrumentspan, across crate boundaries. - Subscribers: each event reaches registered sinks as a typed
&dyn Messagebefore thetracinghandoff; stay generic via accessors or downcast. - Routing: on static
tags()with no downcast, or (withfacet) on live field values read by name.
Getting started
use ;
// One struct per event: the message text is static, the fields carry the variance.
// Emit it: builds the struct and records it to `tracing` at the type's level.
event!;
Examples
catalogue-facet: dump the catalogue as YAML viafacet-yamlcatalogue-serde: dump the catalogue as YAML viaserdeinstrument: fillOptionfields from surrounding spanssubscriber-facet: filter on a live field value viaas_facetsubscriber-serde: forward each event as JSON viaas_serializesubscriber: a generic line printer plus a typed downcasting sinktags: route messages by tag with no downcast