-
Notifications
You must be signed in to change notification settings - Fork 761
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
Docs say that #[instrument] uses Value trait, but experiment disagree #2775
Comments
Note: the broken link in the docs and the extra square brackets are fixed here: #2780, turned out to be a small error when backporting changes. The problem is (I think at least) that Edit: #2781 will fix this behavior, but we still need to fix the docs. |
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: tokio-rs#2775
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: tokio-rs#2775
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: #2775
https://docs.rs/tracing/latest/tracing/index.html still says that |
Oof, I missed that, thanks for the heads up! A function annotated with #[instrument] will create and enter a span with that function’s name every time the function is called, with arguments to that function recorded as fields using the The docs here: https://docs.rs/tracing/latest/tracing/attr.instrument.html explain this behavior more in depth, so I don't think its necessary to write another sentence here. |
I would say so:
But your variant is okay, too |
Added it to the PR! |
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: #2775
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: #2775
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: tokio-rs#2775
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: #2775
Bug Report
Version
Platform
Linux comp 5.10.0-0.deb9.24-amd64 #1 SMP Debian 5.10.179-5~deb9u1 (2023-09-01) x86_64 GNU/Linux
Crates
tracing, tracing_subscriber
Description
Consider this code:
Docs say this ( https://docs.rs/tracing/latest/tracing/attr.instrument.html ):
(Small note: link "Value trait" is broken. And
std::fmt::Debug
has extra square brackets.)My interpretation of quote above is so: first
Value
will be tried, thenDebug
. It is not fully clear what means "primitive types" here. But the text says "tracing primitive types", not just "primitive types", so my interpretation is so: docs mean not Rust's primitive types (i. e. https://doc.rust-lang.org/nightly/std/#primitives ), but some tracing's notion of primitive types. And link goes to list ofValue
implementors, which includeString
. So I conclude that meaning is so: "first tryValue
, thenDebug
".In code above we use
String
, which implementsValue
, soValue
implementation should be used. Thus output should contain"x":"a"
. But here is actual output:We see
"x":"\"a\""
here instead of correct (according to docs)"x":"a"
. So either docs, either implementation should be fixed.Moreover, https://docs.rs/tracing/latest/tracing/index.html says this:
So, this text implies that
Debug
always will be used. This contradicts to docs from https://docs.rs/tracing/latest/tracing/attr.instrument.html . Surprisingly, this doesn't match reality, too! If I pass&str
instead ofString
, then I see"x":"a"
! I. e.Value
orDisplay
implementation used, notDebug
. So, two documentation pieces contradict each other, and neither depicts reality correctly!The text was updated successfully, but these errors were encountered: