feat: make trace ID and span ID public on OtelData#233
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.
If you disable the context_activation the context won't be created when you enter the span.
|
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
OtelDatastruct.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.