mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 07:20:35 +00:00

## Motivation As discussed in #308, there are a large number of crates in this repository, which can be confusing for users and can increase the maintainance burden for maintainers. Also, the `tracing-fmt` and `tracing-subscriber` crates both contain filtering implementations with similar behaviour and APIs, but `tracing-subscriber`'s filter module offers more advanced features (filtering on field values), and is usable with any subscriber implementation. Two separate filter implementations also has the potential to be confusing for users. ## Solution This branch moves most of the code from `tracing-fmt` into a module in `tracing-subscriber`, and changes the `tracing-fmt` builder APIs to use the `Filter` type in `tracing-subscriber`. The `tracing-subscriber/fmt` feature flag can be used to disable the formatting subscriber when it is not used. The `tracing-fmt` crate has been updated to re-export the APIs from `tracing-subscriber`, and marked as deprecated. Once we've published a new version of `tracing-subscriber` with the format APIs, we can publish a final release of `tracing-fmt` that will update the documentation & mark all APIs as deprecated, so that users know to move to the `tracing-subscriber` crate. Refs: #308 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
tracing-attributes
Macro attributes for application-level tracing.
Overview
tracing
is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. This crate provides the
#[instrument]
attribute for automatically instrumenting functions using
tracing
.
Note that this macro is also re-exported by the main tracing
crate.
Usage
First, add this to your Cargo.toml
:
[dependencies]
tracing-attributes = "0.1.2"
This crate provides the #[instrument]
attribute for instrumenting a function
with a tracing
span. For example:
use tracing_attributes::instrument;
#[instrument]
pub fn my_function(my_arg: usize) {
// ...
}
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.