-
Notifications
You must be signed in to change notification settings - Fork 745
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
serde: support for deserializing named tracing types #275
Comments
I'm looking at a way to send tracing data between Rust processes via a serde bridge, this would be very useful. Will probably end up implementing a stripped down proof of concept in the meantime. |
Okay so I got most of the way through the implementation of this feature but was blocked on trying to create a value set with |
@kellpossible Did you get to anything viable for the serde bridge? Do you have a PR up somewhere with a base code I could maybe try to complete? I'm looking for basically the same thing, except I'm doing that between a Rust program and the Rust wasm module it executes using wasmtime. |
@Ekleog it's not perfect due to lifetime issues I ran into, but here's what I've got so far https://github.com/AleoHQ/tracing-bridge |
Hmm… I feel like I'm missing something, but… I can't see how this code makes it possible to reconstruct the various Anyway, I've filed #1170 to ask for the missing API in tracing, let's see how that evolves! Thank you anyway for your feedback :) |
@Ekleog yes it's not perfect, it seems like the API methods available don't allow this to be done properly with tracing. I just tried to hash together something as well as I could at the time. |
So, I'm looking into this for getting I'd prefer not to use JSON (it's not particularly compact, higher serialization cost than something like postcard), and ran into the "no deserialization" limitation mentioned here. I had a brief chat with @hawkw, and I think I am going to try and do roughly the following:
This approach won't be suitable for fully "round tripping" A bit more graphically, today you can do (only) this:
What I'm proposing would allow you to do this:
What this would NOT allow you to do:
Edit: One thing I forgot to mention is that even with these changes, if today you only use |
I'm now working on this on the I'm now pretty convinced this is possible, though there's a couple things I'm not sure about how to do in I'm also hunting down some serializations problems, as well, but progress is good. https://github.com/jamesmunns/tracing/blob/serde-structs/tracing-serde-structs/src/lib.rs |
Feature Request
Crates
tracing-serde
Motivation
Currently,
tracing-serde
supports serializingtracing
types, such asMetadata
,Event
,span::Attributes
andspan::Record
, etc. However, it does not support deserializing those types from a serialized representation. It would be good to support this.Proposal
We should add structs to
tracing-serde
that represent the deserialized form oftracing
types that can currently be serialized. These would have public accessors returning the fields of those types, and implement theserde::Deserialize
trait.Alternatives
From the outside, it might seem like we should just implement
serde::Deserialize
fortracing-core
types likeMetadata
,Event
, et cetera, rather than adding new structs that those types can be deserialized as. However, there are some serious issues with this.tracing
structs likeEvent
andMetadata
consist primarily of references to other data for performance and space optimization reasons. Similarly to how we don't serialize the internal representations of types likeValueSet
and instead useSerializeMap
etc, we wouldn't want to deserialize internal representations that don't make sense outside of the address space of the process where they originated.Another option is to not implement
Deserialize
for any structs, and just change allSerialize
implementations to serialize data structures like maps and sets. This would mean removing all uses ofSerializeStruct
and replacing it with unstructured data. However, this makes using deserialized tracing data more difficult for users, as rather than having a nice structured API for well-known fields, everything is represented as unstructured maps that may or may not contain particular values or types.The text was updated successfully, but these errors were encountered: