Application-level tracing and structured diagnostics for Rust
open sourceMITfree
tracing is a framework for instrumenting Rust programs to collect structured, event-based diagnostics: spans that record a period of work and events within them, with typed fields, which suits asynchronous code where one task's logs interleave with others'. Libraries record spans and events with its macros, and an application picks a subscriber to collect them: tracing-subscriber logs them with sensible defaults and also takes messages from log-instrumented crates, and tracing-appender writes them to files without blocking. It's maintained by the Tokio project but doesn't need the Tokio runtime.
Problems it solves
- add structured logging with context to my async Rust service
- see which async task a log line came from when tasks run concurrently
- time how long each step of a request takes in my Rust code
- write my Rust application's logs to rolling files without blocking
Features
- spans and events with structured, typed fields
- instrumentation macros, including #[instrument]
- pluggable subscribers to collect and export traces
- tracing-subscriber for formatted logging
- consumes log crate messages
- tracing-appender for non-blocking file logging
- works without the Tokio runtime
Capabilities
| Takes plugins | plan not known |
|---|
Alternatives
The same job
These do what tracing does.
- log A lightweight logging facade for Rust