tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.52k stars 725 forks source link

attributes: globally qualify attribute paths #3126

Open heaths opened 3 weeks ago

heaths commented 3 weeks ago

Avoid ambiguities with any user-defined tracing modules by globally qualifying types used in the attribute-generated code e.g., ::tracing::Level.

Fixes: #3119 for the v0.2.x crate versions.

Motivation

We need to define helper functions for tracing within our own crates, and tracing is too good a name to pass up. Our helpers will mostly wrap and otherwise "hide" the tracing crate, but when using #[instrument] the generated code conflicts with our tracing module.

Solution

Globally qualify any token paths e.g., ::tracing to avoid ambiguities.

heaths commented 3 weeks ago

Note: the CONTRIBUTING.md file recommends updating the CHANGELOG.md but the last entry is very old - over 4 years old; however, the CHANGELOG.md file in the v0.1.x branch is up to date. I plan to make a PR against that branch as well and will update that CHANGELOG.md. I'm happy to update master's as well if that is appropriate.

heaths commented 3 weeks ago

Thanks. Should I close the other PR then or will maintainers?

kaffarell commented 2 days ago

No, this PR looks fine, the maintainers are gonna backport everything!