-
Notifications
You must be signed in to change notification settings - Fork 742
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
[WIP] opentelemetry-aware event formatter #1304
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Eliza Weisman <[email protected]>
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.
Exciting! Couple of quick ideas for getting things closer to what you may have wanted
.and_then(|span| { | ||
let ext = span.extensions(); | ||
let builder = ext.get::<otel::SpanBuilder>()?; | ||
let tid = builder.trace_id.unwrap_or_else(otel::TraceId::invalid); |
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.
This logic is a little complex currently unfortunately. Basically 3 cases here:
- parent context with active span
- parent context with remote span
- set trace id in builder
So you should see the correct trace ids with something along the lines of:
span.as_ref()
.and_then(|span| {
let ext = span.extensions();
let builder = ext.get::<otel::SpanBuilder>()?;
if let Some(ref parent) = builder.parent_context {
if parent.has_active_span() {
return Some(parent.span().span_context().trace_id());
}
if let Some(remote) = parent.remote_span_context() {
return Some(remote.trace_id());
}
}
builder.trace_id
})
.unwrap_or_else(otel::TraceId::invalid)
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.
thanks! i was having a really hard time figuring out what the right logic here was, that's really helpful.
write!( | ||
writer, | ||
"{{{:?}}}{}:", | ||
remote_parent.trace_state(), |
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.
remote_parent.trace_flags()
may actually be more interesting here as it contains sampling information and is present in all spans, values from the tracestate-header are less common and often opaque to the application anyway
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.
okay, thanks! i wasn't sure which data was more likely to be useful — perhaps we would want an option to show trace flags for local spans as well, for debugging sampling?
i was hoping there was a way to get key-value data, names, etc for remote spans to display in the logs, but it seems like that's not available to us...(which does make sense; we wouldn't want to pass that data around everywhere). is there any way we can hydrate that data from span IDs, or is that not supported?
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.
okay, thanks! i wasn't sure which data was more likely to be useful — perhaps we would want an option to show trace flags for local spans as well, for debugging sampling?
Yeah I think that would make sense as an option 👍
i was hoping there was a way to get key-value data, names, etc for remote spans to display in the logs, but it seems like that's not available to us...(which does make sense; we wouldn't want to pass that data around everywhere). is there any way we can hydrate that data from span IDs, or is that not supported?
That would be interesting but I don't think that it's possible to get information about remote spans currently, you basically just work with a serialized SpanContext
when injecting/extracting.
This seems useful, would love to see it get merged in the future. |
this doesn't quite work yet, but i thought it could be nice to have --- possibly @jtescher has some advice on how to handle remote parents nicely (and, if i'm missing anything that we should be logging?)