Function tracing_capture::predicates::ancestor
source · pub fn ancestor<P>(matches: P) -> AncestorPredicate<P>where
P: for<'a> Predicate<CapturedSpan<'a>>,
Expand description
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.
§Examples
let storage = SharedStorage::default();
let subscriber = Registry::default().with(CaptureLayer::new(&storage));
tracing::subscriber::with_default(subscriber, || {
let _entered = tracing::info_span!("wrapper").entered();
tracing::info_span!("compute").in_scope(|| {
tracing::info!(answer = 42, "done");
});
});
let storage = storage.lock();
let parent_pred = level(Level::INFO) & name(eq("wrapper"));
let _ = storage.scan_events().single(&ancestor(parent_pred));