-
Notifications
You must be signed in to change notification settings - Fork 223
Description
Motivation
The Tokio team is releasing a new crate, valuable, which is intended to be used for passing in custom types as fields in logs. Since Uuids are commonly used in applications that also use tracing like Kanidm, we should implement the Valuable trait behind a feature gate.
Solution
Derive the Valuable trait.
#[cfg_attr(feature = "valuable", derive(Valuable))]
struct Uuid(Bytes);Alternatives
- Continue to record
Uuids as strings. - Create a wrapper type around the
Uuidand rely on usingas_bytesin the trait implementation. This would be incredibly annoying though, because it would mean applications would have to use:
let uuid = Uuid::new_v4();
tracing::info!(my_id = MyWrapper(uuid).as_value(), "the uuid");Hopefully tracing will add a sigil to reduce verbosity with as_value() similar to how ? and % are used for Debug and Display formatting, but avoiding a wrapper type would be ideal.
Is it blocking?
No
Anything else?
The valuable crate is still in the very early stages, and could possibly have breaking changes. However, I think the very minimal API that this crate would depend on (just deriving the trait) is unlikely to change.