We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0edb571 commit 72be0dcCopy full SHA for 72be0dc
1 file changed
src/formatter.rs
@@ -45,8 +45,14 @@ where
45
S: Subscriber + for<'a> LookupSpan<'a>,
46
{
47
span_ref.extensions().get::<OtelData>().map(|o| {
48
- let parent_id = o.parent_cx.span().span_context().trace_id();
49
- let trace_id = o.builder.trace_id.unwrap_or(parent_id);
+ // If the parent ID is empty/0 - then fall back to the builder's ID
+ let parent_span_cx = o.parent_cx.span();
50
+
51
+ let trace_id = if parent_span_cx.span_context().trace_id() != TraceId::INVALID {
52
+ parent_span_cx.span_context().trace_id()
53
+ } else {
54
+ o.builder.trace_id.unwrap_or(TraceId::INVALID)
55
+ };
56
TraceInfo {
57
trace_id: trace_id.into(),
58
span_id: o.builder.span_id.unwrap_or(SpanId::INVALID).into(),
0 commit comments