diff --git a/tracing-core/src/span.rs b/tracing-core/src/span.rs index c793841de6..8f5b6101f6 100644 --- a/tracing-core/src/span.rs +++ b/tracing-core/src/span.rs @@ -1,4 +1,5 @@ //! Spans represent periods of time in the execution of a program. +use crate::field::FieldSet; use crate::parent::Parent; use crate::stdlib::num::NonZeroU64; use crate::{field, Metadata}; @@ -196,6 +197,21 @@ impl<'a> Attributes<'a> { pub fn is_empty(&self) -> bool { self.values.is_empty() } + + /// Returns the set of all [fields] defined by this span's [`Metadata`]. + /// + /// Note that the [`FieldSet`] returned by this method includes *all* the + /// fields declared by this span, not just those with values that are recorded + /// as part of this set of `Attributes`. Other fields with values not present in + /// this `Attributes`' value set may [record] values later. + /// + /// [fields]: crate::field + /// [record]: Attributes::record() + /// [`Metadata`]: crate::metadata::Metadata + /// [`FieldSet`]: crate::field::FieldSet + pub fn fields(&self) -> &FieldSet { + self.values.field_set() + } } // ===== impl Record =====