New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Make dyn Any + 'static
a primitive, recordable type
#905
Comments
dyn Any + 'static
a primitive, recordable typedyn Any + 'static
a primitive, recordable type
I think my biggest motivation for this proposal was supporting recording nested structures, as
...there's a rich design space available for us to explore. |
I'm a bigger fan of
I'm not familiar with this but it seems like it might not work super well for the case of wanting to print JS values to The ideal, IMO would be to support something like this in tracing-wasm: let foo: JsValue = ...;
info!(foo, "button clicked"); which would end up calling something like let foo: JsValue = ...;
info!(foo = foo.pretty(), "button clicked"); // returns something like ConsoleValue(foo) |
Supporting downcasting for |
Feature Request
Crates
tracing-core
Motivation
tracing_core::Value
without needing to take a public dependency on serde 1.0.Proposal
David:
Eliza, continuing in #819:
To address the "I can only record types that I know how to downcast" problem, Layers and Subscribers would be encouraged to provide a registry of formatters + downcasters for
std::any::Any
that the end-user (e.g., the person creating a binary executable) would register when creating their subscriber or layer.Alternatives
Don't do this. Based off Eliza's response, I worry that supporting
dyn Any + 'static
is strictly worse than something likeValue::from_serde
or the current practice of extensions traits on Spans that allow users to directly write to a Subscriber's extensions.Value::from_serde
, or something equivalent toValue::from_serde
, seems like a more general purpose and correct solution thandyn Any + 'static
because it doesn't require Layer or Subscriber-specific knowledge of types.tracing_core
.dyn Any + 'static
could prevent the usage of non-'static
references, requiring a clone to record a value. This is something thattracing
has avoided when recording other values and wouldn't hit iftracing_core::Value
supported something serde-style serializers.On the other hand, a registry of formatting/downcasting functions for
std::any::Any
could serve nice compliment for specialized, associative collections likehttp::Request
and friends, in that it provides a handy escape hatch for types/crates that either can't or won't take a public dependency ontracing_core::Value
. That said, I'm not sure this benefit is worth the downsides because Serde's support for implementing Serialize/Deserialize on foreign types would handle this usecase nicely.The text was updated successfully, but these errors were encountered: