70 %

Toast is in Beta!Learn more →

Chris Biscardi

Distributed Tracing in Rust

If you want structured instrumentation at the application level (not the infrastructure level), the crate to use is tracing.

The tracing project is a collection of crates that combine together to handle the collection, serialization, and distribution of structured instrumentation data from your Rust libraries and binaries all the way to stdout or an [[Observability]] product like Honeycomb.

Event and Spans

Tracing's core user facing primitives are Events and Spans. Events and spans are both collections of fields.

At a rough level, you can think of events and spans as a JSON object, with keys and values, but in reality they are not JSON.

The key difference between events and spans is that spans are used for operations that take some amount of time while events are used for instantaneous actions.

You can think of events as spans with a duration of 0 with no children, which is how they will be shown in distributed tracing systems like honeycomb

honeycomb spans vs traces