Module predicates

Source
Expand description

Predicates for CapturedSpans and CapturedEvents.

§Overview

A predicate can be created with the functions from this module:

  • level() checks the span / event level
  • name() checks the span name
  • target() checks the span / event target
  • field() checks a specific span / event field
  • message() checks the event message
  • parent() checks the direct parent span of an event / span
  • ancestor() 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§

AncestorPredicate
Predicate for the ancestors of a CapturedSpan or CapturedEvent returned by the ancestor() function.
And
Boolean “and” combinator for predicates. Produced by the bitwise and (&) operator on the base predicates from this module.
FieldPredicate
Predicate for a particular field of a CapturedSpan or CapturedEvent returned by the field() function.
LevelPredicate
Predicate for the Level of a CapturedSpan or CapturedEvent returned by the level() function.
MessagePredicate
Predicate for the message of a CapturedEvent returned by the message() function.
NamePredicate
Predicate for the name of a CapturedSpan returned by the name() function.
Or
Boolean “or” combinator for predicates. Produced by the bitwise or (|) operator on the base predicates from this module.
ParentPredicate
Predicate for the parent of a CapturedSpan or CapturedEvent returned by the parent() function.
Scanner
Helper that allows using Predicates rather than closures to find matching elements, and provides more informative error messages.
TargetPredicate
Predicate for the target of a CapturedSpan or CapturedEvent returned by the target() function.
ValuePredicate
Predicate for TracedValues returned by the value() function.

Traits§

IntoFieldPredicate
Conversion into a predicate for a TracedValue used in the field() function.
IntoLevelPredicate
Conversion into a predicate for Levels used in the level() function.
IntoTargetPredicate
Conversion into a predicate for the target used in the target() function.
ScanExt
Helper to wrap holders of CapturedSpans or CapturedEvents (spans or the underlying Storage) so that they are more convenient to use with Predicates.

Functions§

ancestor
Creates a predicate for ancestor CapturedSpans of a span or a CapturedEvent. 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 CapturedSpan or CapturedEvent.
into_fn
Converts a predicate into an Fn(_) -> bool closure.
level
Creates a predicate for the Level of a CapturedSpan or CapturedEvent.
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 CapturedSpan of a span or a CapturedEvent.
target
Creates a predicate for the target of a CapturedSpan or CapturedEvent.
value
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.