-
Notifications
You must be signed in to change notification settings - Fork 113
feat: make trace ID and span ID public on OtelData
#233
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
9f60144
to
ef46bf7
Compare
cc @cschramm and @ollyswanson if you think this is good enough. What wouldn't specifically work is something like let span = tracing::debug_span!("root");
tracing::error!(parent: &span, " :( "); while starting the span would work let span = tracing::debug_span!("root");
let _guard = span.entered();
tracing::error!(" :) "); |
Works perfectly fine for my use case, where I use the dispatcher's current span (or rather its root span, by traversing the parents). If I'm not mistaken, that should always be entered. |
If you're talking about But generally, people tend to use enter spans rather than explicitly setting the parent so you should be mostly fine. |
Hey @mladedav I'm working on making it possible to get the |
src/lib.rs
Outdated
/// Gets the trace ID of the span. | ||
/// | ||
/// Returns `None` if the context has not been built yet. This can be forced e.g. by calling | ||
/// [`context`] on the span (not on `OtelData`) or simply entering the span for the first time. |
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.
If you disable the context_activation
the context won't be created when you enter the span.
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, fixed.
I opened #234 as another solution |
For simplicity, I'd go with making it public again. We can deprecate this in the next version (and add the context activation-based approach in a point release whenever we want). |
ef46bf7
to
68dd8ed
Compare
Motivation
Get the IDs from the
OtelData
struct.Closes #227
Solution
When the context is started, we can get the IDs.
There is however nothing to report when the context is not yet fully built. But if it is not, there is not span ID to report and reporting the parent span's trace ID from the builder may not be correct as that may still change.