| 1 |
![Tracing — Structured, application-level diagnostics][splash] |
| 2 |
|
| 3 |
[splash]: https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/splash.svg |
| 4 |
|
| 5 |
# tracing-attributes |
| 6 |
|
| 7 |
Macro attributes for application-level tracing. |
| 8 |
|
| 9 |
[![Crates.io][crates-badge]][crates-url] |
| 10 |
[![Documentation][docs-badge]][docs-url] |
| 11 |
[![Documentation (master)][docs-master-badge]][docs-master-url] |
| 12 |
[![MIT licensed][mit-badge]][mit-url] |
| 13 |
[![Build Status][actions-badge]][actions-url] |
| 14 |
[![Discord chat][discord-badge]][discord-url] |
| 15 |
|
| 16 |
[Documentation][docs-url] | [Chat][discord-url] |
| 17 |
|
| 18 |
[crates-badge]: https://img.shields.io/crates/v/tracing-attributes.svg |
| 19 |
[crates-url]: https://crates.io/crates/tracing-attributes |
| 20 |
[docs-badge]: https://docs.rs/tracing-attributes/badge.svg |
| 21 |
[docs-url]: https://docs.rs/tracing-attributes/0.1.23 |
| 22 |
[docs-master-badge]: https://img.shields.io/badge/docs-master-blue |
| 23 |
[docs-master-url]: https://tracing-rs.netlify.com/tracing_attributes |
| 24 |
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg |
| 25 |
[mit-url]: LICENSE |
| 26 |
[actions-badge]: https://github.com/tokio-rs/tracing/workflows/CI/badge.svg |
| 27 |
[actions-url]:https://github.com/tokio-rs/tracing/actions?query=workflow%3ACI |
| 28 |
[discord-badge]: https://img.shields.io/discord/500028886025895936?logo=discord&label=discord&logoColor=white |
| 29 |
[discord-url]: https://discord.gg/EeF3cQw |
| 30 |
|
| 31 |
## Overview |
| 32 |
|
| 33 |
[`tracing`] is a framework for instrumenting Rust programs to collect |
| 34 |
structured, event-based diagnostic information. This crate provides the |
| 35 |
`#[instrument]` attribute for automatically instrumenting functions using |
| 36 |
`tracing`. |
| 37 |
|
| 38 |
Note that this macro is also re-exported by the main `tracing` crate. |
| 39 |
|
| 40 |
*Compiler support: [requires `rustc` 1.56+][msrv]* |
| 41 |
|
| 42 |
[msrv]: #supported-rust-versions |
| 43 |
|
| 44 |
## Usage |
| 45 |
|
| 46 |
First, add this to your `Cargo.toml`: |
| 47 |
|
| 48 |
```toml |
| 49 |
[dependencies] |
| 50 |
tracing-attributes = "0.1.23" |
| 51 |
``` |
| 52 |
|
| 53 |
|
| 54 |
This crate provides the `#[instrument]` attribute for instrumenting a function |
| 55 |
with a `tracing` [span]. For example: |
| 56 |
|
| 57 |
```rust |
| 58 |
use tracing_attributes::instrument; |
| 59 |
|
| 60 |
#[instrument] |
| 61 |
pub fn my_function(my_arg: usize) { |
| 62 |
// ... |
| 63 |
} |
| 64 |
``` |
| 65 |
|
| 66 |
[`tracing`]: https://crates.io/crates/tracing |
| 67 |
[span]: https://docs.rs/tracing/latest/tracing/span/index.html |
| 68 |
|
| 69 |
## Supported Rust Versions |
| 70 |
|
| 71 |
Tracing is built against the latest stable release. The minimum supported |
| 72 |
version is 1.56. The current Tracing version is not guaranteed to build on Rust |
| 73 |
versions earlier than the minimum supported version. |
| 74 |
|
| 75 |
Tracing follows the same compiler support policies as the rest of the Tokio |
| 76 |
project. The current stable Rust compiler and the three most recent minor |
| 77 |
versions before it will always be supported. For example, if the current stable |
| 78 |
compiler version is 1.69, the minimum supported version will not be increased |
| 79 |
past 1.66, three minor versions prior. Increasing the minimum supported compiler |
| 80 |
version is not considered a semver breaking change as long as doing so complies |
| 81 |
with this policy. |
| 82 |
|
| 83 |
## License |
| 84 |
|
| 85 |
This project is licensed under the [MIT license](LICENSE). |
| 86 |
|
| 87 |
### Contribution |
| 88 |
|
| 89 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 90 |
for inclusion in Tokio by you, shall be licensed as MIT, without any additional |
| 91 |
terms or conditions. |