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
Uuid and rely on using as_bytes in 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.
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. SinceUuids are commonly used in applications that also usetracinglike Kanidm, we should implement theValuabletrait behind a feature gate.Solution
Derive the
Valuabletrait.Alternatives
Uuids as strings.Uuidand rely on usingas_bytesin the trait implementation. This would be incredibly annoying though, because it would mean applications would have to use:Hopefully
tracingwill add a sigil to reduce verbosity withas_value()similar to how?and%are used forDebugandDisplayformatting, but avoiding a wrapper type would be ideal.Is it blocking?
No
Anything else?
The
valuablecrate 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.