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§
- Ancestor
Predicate - Predicate for the ancestors of a
CapturedSpanorCapturedEventreturned by theancestor()function. - And
- Boolean “and” combinator for predicates. Produced by the bitwise and (
&) operator on the base predicates from this module. - Field
Predicate - Predicate for a particular field of a
CapturedSpanorCapturedEventreturned by thefield()function. - Level
Predicate - Predicate for the
Levelof aCapturedSpanorCapturedEventreturned by thelevel()function. - Message
Predicate - Predicate for the message of a
CapturedEventreturned by themessage()function. - Name
Predicate - Predicate for the name of a
CapturedSpanreturned by thename()function. - Or
- Boolean “or” combinator for predicates. Produced by the bitwise or (
|) operator on the base predicates from this module. - Parent
Predicate - Predicate for the parent of a
CapturedSpanorCapturedEventreturned by theparent()function. - Scanner
- Helper that allows using
Predicates rather than closures to find matching elements, and provides more informative error messages. - Target
Predicate - Predicate for the target of a
CapturedSpanorCapturedEventreturned by thetarget()function. - Value
Predicate - Predicate for
TracedValues returned by thevalue()function.
Traits§
- Into
Field Predicate - Conversion into a predicate for a
TracedValueused in thefield()function. - Into
Level Predicate - Conversion into a predicate for
Levels used in thelevel()function. - Into
Target Predicate - Conversion into a predicate for the target used in the
target()function. - ScanExt
- Helper to wrap holders of
CapturedSpans orCapturedEvents (spans or the underlyingStorage) so that they are more convenient to use withPredicates.
Functions§
- ancestor
- 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. - field
- Creates a predicate for a particular field of a
CapturedSpanorCapturedEvent. - into_fn
- Converts a predicate into an
Fn(_) -> boolclosure. - level
- Creates a predicate for the
Levelof aCapturedSpanorCapturedEvent. - message
- Creates a predicate for the message of a
CapturedEvent. - name
- Creates a predicate for the name of a
CapturedSpan. - parent
- Creates a predicate for the direct parent
CapturedSpanof a span or aCapturedEvent. - target
- Creates a predicate for the target of a
CapturedSpanorCapturedEvent. - value
- 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.