Skip to content

refactor: marker is mdc #90

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

Merged
merged 11 commits into from
Jan 10, 2025
Merged

refactor: marker is mdc #90

merged 11 commits into from
Jan 10, 2025

Conversation

tisonkun
Copy link
Contributor

@tisonkun tisonkun commented Jan 9, 2025

Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
@tisonkun tisonkun enabled auto-merge (squash) January 10, 2025 06:24
@tisonkun tisonkun merged commit 416242c into main Jan 10, 2025
9 checks passed
@tisonkun tisonkun deleted the apiapi branch January 10, 2025 06:28
}

impl Diagnostic {
pub fn name(&self) -> &'static str {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this method for? Since it's supposed to by dyn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously I use it to filter all the context provided from FastraceDiagnostic in some case.

That is, a key-value in MDC can be considered as (context_name, key_name, value) and implementor of append/layout can filter kvs by either name. But it may not be used now and perhaps over design.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be over designed.. The application, who configurates logforth, has the control over which diagnostic goes through which append. So I don't think it's necessary to let the append filter on diagnostic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in a new PR.

"thread-local"
}

pub fn insert<K, V>(&self, key: K, value: V)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe remove &self?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as rustc can eliminate the overhead, I'd prefer to keep the helper struct to align concepts - https://x.com/tison1096/status/1877365316621115855

Copy link
Contributor

Choose a reason for hiding this comment

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

How could the user, who want's to set the kv, get the MDC to call the methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are the same so it's easy to get a copy by let diag = ThreadLocalDiagnostic::default().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But perhaps ThreadLocalDiagnostic::insert(k, v) would be OK.

});
}

pub fn remove(&self, key: &str) {
Copy link
Contributor

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.

2 participants