Expand description
Predicates for CapturedSpans and CapturedEvents.
§Overview
A predicate can be created with the functions from this module:
level()checks the span / event levelname()checks the span nametarget()checks the span / event targetfield()checks a specific span / event fieldmessage()checks the event messageparent()checks the direct parent span of an event / spanancestor()checks the ancestor spans of an event / span
These predicates can be combined with bitwise operators, & and |.
The ScanExt trait may be used to simplify assertions with predicates. The remaining
traits and structs are lower-level plumbing and rarely need to be used directly.
§Examples
// Predicates can be combined using bitwise operators:
let predicate = target([eq("tracing")])
& name(eq("test_capture"))
& level(Level::INFO)
& field("result", 42_i64);
// The resulting predicate can be used with `CapturedExt` trait.
let storage: &Storage = // ...
let _ = storage.scan_spans().first(&predicate);
let _ = storage.scan_events().single(&level(Level::ERROR));
// ...or converted back to a closure:
let _ = storage.all_spans().filter(into_fn(predicate));Structs§
- Boolean “and” combinator for predicates. Produced by the bitwise and (
&) operator on the base predicates from this module. - Predicate for a particular field of a
CapturedSpanorCapturedEventreturned by thefield()function. - Predicate for the message of a
CapturedEventreturned by themessage()function. - Predicate for the name of a
CapturedSpanreturned by thename()function. - Boolean “or” combinator for predicates. Produced by the bitwise or (
|) operator on the base predicates from this module. - Helper that allows using
Predicates rather than closures to find matching elements, and provides more informative error messages. - Predicate for
TracedValues returned by thevalue()function.
Traits§
- Conversion into a predicate for a
TracedValueused in thefield()function. - Conversion into a predicate for [
Level]s used in thelevel()function. - Conversion into a predicate for the target used in the
target()function. - Helper to wrap holders of
CapturedSpans orCapturedEvents (spans or the underlyingStorage) so that they are more convenient to use withPredicates.
Functions§
- Creates a predicate for ancestor
CapturedSpans of a span or aCapturedEvent. The predicate is true iff the wrapped span predicate holds true for any of the ancestors. - Creates a predicate for a particular field of a
CapturedSpanorCapturedEvent. - Converts a predicate into an
Fn(_) -> boolclosure. - Creates a predicate for the message of a
CapturedEvent. - Creates a predicate for the name of a
CapturedSpan. - Creates a predicate for the direct parent
CapturedSpanof a span or aCapturedEvent. - Creates a predicate for the target of a
CapturedSpanorCapturedEvent. - Creates a predicate for a
TracedValuethat checks whether the value matches the specified criteria for a particular subtype (e.g., an unsigned integer). If the value has another subtype, the predicate is false.