Announcing Experimental valuable
Support
#1906
hawkw
announced in
Announcements
Replies: 1 comment 6 replies
-
Hello, it's been more than two years since this was announced with experimental status. Are there any blockers preventing this feature being stabilized? Or otherwise, is there any discussion about this feature somewhere else? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone!
Today we're excited to announce the release of
tracing-core
v0.1.22, which introduces experimental support for thevaluable
crate intracing
!For a long time, many people have wanted a way to record both user-defined types, and standard library collections such as
Vec
andHashMap
, as structured data attached totracing
spans and events. The current design of thetracing::Value
trait is not flexible enough to represent this kind of data, but adding support for arbitrary user-defined types has been a goal since day one.A lot of approaches have been considered, such as extending the
tracing::Value
system to add support forserde
(#819) and makingdyn std::any::Any
a primitiveValue
type (#905). Unfortunately, whileserde
is a great library, it has some limitations that make it difficult to use intracing
; primarily around object safety.Enter
valuable
.valuable
is a library providing object-safe inspection of structured values. Unlikeserde
, it was designed specifically for use-cases liketracing
's, while remaining compatible withserde
for serialization.Our long term goal is to replace most of
tracing
's currentValue
system withvaluable
intracing
0.2.x. However, before we can do that, we need to actually experiment with using thevaluable
APIs in practice. The recenttracing
v0.1.30 andtracing-core
v0.1.22 have backwards-compatible support forvaluable
in addition to the existingtracing::Value
trait. We're hoping you'll help try out usingvaluable
withtracing
and share your experiences so we can refine the design for v0.2!How it Works
For details on how
valuable
itself works, refer to this post on the Tokio blog.The
valuable
support intracing
v0.1.x works by adding a newVisit::record_value
method to thetracing::field::Visit
trait, to record avaluable::Value
. If aVisit
implementation provides this method, it can record those values usingvaluable
. Otherwise, if the visitor does not implementrecord_value
, it will fall back to recording theValue
usingfmt::Debug
as normal.To record your types using
valuable
, derive thevaluable::Valuable
trait, and record them by callingValuable::as_value
:See the documentation and examples for more information.
Enabling Experimental Features
Note that the
valuable
support is currently an experimental feature. This means that breaking changes tovaluable
are not considered breaking changes to thetracing
API. Therefore, you must opt in to using thevaluable
support by both enabling the "valuable" feature flag and enabling the "tracing_unstable" cfg flag, such as by building withRUSTFLAGS="--cfg tracing_unstable" cargo build
See the documentation on unstable features for more information.
Crates With
valuable
SupportCurrently, the following crates offer some experimental support for
valuable
tracing-core
v0.1.22tracing
v0.1.30tracing-subscriber
v0.3.8 supports recordingvaluable::Valuable
fields as structured JSON with the JSON formattertracing-serde
v0.1.3 supports serializingvaluable::Valuable
fields using the [valuable-serde
] crateWe'd Love To Hear Your Thoughts!
Since this is an experimental feature, we'd love to hear your thoughts and experiences with the new
valuable
support intracing
! Please try it out and feel free to leave a comment in this thread with any questions and thoughts you may have. Also, you can join us on Discord, and open new issues for any bugs you find or new features you'd like to see.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions