Function tracing_capture::predicates::name
source · pub fn name<P: Predicate<str>>(matches: P) -> NamePredicate<P>
Expand description
Creates a predicate for the name of a CapturedSpan
.
§Arguments
The argument of this function can be any str
ing predicate, e.g. eq("test")
for
exact comparison.
§Examples
let storage = SharedStorage::default();
let subscriber = Registry::default().with(CaptureLayer::new(&storage));
tracing::subscriber::with_default(subscriber, || {
tracing::info_span!("compute").in_scope(|| {
tracing::info!(answer = 42, "done");
});
});
let storage = storage.lock();
// All of these access the single captured span.
let spans = storage.scan_spans();
let _ = spans.single(&name(eq("compute")));
let _ = spans.single(&name(starts_with("co")));