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§

Deeply scans all descendants of this span.

Deeply scans all descendant events of this span.

Provides a reference to the span metadata.

Iterates over values that the span was created with, or which were recorded later.

Returns a value for the specified field, or None if the value is not defined.

Returns statistics about span operations.

Returns events attached to this span.

Returns the reference to the parent span, if any.

Returns the references to the ancestor spans, starting from the direct parent and ending in one of root spans.

Iterates over the direct children of this span, in the order of their capture.

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.

Iterates over the descendant events of this span. The iteration order is not specified.

Trait Implementations§

Provides a reference to the span / event metadata.
Returns a value for the specified field, or None if the value is not defined.
Returns the reference to the parent span, if any.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Execute this Predicate against variable, returning the resulting boolean. Read more
Find a case that proves this predicate as expected when run against variable.

Scans for CapturedSpan are shallow, i.e. include only direct children spans / events.

Creates a scanner for the spans contained by this holder. What is meant by “contained” (i.e., whether the scan is deep or shallow), depends on the holder type and is documented at the corresponding impl. Read more
Creates a scanner for the events contained by this holder. What is meant by “contained” (i.e., whether the scan is deep or shallow), depends on the holder type and is documented at the corresponding impl. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.