Add structured support to kv::Value using sval#342
Merged
Conversation
split consumer builds of MSRV from dev builds
59b89b4 to
368a777
Compare
29 tasks
EFanZh
pushed a commit
to EFanZh/log
that referenced
this pull request
Jul 23, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's this all about?
This PR adds a new unstable feature for structured logging that lets consumers actually interact with the structure of values.
It doesn't do this by exposing its own serialization contract. Instead, it implements traits from a serialization framework called
sval. I'm open to any philosophical debate on different approaches here!There are two commits that I think demonstrate how it fits together:
valueinternals so we can add in-band serialization frameworks easily.svalsupport. This is the one to look at if you're interested in what impact introducing in-band frameworks has.What is
sval?svalis a serialization-only framework I've been working on specifically for use inlog.svalsupports no-std, object-safe serialization for primitives and more complex structures like maps and sequences. It absolveslogfrom having to produce and maintain its own serialization contract, so it can stay focused, but lets it provide a complete serialization API for consumers.What about
serde?serdeis the other serialization framework I've been planning to support in-band inlogbecause it's ubiquitous (and does its job very well). I haven't started with it because:stdto work, because we neederased-serde.svalhas out-of-the-box support forserde(including in no-std environments) so adding it first already gives consumers a way to capture implementations ofserde::Serialize.The plan is to also eventually offer
serdesupport.Impact on build times
When
svalis enabled through thekv_unstable_svalfeature, it increases our compile times by a little bit:logFeaturescargo buildtime (best of 5 runs)kv_unstablekv_unstable_svalsval