pub struct TraceCapture(/* private fields */);Available on crate feature
test-utils only.Expand description
Records every span and event it sees. Clones share one record, so a test
keeps a clone and installs another with TraceCapture::subscriber.
Field values are JSON: strings and Debug/Display renderings are
strings, integers are numbers and booleans are booleans.
Implementations§
Source§impl TraceCapture
impl TraceCapture
Sourcepub fn subscriber(&self) -> impl Subscriber + Send + Sync + 'static
pub fn subscriber(&self) -> impl Subscriber + Send + Sync + 'static
A registry with this capture as its only layer.
Sourcepub fn spans(&self) -> Vec<CapturedSpan>
pub fn spans(&self) -> Vec<CapturedSpan>
Every span seen so far, in creation order.
Sourcepub fn events(&self) -> Vec<CapturedEvent>
pub fn events(&self) -> Vec<CapturedEvent>
Every event seen so far, in order.
Sourcepub fn last_span(&self) -> Option<CapturedSpan>
pub fn last_span(&self) -> Option<CapturedSpan>
The last span opened so far.
Sourcepub fn values_of(&self, field: &str) -> Vec<Value>
pub fn values_of(&self, field: &str) -> Vec<Value>
Every value field took on any span, at creation or later, span by
span in creation order.
Trait Implementations§
Source§impl Clone for TraceCapture
impl Clone for TraceCapture
Source§impl Default for TraceCapture
impl Default for TraceCapture
Source§impl<S> Layer<S> for TraceCapturewhere
S: Subscriber + for<'a> LookupSpan<'a>,
impl<S> Layer<S> for TraceCapturewhere
S: Subscriber + for<'a> LookupSpan<'a>,
Source§fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)
Notifies this layer that a new span was constructed with the given
Attributes and Id.Source§fn on_record(&self, id: &Id, values: &Record<'_>, _: Context<'_, S>)
fn on_record(&self, id: &Id, values: &Record<'_>, _: Context<'_, S>)
Notifies this layer that a span with the given
Id recorded the given
values.Source§fn on_follows_from(&self, id: &Id, follows: &Id, _: Context<'_, S>)
fn on_follows_from(&self, id: &Id, follows: &Id, _: Context<'_, S>)
Notifies this layer that a span with the ID
span recorded that it
follows from the span with the ID follows.Source§fn on_event(&self, event: &Event<'_>, _: Context<'_, S>)
fn on_event(&self, event: &Event<'_>, _: Context<'_, S>)
Notifies this layer that an event has occurred.
Source§fn on_register_dispatch(&self, subscriber: &Dispatch)
fn on_register_dispatch(&self, subscriber: &Dispatch)
Performs late initialization when installing this layer as a
Subscriber. Read moreSource§fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Registers a new callsite with this layer, returning whether or not
the layer is interested in being notified about the callsite, similarly
to
Subscriber::register_callsite. Read moreSource§fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
Returns
true if this layer is interested in a span or event with the
given metadata in the current Context, similarly to
Subscriber::enabled. Read moreSource§fn on_enter(&self, _id: &Id, _ctx: Context<'_, S>)
fn on_enter(&self, _id: &Id, _ctx: Context<'_, S>)
Notifies this layer that a span with the given ID was entered.
Source§fn on_exit(&self, _id: &Id, _ctx: Context<'_, S>)
fn on_exit(&self, _id: &Id, _ctx: Context<'_, S>)
Notifies this layer that the span with the given ID was exited.
Source§fn on_close(&self, _id: Id, _ctx: Context<'_, S>)
fn on_close(&self, _id: Id, _ctx: Context<'_, S>)
Notifies this layer that the span with the given ID has been closed.
Source§fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
Notifies this layer that a span ID has been cloned, and that the
subscriber returned a different ID.
Source§fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
Composes this layer around the given
Layer, returning a Layered
struct implementing Layer. Read moreSource§fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
Composes this
Layer with the given Subscriber, returning a
Layered struct that implements Subscriber. Read moreSource§fn with_filter<F>(self, filter: F) -> Filtered<Self, F, S>
fn with_filter<F>(self, filter: F) -> Filtered<Self, F, S>
Available on crate features
registry and std only.Auto Trait Implementations§
impl Freeze for TraceCapture
impl RefUnwindSafe for TraceCapture
impl Send for TraceCapture
impl Sync for TraceCapture
impl Unpin for TraceCapture
impl UnsafeUnpin for TraceCapture
impl UnwindSafe for TraceCapture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more