You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Structured logging enhances traditional text-based log records with user-defined attributes. Structured logs can be analyzed using a variety of data processing techniques, without needing to find and parse attributes from unstructured text first.
With JsonFormatter (PR #69) added, the KV can be injected into the output logs as a separated JSON object for parsing by third-party programs.
There are multiple possible implementations for kv::Value: enum (like serde_json::Value), std::any, log::kv::Value (based on crate value-bag), which one is better?
I've started this work today, and trying the first step - implementing kv::Value. Basically I want to make sure that a kv::Value is downcastable and stored at almost zero cost.
There are multiple possible implementations, I'll try to summarize and keep updating the pros and cons of them here.
Make a enum like serde_json::Value ourselves
I prefer not to do this because it requires a lot of code to be written and a lot of effort to keep them interactive.
Its implementation is a bit like enum + any, and external traits are available out of the box. This seems pretty cool. The only drawback is that it comes from an external crate, should we wrap it or just expose it to the user?
Hello! I just happened to notice that the issue I reported about log's KV downcasting was mentioned here, and I figured that I could give my two cents here: the more feature-rich tracing crate also supports structured logging, allowing events (basically, log records) to include typed fields identified by name. This might be worth considering as a reference for implementation as well.
@AlexTMjugador Hi, I'm happy to know that you saw this issue. 😄 Yes, tracing has a large user base and is practically tested, so I'm learning about its implementation of kv as well. Thank you for the information.
Structured logging enhances traditional text-based log records with user-defined attributes. Structured logs can be analyzed using a variety of data processing techniques, without needing to find and parse attributes from unstructured text first.
With
JsonFormatter
(PR #69) added, the KV can be injected into the output logs as a separated JSON object for parsing by third-party programs.Implementation
Working in PR #77.
Details
There are multiple possible implementations for
kv::Value
:enum
(likeserde_json::Value
),std::any
,log::kv::Value
(based on cratevalue-bag
), which one is better?log:kv::Value
issueskv
Value
downcasting rust-lang/log#641Reference
A reference is the
log
kv implementation, we can see if we can improve anything base on that, andtracing
's fields (thanks @AlexTMjugador).There are more references in rust-lang/log#343.
The text was updated successfully, but these errors were encountered: