-
Notifications
You must be signed in to change notification settings - Fork 745
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
subscriber, serde: add valuable
support to the JSON formatter
#1862
Conversation
As a side note, this branch also nicely validates that recording |
depends on tokio-rs/valuable#82 |
ff9f93a
to
9f76c79
Compare
valuable
support to the JSON formattervaluable
support to the JSON formatter
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
ef08941
to
91185f2
Compare
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.
I wanted to maybe flatten the JSON output, but there isn't any API space to do that. Next version of subscriber, I guess.
Sorry, can you explain what you mean by this? this API already exists, and I believe it will flatten |
# 0.1.3 (February 4, 2022) This release adds *experimental* support for recording structured field values using the [`valuable`] crate. See [this blog post][post] for details on `valuable`. Note that `valuable` support currently requires `--cfg tracing_unstable`. See the documentation for details. ### Added - **valuable**: Experimental support for serializing user-defined types using [`valuable`] and [`valuable-serde`] ([#1862]) - Support for serializing `f64` values ([#1507]) ### Fixed - Fixed incorrect size hint in `SerializeFieldSet` ([#1333]) - A number of documentation fixes Thanks to @akinnane and @maxburke for contributing to this release! [`valuable`]: https://crates.io/crates/valuable [`valuable-serde`]: https://crates.io/crates/valuable-serde [post]: https://tokio.rs/blog/2021-05-valuable [#1862]: #1862 [#1507]: #1507 [#1333]: #1333 (I also noticed there was a missing changelog entry for v0.1.2, so I fixed that while I was here)
# 0.1.3 (February 4, 2022) This release adds *experimental* support for recording structured field values using the [`valuable`] crate. See [this blog post][post] for details on `valuable`. Note that `valuable` support currently requires `--cfg tracing_unstable`. See the documentation for details. ### Added - **valuable**: Experimental support for serializing user-defined types using [`valuable`] and [`valuable-serde`] ([#1862]) - Support for serializing `f64` values ([#1507]) ### Fixed - Fixed incorrect size hint in `SerializeFieldSet` ([#1333]) - A number of documentation fixes Thanks to @akinnane and @maxburke for contributing to this release! [`valuable`]: https://crates.io/crates/valuable [`valuable-serde`]: https://crates.io/crates/valuable-serde [post]: https://tokio.rs/blog/2021-05-valuable [#1862]: #1862 [#1507]: #1507 [#1333]: #1333 (I also noticed there was a missing changelog entry for v0.1.2, so I fixed that while I was here)
# 0.3.8 (Feb 4, 2022) This release adds *experimental* support for recording structured field values using the [`valuable`] crate to the `format::Json` formatter. In particular, user-defined types which are recorded using their [`valuable::Valuable`] implementations will be serialized as JSON objects, rather than using their `fmt::Debug` representation. See [this blog post][post] for details on `valuable`. Note that `valuable` support currently requires `--cfg tracing_unstable`. See the documentation for details. Additionally, this release includes a number of other smaller API improvements. ### Added - **json**: Experimental support for recording [`valuable`] values as structured JSON ([#1862], [#1901]) - **filter**: `Targets::would_enable` method for testing if a `Targets` filter would enable a given target ([#1903]) - **fmt**: `map_event_format`, `map_fmt_fields`, and `map_writer` methods to `fmt::Layer` and `fmt::SubscriberBuilder` ([#1871]) ### Changed - `tracing-core`: updated to [0.1.22][core-0.1.22] ### Fixed - Set `smallvec` minimal version to 1.2.0, to fix compilation errors with `-Z minimal-versions` ([#1890]) - Minor documentation fixes ([#1902], [#1893]) Thanks to @guswynn, @glts, and @lilyball for contributing to this release! [`valuable`]: https://crates.io/crates/valuable [`valuable::Valuable`]: https://docs.rs/valuable/latest/valuable/trait.Valuable.html [post]: https://tokio.rs/blog/2021-05-valuable [core-0.1.22]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.22 [#1862]: #1862 [#1901]: #1901 [#1903]: #1903 [#1871]: #1871 [#1890]: #1890 [#1902]: #1902 [#1893]: #1893
# 0.3.8 (Feb 4, 2022) This release adds *experimental* support for recording structured field values using the [`valuable`] crate to the `format::Json` formatter. In particular, user-defined types which are recorded using their [`valuable::Valuable`] implementations will be serialized as JSON objects, rather than using their `fmt::Debug` representation. See [this blog post][post] for details on `valuable`. Note that `valuable` support currently requires `--cfg tracing_unstable`. See the documentation for details. Additionally, this release includes a number of other smaller API improvements. ### Added - **json**: Experimental support for recording [`valuable`] values as structured JSON ([#1862], [#1901]) - **filter**: `Targets::would_enable` method for testing if a `Targets` filter would enable a given target ([#1903]) - **fmt**: `map_event_format`, `map_fmt_fields`, and `map_writer` methods to `fmt::Layer` and `fmt::SubscriberBuilder` ([#1871]) ### Changed - `tracing-core`: updated to [0.1.22][core-0.1.22] ### Fixed - Set `smallvec` minimal version to 1.2.0, to fix compilation errors with `-Z minimal-versions` ([#1890]) - Minor documentation fixes ([#1902], [#1893]) Thanks to @guswynn, @glts, and @lilyball for contributing to this release! [`valuable`]: https://crates.io/crates/valuable [`valuable::Valuable`]: https://docs.rs/valuable/latest/valuable/trait.Valuable.html [post]: https://tokio.rs/blog/2021-05-valuable [core-0.1.22]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.22 [#1862]: #1862 [#1901]: #1901 [#1903]: #1903 [#1871]: #1871 [#1890]: #1890 [#1902]: #1902 [#1893]: #1893
…o-rs#1862) This branch introduces support for `valuable` in `tracing-subscriber`'s JSON formatter, and in `tracing-serde`, using the `valuable-serde` bridge. This allows the `fmt::Json` subscriber to actually record `valuable` values as structured JSON. Here's an example, where a field is first recorded using `fmt::Debug`, and then again using `field::valuable`: ``` :; RUSTFLAGS="--cfg tracing_unstable" cargo run --example valuable_json | jq Finished dev [unoptimized + debuginfo] target(s) in 0.09s Running `target/debug/examples/valuable_json` { "timestamp": "2022-01-25T21:36:30.729658Z", "level": "INFO", "fields": { "valuable": false, "user": "User { name: \"Arwen Undomiel\", age: 3000, address: Address { country: \"Middle Earth\", city: \"Rivendell\", street: \"leafy lane\" } }" }, "target": "valuable_json" } { "timestamp": "2022-01-25T21:36:30.729720Z", "level": "INFO", "fields": { "valuable": true, "user": { "name": "Arwen Undomiel", "age": 3000, "address": { "country": "Middle Earth", "city": "Rivendell", "street": "leafy lane" } } }, "target": "valuable_json" } ``` As a side note, this branch also nicely validates that recording `Valuable` values from a subscriber is actually possible, which the previous valuable PR didn't have an example of. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
# 0.1.3 (February 4, 2022) This release adds *experimental* support for recording structured field values using the [`valuable`] crate. See [this blog post][post] for details on `valuable`. Note that `valuable` support currently requires `--cfg tracing_unstable`. See the documentation for details. ### Added - **valuable**: Experimental support for serializing user-defined types using [`valuable`] and [`valuable-serde`] ([tokio-rs#1862]) - Support for serializing `f64` values ([tokio-rs#1507]) ### Fixed - Fixed incorrect size hint in `SerializeFieldSet` ([tokio-rs#1333]) - A number of documentation fixes Thanks to @akinnane and @maxburke for contributing to this release! [`valuable`]: https://crates.io/crates/valuable [`valuable-serde`]: https://crates.io/crates/valuable-serde [post]: https://tokio.rs/blog/2021-05-valuable [tokio-rs#1862]: tokio-rs#1862 [tokio-rs#1507]: tokio-rs#1507 [tokio-rs#1333]: tokio-rs#1333 (I also noticed there was a missing changelog entry for v0.1.2, so I fixed that while I was here)
# 0.3.8 (Feb 4, 2022) This release adds *experimental* support for recording structured field values using the [`valuable`] crate to the `format::Json` formatter. In particular, user-defined types which are recorded using their [`valuable::Valuable`] implementations will be serialized as JSON objects, rather than using their `fmt::Debug` representation. See [this blog post][post] for details on `valuable`. Note that `valuable` support currently requires `--cfg tracing_unstable`. See the documentation for details. Additionally, this release includes a number of other smaller API improvements. ### Added - **json**: Experimental support for recording [`valuable`] values as structured JSON ([tokio-rs#1862], [tokio-rs#1901]) - **filter**: `Targets::would_enable` method for testing if a `Targets` filter would enable a given target ([tokio-rs#1903]) - **fmt**: `map_event_format`, `map_fmt_fields`, and `map_writer` methods to `fmt::Layer` and `fmt::SubscriberBuilder` ([tokio-rs#1871]) ### Changed - `tracing-core`: updated to [0.1.22][core-0.1.22] ### Fixed - Set `smallvec` minimal version to 1.2.0, to fix compilation errors with `-Z minimal-versions` ([tokio-rs#1890]) - Minor documentation fixes ([tokio-rs#1902], [tokio-rs#1893]) Thanks to @guswynn, @glts, and @lilyball for contributing to this release! [`valuable`]: https://crates.io/crates/valuable [`valuable::Valuable`]: https://docs.rs/valuable/latest/valuable/trait.Valuable.html [post]: https://tokio.rs/blog/2021-05-valuable [core-0.1.22]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.22 [tokio-rs#1862]: tokio-rs#1862 [tokio-rs#1901]: tokio-rs#1901 [tokio-rs#1903]: tokio-rs#1903 [tokio-rs#1871]: tokio-rs#1871 [tokio-rs#1890]: tokio-rs#1890 [tokio-rs#1902]: tokio-rs#1902 [tokio-rs#1893]: tokio-rs#1893
This branch introduces support for
valuable
intracing-subscriber
'sJSON formatter, and in
tracing-serde
, using thevaluable-serde
bridge.
This allows the
fmt::Json
subscriber to actually recordvaluable
values as structured JSON. Here's an example, where a field is first
recorded using
fmt::Debug
, and then again usingfield::valuable
:Note that this is currently not mergeable, as it adds a dependency on
the
valuable-serde
crate, which is unreleased. Also, I'm not sure ifthe feature flagging is quite correct in a couple places.