Skip to content
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

Add structured support to kv::Value using sval #342

Merged
merged 3 commits into from
Jul 24, 2019

Conversation

KodrAus
Copy link
Contributor

@KodrAus KodrAus commented Jul 16, 2019

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:

What is sval?

sval is a serialization-only framework I've been working on specifically for use in log. sval supports no-std, object-safe serialization for primitives and more complex structures like maps and sequences. It absolves log from 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?

serde is the other serialization framework I've been planning to support in-band in log because it's ubiquitous (and does its job very well). I haven't started with it because:

  • It'll require std to work, because we need erased-serde.
  • sval has out-of-the-box support for serde (including in no-std environments) so adding it first already gives consumers a way to capture implementations of serde::Serialize.

The plan is to also eventually offer serde support.

Impact on build times

When sval is enabled through the kv_unstable_sval feature, it increases our compile times by a little bit:

log Features Dependencies fresh cargo build time (best of 5 runs)
kv_unstable none 1.28s
kv_unstable_sval sval 1.47s

split consumer builds of MSRV from dev builds
@KodrAus KodrAus force-pushed the feat/sval-values branch from 59b89b4 to 368a777 Compare July 16, 2019 23:40
@KodrAus KodrAus changed the title [WIP] Add structured support to kv::Value using sval Add structured support to kv::Value using sval Jul 24, 2019
@KodrAus KodrAus merged commit c098145 into rust-lang:master Jul 24, 2019
@KodrAus KodrAus deleted the feat/sval-values branch July 24, 2019 21:17
EFanZh pushed a commit to EFanZh/log that referenced this pull request Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant