Module tracing_capture::predicates
source · Expand description
Predicates for CapturedSpan
s and CapturedEvent
s.
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
CapturedSpan
or CapturedEvent
returned by
the field()
function.Predicate for the message of a
CapturedEvent
returned by the message()
function.Predicate for the name of a
CapturedSpan
returned by the name()
function.Boolean “or” combinator for predicates. Produced by the bitwise or (
|
) operator
on the base predicates from this module.Helper that allows using
Predicate
s rather than closures to find matching elements,
and provides more informative error messages.Predicate for
TracedValue
s returned by the value()
function.Traits
Conversion into a predicate for a
TracedValue
used in the field()
function.Conversion into a predicate for the target used in the
target()
function.Helper to wrap holders of
CapturedSpan
s or CapturedEvent
s
(spans or the underlying Storage
) so that they are more convenient to use with Predicate
s.Functions
Creates a predicate for ancestor
CapturedSpan
s of a span or a CapturedEvent
.
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
CapturedSpan
or CapturedEvent
.Converts a predicate into an
Fn(_) -> bool
closure.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
CapturedSpan
of a span or a CapturedEvent
.Creates a predicate for the target of a
CapturedSpan
or CapturedEvent
.Creates a predicate for a
TracedValue
that 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.