Struct tracing_capture::CapturedSpan
source · 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 CapturedEvent
s.
CapturedSpan
s 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 Storage
s 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>
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.