Announcing Experimental valuable Support
#1906
Replies: 4 comments 7 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.
-
|
How can I implement |
Beta Was this translation helpful? Give feedback.
-
|
Hi team, are there any updates on the valuable feature? Are there any blockers keeping this feature from being stabilized? |
Beta Was this translation helpful? Give feedback.
-
|
Just like @nastynaz, there should be an example of implementing the trait by hand. It's the pain to figure it out. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone!
Today we're excited to announce the release of
tracing-corev0.1.22, which introduces experimental support for thevaluablecrate intracing!For a long time, many people have wanted a way to record both user-defined types, and standard library collections such as
VecandHashMap, as structured data attached totracingspans and events. The current design of thetracing::Valuetrait 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::Valuesystem to add support forserde(#819) and makingdyn std::any::Anya primitiveValuetype (#905). Unfortunately, whileserdeis a great library, it has some limitations that make it difficult to use intracing; primarily around object safety.Enter
valuable.valuableis a library providing object-safe inspection of structured values. Unlikeserde, it was designed specifically for use-cases liketracing's, while remaining compatible withserdefor serialization.Our long term goal is to replace most of
tracing's currentValuesystem withvaluableintracing0.2.x. However, before we can do that, we need to actually experiment with using thevaluableAPIs in practice. The recenttracingv0.1.30 andtracing-corev0.1.22 have backwards-compatible support forvaluablein addition to the existingtracing::Valuetrait. We're hoping you'll help try out usingvaluablewithtracingand share your experiences so we can refine the design for v0.2!How it Works
For details on how
valuableitself works, refer to this post on the Tokio blog.The
valuablesupport intracingv0.1.x works by adding a newVisit::record_valuemethod to thetracing::field::Visittrait, to record avaluable::Value. If aVisitimplementation provides this method, it can record those values usingvaluable. Otherwise, if the visitor does not implementrecord_value, it will fall back to recording theValueusingfmt::Debugas normal.To record your types using
valuable, derive thevaluable::Valuabletrait, and record them by callingValuable::as_value:See the documentation and examples for more information.
Enabling Experimental Features
Note that the
valuablesupport is currently an experimental feature. This means that breaking changes tovaluableare not considered breaking changes to thetracingAPI. Therefore, you must opt in to using thevaluablesupport by both enabling the "valuable" feature flag and enabling the "tracing_unstable" cfg flag, such as by building withRUSTFLAGS="--cfg tracing_unstable" cargo buildSee the documentation on unstable features for more information.
Crates With
valuableSupportCurrently, the following crates offer some experimental support for
valuabletracing-corev0.1.22tracingv0.1.30tracing-subscriberv0.3.8 supports recordingvaluable::Valuablefields as structured JSON with the JSON formattertracing-serdev0.1.3 supports serializingvaluable::Valuablefields 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
valuablesupport 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