.. /index

tracing

tracing

The tracing crate (tokio-rs) is the Rust ecosystem's standard for structured diagnostics — logging, distributed tracing, and instrumentation unified under one API. When a level is disabled, overhead is a single atomic load (~1 ns).

Performance tuning

For hot paths, compile-time level gating eliminates all debug/trace instrumentation from the binary entirely:

[dependencies]
tracing = { version = "0.1", features = ["max_level_info"] }

This means zero-cost debug instrumentation: leave tracing::debug! calls in production code and they compile to nothing.

Ecosystem

For library authors

If writing a library crate, instrument with tracing spans and events. Application authors choose their subscriber. This separation of instrumentation from output is tracing's key architectural insight and why it won over log.

Linked from

Sources