diff --git a/tracing-subscriber/src/fmt/fmt_layer.rs b/tracing-subscriber/src/fmt/fmt_layer.rs index 21c30d14bf..d350e8150d 100644 --- a/tracing-subscriber/src/fmt/fmt_layer.rs +++ b/tracing-subscriber/src/fmt/fmt_layer.rs @@ -8,7 +8,7 @@ use format::{FmtSpan, TimingDisplay}; use std::{any::TypeId, cell::RefCell, fmt, io, marker::PhantomData, ops::Deref, time::Instant}; use tracing_core::{ field, - span::{Attributes, Id, Record}, + span::{Attributes, Current, Id, Record}, Event, Metadata, Subscriber, }; @@ -856,6 +856,11 @@ where self.ctx.scope() } + /// Returns the current span for this formatter. + pub fn current_span(&self) -> Current { + self.ctx.current_span() + } + /// Returns the [field formatter] configured by the subscriber invoking /// `format_event`. ///