Allow owned values and fat pointers in Span::record#2212
Merged
hawkw merged 2 commits intotokio-rs:masterfrom Jul 13, 2022
Merged
Allow owned values and fat pointers in Span::record#2212hawkw merged 2 commits intotokio-rs:masterfrom
Span::record#2212hawkw merged 2 commits intotokio-rs:masterfrom
Conversation
davidbarsky
approved these changes
Jul 11, 2022
Member
davidbarsky
left a comment
There was a problem hiding this comment.
approved, but i'm unreasonably paranoid that the previous impls don't work. not blocking: can you maybe add a unit test for the previous, ref-based usage?
Previously, using `record("x", "y")` would give an error:
```
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:3:22
|
243 | span.record("x", "y");
| ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Span::record`
--> /home/jnelson/.local/lib/cargo/registry/src/mygithub.libinneed.workers.dev-1ecc6299db9ec823/tracing-0.1.32/src/span.rs:1184:30
|
1184 | pub fn record<Q: ?Sized, V>(&self, field: &Q, value: &V) -> &Self
| ^ required by this bound in `Span::record`
```
Now it works fine, as tested by the doc-example.
This doesn't break any existing code, because there's a generic `impl<T: Value> Value for &T`: https://docs.rs/tracing/0.1.35/tracing/trait.Value.html#impl-Value-for-%26%27a%20T
Contributor
Author
|
Sure thing, done :) |
hawkw
added a commit
that referenced
this pull request
Jul 20, 2022
Previously, using `record("x", "y")` would give an error:
```
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:3:22
|
243 | span.record("x", "y");
| ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Span::record`
--> /home/jnelson/.local/lib/cargo/registry/src/mygithub.libinneed.workers.dev-1ecc6299db9ec823/tracing-0.1.32/src/span.rs:1184:30
|
1184 | pub fn record<Q: ?Sized, V>(&self, field: &Q, value: &V) -> &Self
| ^ required by this bound in `Span::record`
```
Now it works fine, as tested by the doc-example.
This doesn't break any existing code, because there's a generic `impl<T: Value> Value for &T`: https://docs.rs/tracing/0.1.35/tracing/trait.Value.html#impl-Value-for-%26%27a%20T
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw
added a commit
that referenced
this pull request
Jul 20, 2022
Previously, using `record("x", "y")` would give an error:
```
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:3:22
|
243 | span.record("x", "y");
| ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Span::record`
--> /home/jnelson/.local/lib/cargo/registry/src/mygithub.libinneed.workers.dev-1ecc6299db9ec823/tracing-0.1.32/src/span.rs:1184:30
|
1184 | pub fn record<Q: ?Sized, V>(&self, field: &Q, value: &V) -> &Self
| ^ required by this bound in `Span::record`
```
Now it works fine, as tested by the doc-example.
This doesn't break any existing code, because there's a generic `impl<T: Value> Value for &T`: https://docs.rs/tracing/0.1.35/tracing/trait.Value.html#impl-Value-for-%26%27a%20T
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw
added a commit
that referenced
this pull request
Jul 20, 2022
Previously, using `record("x", "y")` would give an error:
```
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:3:22
|
243 | span.record("x", "y");
| ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Span::record`
--> /home/jnelson/.local/lib/cargo/registry/src/mygithub.libinneed.workers.dev-1ecc6299db9ec823/tracing-0.1.32/src/span.rs:1184:30
|
1184 | pub fn record<Q: ?Sized, V>(&self, field: &Q, value: &V) -> &Self
| ^ required by this bound in `Span::record`
```
Now it works fine, as tested by the doc-example.
This doesn't break any existing code, because there's a generic `impl<T: Value> Value for &T`: https://docs.rs/tracing/0.1.35/tracing/trait.Value.html#impl-Value-for-%26%27a%20T
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw
added a commit
that referenced
this pull request
Jul 29, 2022
# 0.1.36 (July 29, 2022) This release adds support for owned values and fat pointers as arguments to the `Span::record` method, as well as updating the minimum `tracing-core` version and several documentation improvements. ### Fixed - Incorrect docs in `dispatcher::set_default` ([#2220]) - Compilation with `-Z minimal-versions` ([#2246]) ### Added - Support for owned values and fat pointers in `Span::record` ([#2212]) - Documentation improvements ([#2208], [#2163]) ### Changed - `tracing-core`: updated to [0.1.29][core-0.1.29] Thanks to @fredr, @cgbur, @jyn514, @matklad, and @CAD97 for contributing to this release! [core-0.1.29]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.29 [#2220]: #2220 [#2246]: #2246 [#2212]: #2212 [#2208]: #2208 [#2163]: #2163
hawkw
added a commit
that referenced
this pull request
Jul 29, 2022
# 0.1.36 (July 29, 2022) This release adds support for owned values and fat pointers as arguments to the `Span::record` method, as well as updating the minimum `tracing-core` version and several documentation improvements. ### Fixed - Incorrect docs in `dispatcher::set_default` ([#2220]) - Compilation with `-Z minimal-versions` ([#2246]) ### Added - Support for owned values and fat pointers in `Span::record` ([#2212]) - Documentation improvements ([#2208], [#2163]) ### Changed - `tracing-core`: updated to [0.1.29][core-0.1.29] Thanks to @fredr, @cgbur, @jyn514, @matklad, and @CAD97 for contributing to this release! [core-0.1.29]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.29 [#2220]: #2220 [#2246]: #2246 [#2212]: #2212 [#2208]: #2208 [#2163]: #2163
caio
added a commit
to caio/foca
that referenced
this pull request
Nov 9, 2022
tracing-attributes 0.1.23 ships with a smarter `Span::record` that
allows owned values [^1], which makes
This means that previously invalid code such as:
span.record("num_updates", num_items);
Is now valid, which makes clippy throw a warning for needless_borrow
Fixing the lint, however, means that foca would require a strict version
check for tracing-attributes (otherwise anything pulling 0.1.22 or
bellow would not compile anymore).
I don't want a strict dependency on tracing: it's tangential do foca and
I'd like users to benefit from the improvements that might be shipped
along, so I fix the lint warning by ignoring it instead.
Once we get a (at least minor) version bump on `tracing`, this can be
removed and updated to skip the borrow.
[^1]: tokio-rs/tracing#2212
caio
added a commit
to caio/foca
that referenced
this pull request
Nov 13, 2022
tracing-attributes 0.1.23 ships with a smarter `Span::record` that
allows owned values [^1], which makes
This means that previously invalid code such as:
span.record("num_updates", num_items);
Is now valid, which makes clippy throw a warning for needless_borrow
Fixing the lint, however, means that foca would require a strict version
check for tracing-attributes (otherwise anything pulling 0.1.22 or
bellow would not compile anymore).
I don't want a strict dependency on tracing: it's tangential do foca and
I'd like users to benefit from the improvements that might be shipped
along, so I fix the lint warning by ignoring it instead.
Once we get a (at least minor) version bump on `tracing`, this can be
removed and updated to skip the borrow.
[^1]: tokio-rs/tracing#2212
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
# 0.1.36 (July 29, 2022) This release adds support for owned values and fat pointers as arguments to the `Span::record` method, as well as updating the minimum `tracing-core` version and several documentation improvements. ### Fixed - Incorrect docs in `dispatcher::set_default` ([tokio-rs#2220]) - Compilation with `-Z minimal-versions` ([tokio-rs#2246]) ### Added - Support for owned values and fat pointers in `Span::record` ([tokio-rs#2212]) - Documentation improvements ([tokio-rs#2208], [tokio-rs#2163]) ### Changed - `tracing-core`: updated to [0.1.29][core-0.1.29] Thanks to @fredr, @cgbur, @jyn514, @matklad, and @CAD97 for contributing to this release! [core-0.1.29]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.29 [tokio-rs#2220]: tokio-rs#2220 [tokio-rs#2246]: tokio-rs#2246 [tokio-rs#2212]: tokio-rs#2212 [tokio-rs#2208]: tokio-rs#2208 [tokio-rs#2163]: tokio-rs#2163
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
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.
Motivation
Previously, using
record("x", "y")would give an error:Solution
Take
Q: Valuedirectly instead ofQ: &Value. This doesn't break any existing code, because there's a genericimpl<T: Value> Value for &T: https://docs.rs/tracing/0.1.35/tracing/trait.Value.html#impl-Value-for-%26%27a%20TThere's a simpler change which is just to remove the implicit
Sizedrestriction on Q, but that still wouldn't allow passingfalseinstead of&false.