Tracing is a framework for instrumenting Rust programs to collect structured, event-based diagnostic information.
Tracing addresses the need for application-level diagnostics in Rust by providing a system to emit and collect trace events through a subscriber architecture. Rather than requiring a specific logging implementation, the framework defines a contract between instrumentation points in code and subscriber implementations that decide how to handle those events. Libraries emit trace data using macros and types from the tracing crate, while applications install a subscriber to actually collect and process that data. This separation allows libraries to remain agnostic about how their diagnostics are consumed, and applications to choose or swap subscribers without modifying library code.
Tracing suits any Rust project needing structured diagnostics beyond simple logging. Applications should use tracing-subscriber to install a subscriber implementation, such as the fmt module which provides reasonable defaults for logging traces to standard output. Libraries should depend only on the tracing crate itself and emit instrumentation without installing a global subscriber, avoiding conflicts with application-level configuration. The framework does not require the Tokio runtime, though it is maintained by the Tokio project. For asynchronous code, the #[instrument] attribute macro is the preferred method for tracing async functions, as it correctly handles the span lifetime relative to future polling rather than future completion.
The project maintains multiple branches for different versions of its core crates, with the main branch serving as the default for crates.io releases. Development activity shows sustained engagement with both the framework's core design and its ecosystem of subscriber implementations. The project provides comprehensive documentation covering the distinction between library and application usage patterns, detailed guidance on tracing asynchronous code, and clear examples of subscriber configuration and instrumentation.