Skip to content

Commit

Permalink
revert trace ID resolution logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Fergus Dixon committed Oct 24, 2023
1 parent 72be0dc commit 229de5a
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::io;

use chrono::Utc;
use opentelemetry::trace::{SpanId, TraceContextExt, TraceId};
use opentelemetry::trace::{SpanId, TraceId};
use serde::ser::{SerializeMap, Serializer as _};
use serde::Serialize;
use tracing::{Event, Subscriber};
Expand Down Expand Up @@ -44,19 +44,9 @@ fn lookup_trace_info<S>(span_ref: &SpanRef<S>) -> Option<TraceInfo>
where
S: Subscriber + for<'a> LookupSpan<'a>,
{
span_ref.extensions().get::<OtelData>().map(|o| {
// If the parent ID is empty/0 - then fall back to the builder's ID
let parent_span_cx = o.parent_cx.span();

let trace_id = if parent_span_cx.span_context().trace_id() != TraceId::INVALID {
parent_span_cx.span_context().trace_id()
} else {
o.builder.trace_id.unwrap_or(TraceId::INVALID)
};
TraceInfo {
trace_id: trace_id.into(),
span_id: o.builder.span_id.unwrap_or(SpanId::INVALID).into(),
}
span_ref.extensions().get::<OtelData>().map(|o| TraceInfo {
trace_id: o.builder.trace_id.unwrap_or(TraceId::INVALID).into(),
span_id: o.builder.span_id.unwrap_or(SpanId::INVALID).into(),
})
}

Expand Down

0 comments on commit 229de5a

Please sign in to comment.