-
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
core: tracking issue for valuable
integration
#1570
Comments
cc @carllerche |
(Sorry, I should've commented sooner.) In terms of approaches, I really the idea of introducing Valuable into tracing 0.1 under a feature flag. As for the actual mechanism, I think that I'm also not opposed to introducing a versioned, Cargo-based feature flag for |
This branch adds initial support for using the [`valuable`] crate as an opt-in `Value` type in `tracing`. `valuable` provides a mechanism for defining custom ways to record user-implemented types, as well as structured recording of standard library data structures such as maps, arrays, and sets. For more details, see the tracking issue #1570. In `tracing` v0.2, the intent is for `valuable` to replace the existing `tracing_core::field::Value` trait. However, in v0.1.x, `valuable` support must be added in a backwards-compatible way, so recording types that implement `valuable::Valueable` currently requires opting in using a `field::valuable` wrapper function. Since this is the first release of `valuable` and the API is still stabilizing, we don't want to tie `tracing-core`'s stability to `valuable`'s. Therefore, the valuable dependency is feature-flagged *and* also requires `RUSTFLAGS="--cfg tracing_unstable"`. [`valuable`]: https://github.com/tokio-rs/valuable Co-authored-by: Daniel McKenna <daniel@emotech.co> Co-authored-by: David Barsky <me@davidbarsky.com> Co-authored-by: Eliza Weisman <eliza@buoyant.io>
I have second thoughts about the approach implemented by @hawkw in #1608. Before we start, let's make sure we're on the same page regarding the expectations: suppose that we have the following
then, given the following call:
I'd expect a JSON output along these lines:
while the current output is along these lines:
This happens because the current approach simply uses the I have an impression that we should call |
This is the default implementation of the For example, the JSON formatter in tracing/tracing-subscriber/src/fmt/format/json.rs Lines 481 to 499 in b9da544
Hope that's helpful! |
Thanks a lot! |
Is there any update on stabilization for valuable? |
Is there a way to get a e.g.
currently these are being formatted using the |
If you're using the json fmt subscriber, adding the |
This branch adds initial support for using the [`valuable`] crate as an opt-in `Value` type in `tracing`. `valuable` provides a mechanism for defining custom ways to record user-implemented types, as well as structured recording of standard library data structures such as maps, arrays, and sets. For more details, see the tracking issue tokio-rs#1570. In `tracing` v0.2, the intent is for `valuable` to replace the existing `tracing_core::field::Value` trait. However, in v0.1.x, `valuable` support must be added in a backwards-compatible way, so recording types that implement `valuable::Valueable` currently requires opting in using a `field::valuable` wrapper function. Since this is the first release of `valuable` and the API is still stabilizing, we don't want to tie `tracing-core`'s stability to `valuable`'s. Therefore, the valuable dependency is feature-flagged *and* also requires `RUSTFLAGS="--cfg tracing_unstable"`. [`valuable`]: https://github.com/tokio-rs/valuable Co-authored-by: Daniel McKenna <daniel@emotech.co> Co-authored-by: David Barsky <me@davidbarsky.com> Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Feature Request
Crates
tracing-core
Motivation
The
valuable
crate provides an extensible system for dynamic inspection of structured values. It was primarily implemented in order to extendtracing
's value system with support for visiting nested values (such as a struct's fields). This would be a significant improvement relative to the current value system (see e.g. #819, #845, etc). However, in order to benefit fromvaluable
, we have to actually integrate it intotracing
.Proposal
There are actually two separate problems we will want to solve:
valuable
support intracing
0.1, andvaluable
support for the upcoming v0.2.In 0.2
For 0.2, the solution will be fairly simple, but probably takes a lot of work to implement. The intent is to more or less completely replace the existing
Value
trait withvaluable::Valuable
. I think we would also want to replace theValueSet
type with something implementingvaluable
's abstraction for arrays, as well. We would then modify the macros to record key-value pairs usingvaluable
, rather than using thetracing_core::field::Value
trait, and update existing code to usevaluable
. Of course, we'll want to make sure it's possible to reimplement the basictracing
field behaviors (e.g. recording primitives) on top ofvaluable
with no additional friction.In 0.1
It's probably a good idea to implement the
valuable
integration intracing
0.1 before performing a whole-sale replacement in 0.2 --- it's quite likely that we'll hit things invaluable
that may need to be changed or improved in order to support use intracing
, and this may require breaking changes invaluable
. Usingvaluable
to completely replace theValue
trait makesvaluable
a public API dependency, and breaking changes tovaluable
are breaking changes intracing-core
. Therefore, we ought to make sure any breaking changes tovaluable
are out of the way prior to replacing the entire value system in 0.2.Thus, we probably want to add optional support for
valuable
in 0.1 first. Unlike replacing the entireValue
trait, this would be a backwards-compatible addition to the existingValue
system. We'd probably want to do this by adding a newVisit::record_valuable
method where the visitor is passed adyn Valuable
, behind a feature flag. We'd also add aValue
implementation forvaluable::Value
that dispatches to this method. Sincevaluable::Value
implementsDebug
, this can always fall back to theVisit
type'srecord_debug
if the visitor doesn't opt in tovaluable
support.Alternatives
We could skip adding
valuable
support in 0.1, and just do the wholesale replacement in 0.2. However, I don't think this is a great idea, since it means we don't get the opportunity for users to actually test out usingvaluable
withtracing
, and there might be unforseen issues that require breaking API changes invaluable
. Also, I think the 0.1 version of optionalvaluable
integration is probably fairly simple to implement, so it seems like something we might as well do.The text was updated successfully, but these errors were encountered: