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

Predicate for the ancestors of a CapturedSpan or CapturedEvent returned by the ancestor() function.
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 Level of a CapturedSpan or CapturedEvent returned by the level() 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.
Predicate for the parent of a CapturedSpan or CapturedEvent returned by the parent() function.
Helper that allows using Predicates rather than closures to find matching elements, and provides more informative error messages.
Predicate for the target of a CapturedSpan or CapturedEvent returned by the target() function.
Predicate for TracedValues returned by the value() function.

Traits

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

Functions

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.
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 Level of a CapturedSpan or CapturedEvent.
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.