Module tracing_capture::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§

Traits§

Functions§