blob: f14dbb62be8fde5d5e14f4cee3e885b5d650bd45 [file] [log] [blame] [view]
Fedor Tsarevfa35e1e2023-03-24 09:59:21 +01001![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
7Macro 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
Andrew Walbran6d525572023-11-17 16:00:02 +000021[docs-url]: https://docs.rs/tracing-attributes/0.1.26
Fedor Tsarevfa35e1e2023-03-24 09:59:21 +010022[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
34structured, event-based diagnostic information. This crate provides the
35`#[instrument]` attribute for automatically instrumenting functions using
36`tracing`.
37
38Note that this macro is also re-exported by the main `tracing` crate.
39
Andrew Walbran6d525572023-11-17 16:00:02 +000040*Compiler support: [requires `rustc` 1.56+][msrv]*
Fedor Tsarevfa35e1e2023-03-24 09:59:21 +010041
42[msrv]: #supported-rust-versions
43
44## Usage
45
46First, add this to your `Cargo.toml`:
47
48```toml
49[dependencies]
Andrew Walbran6d525572023-11-17 16:00:02 +000050tracing-attributes = "0.1.26"
Fedor Tsarevfa35e1e2023-03-24 09:59:21 +010051```
52
53
54This crate provides the `#[instrument]` attribute for instrumenting a function
55with a `tracing` [span]. For example:
56
57```rust
58use tracing_attributes::instrument;
59
60#[instrument]
61pub 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
71Tracing is built against the latest stable release. The minimum supported
Andrew Walbran6d525572023-11-17 16:00:02 +000072version is 1.56. The current Tracing version is not guaranteed to build on Rust
Fedor Tsarevfa35e1e2023-03-24 09:59:21 +010073versions earlier than the minimum supported version.
74
75Tracing follows the same compiler support policies as the rest of the Tokio
76project. The current stable Rust compiler and the three most recent minor
77versions before it will always be supported. For example, if the current stable
Andrew Walbran6d525572023-11-17 16:00:02 +000078compiler version is 1.69, the minimum supported version will not be increased
79past 1.66, three minor versions prior. Increasing the minimum supported compiler
Fedor Tsarevfa35e1e2023-03-24 09:59:21 +010080version is not considered a semver breaking change as long as doing so complies
81with this policy.
82
83## License
84
85This project is licensed under the [MIT license](LICENSE).
86
87### Contribution
88
89Unless you explicitly state otherwise, any contribution intentionally submitted
90for inclusion in Tokio by you, shall be licensed as MIT, without any additional
91terms or conditions.