Skip to content

refactor!: rework TaskLocalDiagnostic#234

Open
tisonkun wants to merge 6 commits into
mainfrom
task-local
Open

refactor!: rework TaskLocalDiagnostic#234
tisonkun wants to merge 6 commits into
mainfrom
task-local

Conversation

@tisonkun
Copy link
Copy Markdown
Contributor

@tisonkun tisonkun commented Jun 6, 2026

No description provided.

tisonkun added 3 commits June 6, 2026 15:57
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

This PR refactors task-local diagnostics to store structured key/value data using the core KeyOwned/ValueOwned types, improving ergonomics for attaching context to async tasks and aligning task-local diagnostics with the core KV model.

Changes:

  • Reworked TaskLocalDiagnostic to store Vec<(KeyOwned, ValueOwned)> and updated FutureExt::with_task_local_context to accept any (K, V) where K: Into<KeyOwned> and V: Into<ValueOwned>.
  • Extended core KV types with additional From conversions and made KeyView/ValueView Copy to simplify usage in visitors/serialization.
  • Minor doc wording updates and small serialization call-site adjustments in JSON-based layouts.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
layouts/json/src/lib.rs Adjusts KV-to-JSON conversion call site for ValueView.
layouts/google-cloud-logging/src/lib.rs Same KV-to-JSON conversion adjustment for GCL layout fields/labels.
filters/rustlog/src/lib.rs Doc wording tweak for crate-level documentation link text.
diagnostics/task-local/src/lib.rs Stores owned KV pairs in task-local storage; makes with_task_local_context more flexible.
core/src/kv.rs Adds From impls for owned KV types; makes KeyView/ValueView Copy.
appenders/syslog/src/lib.rs Doc wording tweak for crate-level documentation link text.
appenders/file/src/append.rs Doc wording tweak for crate-level documentation link text.

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

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 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread diagnostics/task-local/src/lib.rs Outdated
Signed-off-by: tison <wander4096@gmail.com>
Comment thread core/src/kv.rs
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we can ensure View and Borrowed Key/Value always Copy but I suggest it is the right design and we should keep it as much as possible.

Comment thread core/src/kv.rs
Comment on lines +33 to +40
impl<F> Visitor for F
where
F: FnMut(KeyView, ValueView) -> Result<(), Error>,
{
fn visit(&mut self, key: KeyView, value: ValueView) -> Result<(), Error> {
self(key, value)
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Explicitly should be better. But this impl looks very common to support; as in this PR:

diag.visit(&mut |key: KeyView<'_>, value: ValueView<'_>| {
    assert_eq!(key.as_str(), "key");
    assert_eq!(value.to_str().unwrap(), "value");
    Ok(())
})
.unwrap();

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 9 out of 9 changed files in this pull request and generated no new comments.

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.

2 participants