Skip to content

refactor!: make our own key-value type#229

Merged
tisonkun merged 19 commits into
mainfrom
new-kvs
Jun 2, 2026
Merged

refactor!: make our own key-value type#229
tisonkun merged 19 commits into
mainfrom
new-kvs

Conversation

@tisonkun
Copy link
Copy Markdown
Contributor

@tisonkun tisonkun commented Jun 1, 2026

This closes #215

tisonkun added 14 commits May 30, 2026 23:14
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
This reverts commit b4487f6.
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun tisonkun requested a review from andylokandy June 1, 2026 15:55
Signed-off-by: tison <wander4096@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the existing value-bag-based key/value representation with Logforth’s own structured key-value model (Key/Value + borrowed view types), aligning with the goal in #215 to define a first-class “structural logging” viewpoint and enabling more consistent formatting/serialization across layouts, appenders, and bridges.

Changes:

  • Replaced value-bag with new logforth_core::kv types (KeyView/ValueView, ValueOwned, map/list support) and updated all Visitor implementations accordingly.
  • Updated the log bridge to translate log::kv into Logforth’s KV model, with an optional serde feature path for richer typed capture.
  • Adjusted workspace/features (removed value-bag, added bridge-log-serde) and updated examples + CI to use the new feature wiring.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
logforth/Cargo.toml Adds bridge-log-serde feature wiring for the log bridge with serde support.
layouts/text/src/lib.rs Updates KV visiting to use KeyView/ValueView.
layouts/logfmt/src/lib.rs Updates KV visiting to use views; updates built-in KV emission to pass .view() values.
layouts/json/src/lib.rs Updates KV collection to use view types for JSON serialization.
layouts/google-cloud-logging/src/lib.rs Updates KV visiting to use KeyView/ValueView.
examples/Cargo.toml Adds bridge-log-serde feature flag; adjusts example feature requirements and log dev-dep usage.
diagnostics/task-local/src/lib.rs Updates diagnostic KV visiting to use borrowed/view KV types.
diagnostics/fastrace/src/lib.rs Updates emitted KVs + tests for the new KV view/owned model.
core/src/str.rs Adds Deref<Target=str> for RefStr to simplify string access/comparisons.
core/src/record.rs Adjusts record cloning/default KV initialization to match the new KeyValues API.
core/src/layout/plain_text.rs Updates plain-text layout KV visitor signature to view types.
core/src/kv.rs Introduces the new in-house KV data model (Key/Value + view/owned + list/map), plus optional serde serialization.
core/src/diagnostic/thread_local.rs Updates thread-local diagnostic KV visiting to the new API.
core/src/diagnostic/static_global.rs Updates static-global diagnostic KV visiting to the new API.
core/Cargo.toml Removes value-bag and redefines serde feature for core KV serialization.
Cargo.toml Removes value-bag workspace dep; adjusts log workspace dependency feature configuration.
bridges/log/src/lib.rs Refactors log bridge KV translation; adds serde-enabled conversion path.
bridges/log/Cargo.toml Adds serde feature and adjusts log dependency features (kv, std, optional kv_serde).
appenders/opentelemetry/src/lib.rs Updates KV extraction to map ValueView into OpenTelemetry AnyValue (including list/map).
appenders/journald/src/lib.rs Updates journald KV visitor signature to view types.
appenders/journald/src/field.rs Updates field encoding trait impls to accept ValueView.
appenders/fastrace/src/lib.rs Updates KV collection/storage to use view types with fewer allocations where possible.
appenders/async/src/worker.rs Renames diagnostic wrapper and updates visitor calls to .view() for owned keys/values.
appenders/async/src/append.rs Updates diagnostic collection visitor signature to KeyView/ValueView.
.github/workflows/ci.yml Updates CI example invocation to include bridge-log-serde where required.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/kv.rs Outdated
Comment thread bridges/log/src/lib.rs
Comment thread bridges/log/src/lib.rs
Comment thread core/src/kv.rs Outdated
Comment thread bridges/log/src/lib.rs
Comment thread bridges/log/src/lib.rs
tisonkun added 3 commits June 2, 2026 00:26
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Comment thread Cargo.toml
Comment thread core/src/kv.rs
Comment thread core/src/kv.rs
Signed-off-by: tison <wander4096@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Comment thread examples/Cargo.toml
Comment thread logforth/Cargo.toml
@tisonkun tisonkun merged commit c07d5f8 into main Jun 2, 2026
11 checks passed
@tisonkun tisonkun deleted the new-kvs branch June 2, 2026 00:34
@ariesdevil
Copy link
Copy Markdown

Should we fire a new release for this?

@tisonkun
Copy link
Copy Markdown
Contributor Author

tisonkun commented Jun 2, 2026

@ariesdevil for sure. We'd need a core 0.4 and all subcrates. Also the facade to be 0.30.

Actually, end users shall not touch these internals.

But I'm working on #230 before we cut the next release or it would be a quick breaking.

Comment thread core/src/kv.rs
pub struct KeyOwned(Cow<'static, str>);
impl fmt::Debug for DebugValue<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.0.fmt(f)

Comment thread core/src/kv.rs
})
impl fmt::Display for DebugValue<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review key-values

3 participants