-
Notifications
You must be signed in to change notification settings - Fork 847
tracing: make valueset macro sanitary
#3382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+43
−27
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Due to an import of `::tracing::field::{display, debug, Value}, macro
`valueset!` wasn't sanitary and would produce compile errors when
identifiers `debug` and `display` were used.
This change fixes the issue and makes the macro sanitary.
Fixes: tokio-rs#3381
hds
approved these changes
Nov 19, 2025
Contributor
hds
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR! This is great.
hds
added a commit
that referenced
this pull request
Nov 25, 2025
# 0.1.42 (November 30, 2025) ### Added - **attributes**: Support constant expressions as instrument field names ([#3158]) - **core**: Improve code generation at trace points significantly ([#3398]) ### Fixed - Fix perf regression when `release_max_level_*` not set ([#3373]) - Use imported instead of fully qualified path ([#3374]) - Make `valueset` macro sanitary ([#3382]) ### Documented - **core**: Add missing `dyn` keyword in `Visit` documentation code sample ([#3387]) [#3158]: https://github.com/tokio-rs/tracing/pull/#3158 [#3373]: https://github.com/tokio-rs/tracing/pull/#3373 [#3374]: https://github.com/tokio-rs/tracing/pull/#3374 [#3382]: https://github.com/tokio-rs/tracing/pull/#3382 [#3387]: https://github.com/tokio-rs/tracing/pull/#3387 [#3398]: https://github.com/tokio-rs/tracing/pull/#3398
hds
added a commit
that referenced
this pull request
Nov 26, 2025
# 0.1.42 (November 26, 2025) ### Added - **attributes**: Support constant expressions as instrument field names ([#3158]) - **core**: Improve code generation at trace points significantly ([#3398]) ### Changed - `tracing-core`: updated to 0.1.35 ([#3414]) - `tracing-attributes`: updated to 0.1.31 ([#3417]) ### Fixed - Fix perf regression when `release_max_level_*` not set ([#3373]) - Use imported instead of fully qualified path ([#3374]) - Make `valueset` macro sanitary ([#3382]) ### Documented - **core**: Add missing `dyn` keyword in `Visit` documentation code sample ([#3387]) [#3158]: https://github.com/tokio-rs/tracing/pull/#3158 [#3373]: https://github.com/tokio-rs/tracing/pull/#3373 [#3374]: https://github.com/tokio-rs/tracing/pull/#3374 [#3382]: https://github.com/tokio-rs/tracing/pull/#3382 [#3387]: https://github.com/tokio-rs/tracing/pull/#3387 [#3398]: https://github.com/tokio-rs/tracing/pull/#3398 [#3414]: https://github.com/tokio-rs/tracing/pull/#3414 [#3417]: https://github.com/tokio-rs/tracing/pull/#3417
hds
added a commit
that referenced
this pull request
Nov 26, 2025
# 0.1.42 (November 26, 2025) ### Added - **attributes**: Support constant expressions as instrument field names ([#3158]) - Add `record_all!` macro for recording multiple values in one call ([#3227]) - **core**: Improve code generation at trace points significantly ([#3398]) ### Changed - `tracing-core`: updated to 0.1.35 ([#3414]) - `tracing-attributes`: updated to 0.1.31 ([#3417]) ### Fixed - Fix "name / parent" variant of `event!` ([#2983]) - Remove 'r#' prefix from raw identifiers in field names ([#3130]) - Fix perf regression when `release_max_level_*` not set ([#3373]) - Use imported instead of fully qualified path ([#3374]) - Make `valueset` macro sanitary ([#3382]) ### Documented - **core**: Add missing `dyn` keyword in `Visit` documentation code sample ([#3387]) [#2983]: https://github.com/tokio-rs/tracing/pull/#2983 [#3130]: https://github.com/tokio-rs/tracing/pull/#3130 [#3158]: https://github.com/tokio-rs/tracing/pull/#3158 [#3227]: https://github.com/tokio-rs/tracing/pull/#3227 [#3373]: https://github.com/tokio-rs/tracing/pull/#3373 [#3374]: https://github.com/tokio-rs/tracing/pull/#3374 [#3382]: https://github.com/tokio-rs/tracing/pull/#3382 [#3387]: https://github.com/tokio-rs/tracing/pull/#3387 [#3398]: https://github.com/tokio-rs/tracing/pull/#3398 [#3414]: https://github.com/tokio-rs/tracing/pull/#3414 [#3417]: https://github.com/tokio-rs/tracing/pull/#3417
hds
added a commit
that referenced
this pull request
Nov 26, 2025
# 0.1.42 (November 26, 2025) ### Important The [`Span::record_all`] method has been removed from the documented API. It was always unsuable via the documented API as it requried a `ValueSet` which has no publically documented constructors. The method remains, but should not be used outside of `tracing` macros. ### Added - **attributes**: Support constant expressions as instrument field names ([#3158]) - Add `record_all!` macro for recording multiple values in one call ([#3227]) - **core**: Improve code generation at trace points significantly ([#3398]) ### Changed - `tracing-core`: updated to 0.1.35 ([#3414]) - `tracing-attributes`: updated to 0.1.31 ([#3417]) ### Fixed - Fix "name / parent" variant of `event!` ([#2983]) - Remove 'r#' prefix from raw identifiers in field names ([#3130]) - Fix perf regression when `release_max_level_*` not set ([#3373]) - Use imported instead of fully qualified path ([#3374]) - Make `valueset` macro sanitary ([#3382]) ### Documented - **core**: Add missing `dyn` keyword in `Visit` documentation code sample ([#3387]) [#2983]: https://github.com/tokio-rs/tracing/pull/#2983 [#3130]: https://github.com/tokio-rs/tracing/pull/#3130 [#3158]: https://github.com/tokio-rs/tracing/pull/#3158 [#3227]: https://github.com/tokio-rs/tracing/pull/#3227 [#3373]: https://github.com/tokio-rs/tracing/pull/#3373 [#3374]: https://github.com/tokio-rs/tracing/pull/#3374 [#3382]: https://github.com/tokio-rs/tracing/pull/#3382 [#3387]: https://github.com/tokio-rs/tracing/pull/#3387 [#3398]: https://github.com/tokio-rs/tracing/pull/#3398 [#3414]: https://github.com/tokio-rs/tracing/pull/#3414 [#3417]: https://github.com/tokio-rs/tracing/pull/#3417 [`Span::record_all`]: https://docs.rs/tracing/0.1.41/tracing/struct.Span.html#method.record_all
hds
added a commit
that referenced
this pull request
Nov 26, 2025
# 0.1.42 (November 26, 2025) ### Important The [`Span::record_all`] method has been removed from the documented API. It was always unsuable via the documented API as it requried a `ValueSet` which has no publically documented constructors. The method remains, but should not be used outside of `tracing` macros. ### Added - **attributes**: Support constant expressions as instrument field names ([#3158]) - Add `record_all!` macro for recording multiple values in one call ([#3227]) - **core**: Improve code generation at trace points significantly ([#3398]) ### Changed - `tracing-core`: updated to 0.1.35 ([#3414]) - `tracing-attributes`: updated to 0.1.31 ([#3417]) ### Fixed - Fix "name / parent" variant of `event!` ([#2983]) - Remove 'r#' prefix from raw identifiers in field names ([#3130]) - Fix perf regression when `release_max_level_*` not set ([#3373]) - Use imported instead of fully qualified path ([#3374]) - Make `valueset` macro sanitary ([#3382]) ### Documented - **core**: Add missing `dyn` keyword in `Visit` documentation code sample ([#3387]) [#2983]: https://github.com/tokio-rs/tracing/pull/#2983 [#3130]: https://github.com/tokio-rs/tracing/pull/#3130 [#3158]: https://github.com/tokio-rs/tracing/pull/#3158 [#3227]: https://github.com/tokio-rs/tracing/pull/#3227 [#3373]: https://github.com/tokio-rs/tracing/pull/#3373 [#3374]: https://github.com/tokio-rs/tracing/pull/#3374 [#3382]: https://github.com/tokio-rs/tracing/pull/#3382 [#3387]: https://github.com/tokio-rs/tracing/pull/#3387 [#3398]: https://github.com/tokio-rs/tracing/pull/#3398 [#3414]: https://github.com/tokio-rs/tracing/pull/#3414 [#3417]: https://github.com/tokio-rs/tracing/pull/#3417 [`Span::record_all`]: https://docs.rs/tracing/0.1.41/tracing/struct.Span.html#method.record_all
hds
added a commit
that referenced
this pull request
Nov 27, 2025
The change merged in #3382 caused a breaking change when released. This is because users of the tracing macros depend on being able to use a bare `debug` or `display` function within the macro itself, for example: ```rust tracing::info!(foo = debug(foo), bar = display(bar)); ``` This change reverts the breaking part of the original commit, which is removing the import statement from the `valueset!` macro. However, it leaves the change to use full module paths inside the macro. E.g. `$crate::field::debug`. This is best practice, and so worth keeping. This change also adds a nice warning comment above the import statement to try and avoid another break happening in the future (because this isn't the first time that this has happened). It also adds explicit tests for the use of bare `debug` and `display` usage with the same end.
hds
added a commit
that referenced
this pull request
Nov 27, 2025
The change merged in #3382 caused a breaking change when released. This is because users of the tracing macros depend on being able to use a bare `debug` or `display` function within the macro itself, for example: ```rust tracing::info!(foo = debug(foo), bar = display(bar)); ``` This change reverts the breaking part of the original commit, which is removing the import statement from the `valueset!` macro. However, it leaves the change to use full module paths inside the macro. E.g. `$crate::field::debug`. This is best practice, and so worth keeping. This change also adds a nice warning comment above the import statement to try and avoid another break happening in the future (because this isn't the first time that this has happened). It also adds explicit tests for the use of bare `debug` and `display` usage with the same end.
hds
added a commit
that referenced
this pull request
Nov 27, 2025
## Motivation The change merged in #3382 caused a breaking change when released. This is because users of the tracing macros depend on being able to use a bare `debug` or `display` function within the macro itself, for example: ```rust tracing::info!(foo = debug(foo), bar = display(bar)); ``` ## Solution This change reverts the breaking part of the original commit, which is removing the import statement from the `valueset!` macro. However, it leaves the change to use full module paths inside the macro. E.g. `$crate::field::debug`. This is best practice, and so worth keeping. This change also adds a nice warning comment above the import statement to try and avoid another break happening in the future (because this isn't the first time that this has happened). It also adds explicit tests for the use of bare `debug` and `display` usage with the same end.
hds
added a commit
that referenced
this pull request
Nov 27, 2025
# 0.1.43 (November 28, 2025) #### Important The previous release [0.1.42] was yanked because [#3382] was a breaking change. See further details in [#3424]. This release contains all the changes from that version, plus a revert for the problematic part of the breaking PR. ### Fixed - Revert "make `valueset` macro sanitary" ([#3425]) [#3382]: #3382 [#3424]: #3424 [#3425]: #3425 [0.1.42]: https://github.com/tokio-rs/tracing/releases/tag/tracing-0.1.42
hds
added a commit
that referenced
this pull request
Nov 28, 2025
# 0.1.43 (November 28, 2025) #### Important The previous release [0.1.42] was yanked because [#3382] was a breaking change. See further details in [#3424]. This release contains all the changes from that version, plus a revert for the problematic part of the breaking PR. ### Fixed - Revert "make `valueset` macro sanitary" ([#3425]) [#3382]: #3382 [#3424]: #3424 [#3425]: #3425 [0.1.42]: https://github.com/tokio-rs/tracing/releases/tag/tracing-0.1.42
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to an import of
::tracing::field::{display, debug, Value}, macrovalueset!wasn't sanitary and would produce compile errors when identifiersdebuganddisplaywere used.This change fixes the issue and makes the macro sanitary.
Fixes: #3381
Motivation
Making sure the mentioned macro is sanitary and avoiding users from encountering unexpected compile errors.
Solution
Removed the import inside macro and used fully-qualified paths for imported items.