Utilities for enriching error handling with
tracing is a framework for instrumenting Rust programs to collect
scoped, structured, and async-aware diagnostics. This crate provides
tracing instrumentation and Rust error handling. It
enables enriching error types with diagnostic information from
span contexts, formatting those contexts when errors are displayed, and
tracing events when errors occur.
The crate provides the following:
Note: This crate is currently experimental.
Compiler support: requires
tracing-error provides the
SpanTrace type, which captures the current
tracing span context when it is constructed and allows it to be displayed
at a later time.
use ; use SpanTrace;
This crate also provides
TracedError, for attaching a
SpanTrace to an
existing error. The easiest way to wrap errors in
TracedError is to either
InstrumentError traits or the
use *; read_to_string.in_current_span?;
For example, here is how one might print the errors but specialize the
printing when the error is a placeholder for a wrapping
use Error; use ExtractSpanTrace as _;
Whereas here, we can still display the content of the
any special casing by simply printing all errors in our error chain.
use ErrorLayer; use *;
traced-error- Enables the
TracedErrortype and related traits
Supported Rust Versions
Tracing is built against the latest stable release. The minimum supported version is 1.42. The current Tracing version is not guaranteed to build on Rust versions earlier than the minimum supported version.
Tracing follows the same compiler support policies as the rest of the Tokio project. The current stable Rust compiler and the three most recent minor versions before it will always be supported. For example, if the current stable compiler version is 1.45, the minimum supported version will not be increased past 1.42, three minor versions prior. Increasing the minimum supported compiler version is not considered a semver breaking change as long as doing so complies with this policy.
In addition to this repository, here are also several third-party crates which
are not maintained by the
tokio project. These include:
color-spantraceprovides a formatter for rendering SpanTrace in the style of
color-eyreprovides a customized version of
eyre::Reportfor capturing span traces and backtraces with new errors and pretty printing them in error reports.
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tracing by you, shall be licensed as MIT, without any additional terms or conditions.