-
Notifications
You must be signed in to change notification settings - Fork 15
feat: support attaching trace id to log #88
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
Conversation
|
||
use crate::Marker; | ||
|
||
// TODO(tisonkun): use trait alias when it's stable - https://github.com/rust-lang/rust/issues/41517 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps not my ID here XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to align with the same comment in CustomLayout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go. But I may need one more round to consider whether Marker
a good abstraction. It looks added random kvs with very niche use case .. I can't map it to other common log concepts.
very niche use case
That said, we add bridges for it everywhere but use it under a very specific way.
src/marker/mod.rs
Outdated
#[cfg(feature = "fastrace")] | ||
mod fastrace; | ||
|
||
/// Represents a layout for formatting log records. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it's not a layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
It's mainly to extract context where the log is emitted. User can attach tokio's task_id, thread_id or cpu_id. |
@@ -55,6 +56,7 @@ pub struct OpentelemetryLogBuilder { | |||
protocol: Protocol, | |||
labels: Vec<(Cow<'static, str>, Cow<'static, str>)>, | |||
layout: Option<Layout>, | |||
marker: Option<Marker>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused why Marker
is an Option
. It looks like arbitrary kvs to be attached, then it can be 0 to n?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because user may not provide a marker implementation. If not using Option
, we have to provide a NoopMarker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, it may not be 0 or 1, but 0 to n.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It can provide 0 to n extra kvs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. I get it now .. The marker is the context (driver) and the f
passed in is the method to populate kvs..
This looks like some concepts like MDC - https://logback.qos.ch/manual/mdc.html |
I think it's similar concept. But MDC is hardly a better name IMO... |
Agreed. I get it now the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the point and each concept's reason now.
Let's merge it first while hold the release for a few days to consider possibly better name and code structure.
let root = Span::root("root", SpanContext::random()); | ||
let _g = root.set_local_parent(); | ||
|
||
log::error!("Hello syslog error!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops. need to correct in the next pr.
No description provided.