pub struct CapturedEvent<'a> { /* private fields */ }Expand description
Captured tracing event containing a reference to its Metadata and values that the event
was created with.
CapturedEvents are comparable and are partially ordered according
to the capture order. Events are considered equal iff both are aliases of the same event;
i.e., equality is reference-based rather than content-based.
Two events from different Storages are not ordered and are always non-equal.
Values recorded with the event can be accessed by indexing or using Self::value(),
or iterated over using Self::values().
§Examples
let event: CapturedEvent = // ...
// Accessing event metadata and fields:
assert_eq!(*event.metadata().level(), Level::INFO);
assert_eq!(event["return"], 42_u64);
assert_eq!(event.message(), Some("finished computations"));
assert!(event.value("err").is_none());
// Filtering unsigned integer values:
let numbers = event.values().filter_map(|(_, val)| val.as_uint());
// Accessing the parent span:
let parent_name = event.parent().unwrap().metadata().name();
assert!(event
.ancestors()
.any(|span| span.metadata().name() == "test"));Implementations§
Source§impl<'a> CapturedEvent<'a>
impl<'a> CapturedEvent<'a>
Sourcepub fn metadata(&self) -> &'static Metadata<'static>
pub fn metadata(&self) -> &'static Metadata<'static>
Provides a reference to the event 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 associated with the event.
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 message(&self) -> Option<&'a str>
pub fn message(&self) -> Option<&'a str>
Returns the message recorded in this event, i.e., the value of the message field
if it has a string presentation.
Sourcepub fn parent(&self) -> Option<CapturedSpan<'a>>
pub fn parent(&self) -> Option<CapturedSpan<'a>>
Returns the parent span for this event, or None if is not tied to a captured 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.
Trait Implementations§
Source§impl<'a> Captured<'a> for CapturedEvent<'a>
impl<'a> Captured<'a> for CapturedEvent<'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 CapturedEvent<'a>
impl<'a> Clone for CapturedEvent<'a>
Source§fn clone(&self) -> CapturedEvent<'a>
fn clone(&self) -> CapturedEvent<'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 CapturedEvent<'a>
impl<'a> Debug for CapturedEvent<'a>
Source§impl Index<&str> for CapturedEvent<'_>
impl Index<&str> for CapturedEvent<'_>
Source§impl PartialEq for CapturedEvent<'_>
impl PartialEq for CapturedEvent<'_>
Source§impl PartialOrd for CapturedEvent<'_>
impl PartialOrd for CapturedEvent<'_>
Source§impl<P: Predicate<str>> Predicate<CapturedEvent<'_>> for MessagePredicate<P>
impl<P: Predicate<str>> Predicate<CapturedEvent<'_>> for MessagePredicate<P>
Source§fn eval(&self, variable: &CapturedEvent<'_>) -> bool
fn eval(&self, variable: &CapturedEvent<'_>) -> bool
Predicate against variable, returning the resulting
boolean.impl<'a> Copy for CapturedEvent<'a>
impl Eq for CapturedEvent<'_>
Auto Trait Implementations§
impl<'a> Freeze for CapturedEvent<'a>
impl<'a> !RefUnwindSafe for CapturedEvent<'a>
impl<'a> Send for CapturedEvent<'a>
impl<'a> Sync for CapturedEvent<'a>
impl<'a> Unpin for CapturedEvent<'a>
impl<'a> !UnwindSafe for CapturedEvent<'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.