pub struct CapturedSpan<'a> { /* private fields */ }Expand description
Captured tracing span containing a reference to its Metadata, values that the span
was created with, stats, and descendant CapturedEvents.
CapturedSpans are comparable and are partially ordered according
to the capture order. Spans are considered equal iff both are aliases of the same span;
i.e., equality is reference-based rather than content-based.
Two spans from different Storages are not ordered and are always non-equal.
Values recorded with the span can be accessed by indexing or using Self::value(),
or iterated over using Self::values().
§Examples
let span: CapturedSpan = // ...
// Accessing event metadata and fields:
assert_eq!(*span.metadata().level(), Level::INFO);
assert_eq!(span["arg"], 42_u64);
assert!(span.value("other_arg").is_none());
// Filtering unsigned integer values:
let numbers = span.values().filter_map(|(_, val)| val.as_uint());
// Accessing the parent span:
let parent_name = span.parent().unwrap().metadata().name();
assert!(span
.ancestors()
.any(|span| span.metadata().name() == "test"));
// Accessing child spans and events:
assert!(span.children().len() > 0);
let child_messages: Vec<&str> = span
.events()
.filter_map(|event| event.message())
.collect();
let descendant_span =
span.descendants().find(|span| span["input"] == "!").unwrap();Implementations§
Source§impl<'a> CapturedSpan<'a>
impl<'a> CapturedSpan<'a>
Sourcepub fn deep_scan_spans(self) -> Scanner<Self, DescendantSpans<'a>>
pub fn deep_scan_spans(self) -> Scanner<Self, DescendantSpans<'a>>
Deeply scans all descendants of this span.
Sourcepub fn deep_scan_events(self) -> Scanner<Self, DescendantEvents<'a>>
pub fn deep_scan_events(self) -> Scanner<Self, DescendantEvents<'a>>
Deeply scans all descendant events of this span.
Source§impl<'a> CapturedSpan<'a>
impl<'a> CapturedSpan<'a>
Sourcepub fn metadata(&self) -> &'static Metadata<'static>
pub fn metadata(&self) -> &'static Metadata<'static>
Provides a reference to the span metadata.
Sourcepub fn values(&self) -> impl Iterator<Item = (&'a str, &'a TracedValue)> + 'a
pub fn values(&self) -> impl Iterator<Item = (&'a str, &'a TracedValue)> + 'a
Iterates over values that the span was created with, or which were recorded later.
Sourcepub fn value(&self, name: &str) -> Option<&'a TracedValue>
pub fn value(&self, name: &str) -> Option<&'a TracedValue>
Returns a value for the specified field, or None if the value is not defined.
Sourcepub fn events(&self) -> CapturedEvents<'a> ⓘ
pub fn events(&self) -> CapturedEvents<'a> ⓘ
Returns events attached to this span.
Sourcepub fn ancestors(&self) -> impl Iterator<Item = CapturedSpan<'a>> + '_
pub fn ancestors(&self) -> impl Iterator<Item = CapturedSpan<'a>> + '_
Returns the references to the ancestor spans, starting from the direct parent and ending in one of root spans.
Sourcepub fn children(&self) -> CapturedSpans<'a> ⓘ
pub fn children(&self) -> CapturedSpans<'a> ⓘ
Iterates over the direct children of this span, in the order of their capture.
Sourcepub fn descendants(&self) -> DescendantSpans<'a> ⓘ
pub fn descendants(&self) -> DescendantSpans<'a> ⓘ
Iterates over the descendants of this span.
In the simplest case (spans are not re-entered, span parents are contextual), the iteration order is the span capture order. In the general case, no particular order is guaranteed.
Sourcepub fn descendant_events(&self) -> DescendantEvents<'a> ⓘ
pub fn descendant_events(&self) -> DescendantEvents<'a> ⓘ
Iterates over the descendant events of this span. The iteration order is not specified.
Trait Implementations§
Source§impl<'a> Captured<'a> for CapturedSpan<'a>
impl<'a> Captured<'a> for CapturedSpan<'a>
Source§fn metadata(&self) -> &'static Metadata<'static>
fn metadata(&self) -> &'static Metadata<'static>
Source§fn value(&self, name: &str) -> Option<&'a TracedValue>
fn value(&self, name: &str) -> Option<&'a TracedValue>
None if the value is not defined.Source§fn parent(&self) -> Option<CapturedSpan<'a>>
fn parent(&self) -> Option<CapturedSpan<'a>>
Source§impl<'a> Clone for CapturedSpan<'a>
impl<'a> Clone for CapturedSpan<'a>
Source§fn clone(&self) -> CapturedSpan<'a>
fn clone(&self) -> CapturedSpan<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for CapturedSpan<'a>
impl<'a> Debug for CapturedSpan<'a>
Source§impl Index<&str> for CapturedSpan<'_>
impl Index<&str> for CapturedSpan<'_>
Source§impl PartialEq for CapturedSpan<'_>
impl PartialEq for CapturedSpan<'_>
Source§impl PartialOrd for CapturedSpan<'_>
impl PartialOrd for CapturedSpan<'_>
Source§impl<P: Predicate<str>> Predicate<CapturedSpan<'_>> for NamePredicate<P>
impl<P: Predicate<str>> Predicate<CapturedSpan<'_>> for NamePredicate<P>
Source§fn eval(&self, variable: &CapturedSpan<'_>) -> bool
fn eval(&self, variable: &CapturedSpan<'_>) -> bool
Predicate against variable, returning the resulting
boolean.Source§impl<'a> ScanExt<'a> for CapturedSpan<'a>
Scans for CapturedSpan are shallow, i.e. include only direct children spans / events.
impl<'a> ScanExt<'a> for CapturedSpan<'a>
Scans for CapturedSpan are shallow, i.e. include only direct children spans / events.
Source§fn scan_spans(self) -> Scanner<Self, CapturedSpans<'a>>
fn scan_spans(self) -> Scanner<Self, CapturedSpans<'a>>
Source§fn scan_events(self) -> Scanner<Self, CapturedEvents<'a>>
fn scan_events(self) -> Scanner<Self, CapturedEvents<'a>>
impl<'a> Copy for CapturedSpan<'a>
impl Eq for CapturedSpan<'_>
Auto Trait Implementations§
impl<'a> Freeze for CapturedSpan<'a>
impl<'a> !RefUnwindSafe for CapturedSpan<'a>
impl<'a> Send for CapturedSpan<'a>
impl<'a> Sync for CapturedSpan<'a>
impl<'a> Unpin for CapturedSpan<'a>
impl<'a> !UnwindSafe for CapturedSpan<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.