A framework for instrumenting Rust programs to collect structured, event-based diagnostic information.
Tracing is a framework for instrumenting Rust programs to collect structured, event-based diagnostic information. It provides macros, spans, and events to help developers understand application behavior, performance, and errors in a contextual manner. It solves the problem of opaque logging by enabling rich, typed diagnostics that can be processed by various backends.
Rust developers building applications or libraries who need detailed insights into runtime behavior, especially those working with asynchronous code or distributed systems. It is also valuable for teams implementing observability and monitoring in Rust ecosystems.
Developers choose Tracing for its first-class support for structured diagnostics, seamless async instrumentation, and a rich ecosystem of subscribers and integrations. Its design allows libraries to instrument without imposing a specific logging backend, giving applications full control over how traces are collected and processed.
Application level tracing for Rust.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Events capture typed fields and key-value pairs, as shown in the README's debug! macro example, enabling rich analysis beyond plain text logs.
Provides dedicated tools like Future::instrument and the #[instrument] attribute to correctly trace asynchronous operations, avoiding common pitfalls with span guards in async blocks.
Separation of concerns allows libraries to instrument without imposing backends, while applications can choose from built-in (e.g., fmt, OpenTelemetry) or third-party subscribers for processing traces.
The #[instrument] attribute automatically instruments functions, reducing boilerplate by capturing parameters as span fields, as demonstrated in the library usage example.
The README explicitly warns that incorrect span usage in async code can lead to confusing output, requiring careful handling with Future::instrument to avoid spans remaining entered indefinitely.
Several related crates like tracing-macros and tracing-serde are marked as 'unstable' or 'pre-release', leading to potential breaking changes and fragmentation for adopters.
Instrumentation with spans and subscribers introduces runtime cost that may be non-negligible for latency-sensitive applications, though this is a trade-off for richer diagnostics.