-
Notifications
You must be signed in to change notification settings - Fork 721
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
#[instrument(fields(...))]
does not support field::Empty
#1211
Comments
I checked out the code to prepare a PR to fix this, and saw that the code does actually support this now. Looks like d24a43a#diff-9cbd60b122df9aadd01f63b729cf92e850d39bbb6ba8bb58c1d1d5c8be0e4e3c was the change that landed this. With a Cargo.toml file that contains:
cargo fetched tracing-attributes 0.1.8, which is the version immediately before this support landed. I had to explicitly add tracing-attributes like so:
before cargo would update to the latest version (0.1.11 at time of writing). With that change the syntax to specify an empty field is just to list the field name without any value. For example:
Perhaps this example, or something like it, could be added to the documentation? |
The `tracing-attributes` documentation for `instrument` is out of date and could use some improvement. In particular, it doesn't mention that empty fields can be created in `instrument`'s `fields` argument, and states that dotted fields are forbidden and that field values must be literals, both of which are no longer the case. See also #1210 and #1211. This branch updates the docs to correct the false statements, and also fleshes out the usage examples a bit. I wasn't sure what to do with the old examples --- some of them are now redundant, but it's also useful to have a big list of examples for every allowed form. Any thoughts? Signed-off-by: Eliza Weisman <eliza@buoyant.io>
|
The `tracing-attributes` documentation for `instrument` is out of date and could use some improvement. In particular, it doesn't mention that empty fields can be created in `instrument`'s `fields` argument, and states that dotted fields are forbidden and that field values must be literals, both of which are no longer the case. See also tokio-rs#1210 and tokio-rs#1211. This branch updates the docs to correct the false statements, and also fleshes out the usage examples a bit. I wasn't sure what to do with the old examples --- some of them are now redundant, but it's also useful to have a big list of examples for every allowed form. Any thoughts? Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Bug Report
Version
Platform
Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin
Description
Since you can't record a new field on a span after it's been created (per the docs) I wanted to pre-create some fields on the
#[instrument(fields(...))]
.The documentation doesn't suggest this is possible, but gives the example:
Given that, I figured that
would make sense.
Sadly, that results in
The text was updated successfully, but these errors were encountered: