tokio-rs / valuable

MIT License
185 stars 19 forks source link

the trait `tracing::Value` is not implemented for `valuable::Value<'_> #111

Closed dmrolfs closed 1 year ago

dmrolfs commented 1 year ago

The coerce actor crate uses the valuable crate. In my personal project, which uses both tracing and coerce, I'm unable to build the coerce ("full" features) dependency (i.e., cargo fails trying to check/build coerce v0.8.5 before it starts on my project). Oddly, I'm able to build and fully test the coerce library itself, which suggests something is missing in my project/dependencies definition, although I have strived to match coerce's dependencies. I have posted an issue in the coerce project, and I'm posting here in here there's something in using valuable I missed in the documentation. I appreciate any guidance you may be able to provide. My project can be found at https://github.com/dmrolfs/coerce-cqrs-rs.

The issue I see is:

cargo c
    ...
    Checking coerce v0.8.5
error[E0277]: the trait bound `valuable::Value<'_>: tracing::Value` is not satisfied
  --> /Users/rolfs/.cargo/registry/src/github.com-1ecc6299db9ec823/coerce-0.8.5/src/actor/lifecycle.rs:88:28
   |
88 |                   let span = tracing::info_span!(
   |  ____________________________^
89 | |                     "actor.recv",
90 | |                     ctx = log.as_value(),
91 | |                     message_type = msg.name(),
92 | |                 );
   | |_________________^ the trait `tracing::Value` is not implemented for `valuable::Value<'_>`
   |
   = help: the following other types implement trait `tracing::Value`:
             &'a T
             &'a mut T
             (dyn StdError + 'static)
             (dyn StdError + Sync + 'static)
             (dyn StdError + std::marker::Send + 'static)
             (dyn StdError + std::marker::Send + Sync + 'static)
             Arguments<'a>
             Box<T>
           and 34 others
   = note: required for the cast from `valuable::Value<'_>` to the object type `dyn tracing::Value`
   = note: this error originates in the macro `$crate::valueset` which comes from the expansion of the macro `tracing::info_span` (in Nightly builds, run with -Z macro-backtrace for more info)

...
taiki-e commented 1 year ago

tracing's valuable support requires tracing_unstable cfg.

https://github.com/tokio-rs/tracing/blob/tracing-core-0.1.30/tracing-core/Cargo.toml#L39 https://github.com/tokio-rs/tracing/blob/tracing-core-0.1.30/examples/examples/valuable.rs

tracing's support for valuable is currently feature flagged. Additionally, valuable support is considered an unstable feature: in order to use valuable with tracing, the project must be built with RUSTFLAGS="--cfg tracing_unstable.

dmrolfs commented 1 year ago

Thank you! I missed the flag setting in the coerce crate's .cargo/config.toml.

That clears it up for me!