Skip to main content

SamplingLayerBuilder

Struct SamplingLayerBuilder 

Source
pub struct SamplingLayerBuilder<S, N = DefaultFields, E = Format<Full>, W = fn() -> Stderr> { /* private fields */ }
Expand description

Builder for SamplingLayer.

Created via SamplingLayer::builder().

Implementations§

Source§

impl<S, N, E, W> SamplingLayerBuilder<S, N, E, W>

Source

pub fn budget(self, filter: EnvFilter, limit_per_second: u64) -> Self

Add a sampling budget with an EnvFilter and a per-second event limit.

Budgets whose limit rounds to zero events per bucket are skipped.

Source

pub fn bucket_duration(self, duration: Duration) -> Self

Set the time bucket duration. Defaults to 50ms.

Source

pub fn writer<W2>(self, writer: W2) -> SamplingLayerBuilder<S, N, E, W2>

Set the output writer. Defaults to stderr.

Source§

impl<S, N, E, W> SamplingLayerBuilder<S, N, E, W>
where S: Subscriber + for<'a> LookupSpan<'a>, N: for<'writer> FormatFields<'writer> + 'static, E: FormatEvent<S, N> + 'static,

Source

pub fn event_format<E2>(self, e: E2) -> SamplingLayerBuilder<S, N, E2, W>
where E2: FormatEvent<S, N> + 'static,

Sets the event formatter.

Source

pub fn map_event_format<E2>( self, f: impl FnOnce(E) -> E2, ) -> SamplingLayerBuilder<S, N, E2, W>
where E2: FormatEvent<S, N> + 'static,

Updates the event formatter by applying a function to the existing one.

Source

pub fn fmt_fields<N2>(self, fmt_fields: N2) -> SamplingLayerBuilder<S, N2, E, W>
where N2: for<'writer> FormatFields<'writer> + 'static,

Sets the field formatter.

Source§

impl<S, N, L, T, W> SamplingLayerBuilder<S, N, Format<L, T>, W>
where N: for<'writer> FormatFields<'writer> + 'static,

Source

pub fn without_time(self) -> SamplingLayerBuilder<S, N, Format<L, ()>, W>

Do not emit timestamps.

Source

pub fn with_target(self, display_target: bool) -> Self

Sets whether or not an event’s target is displayed.

Source

pub fn with_level(self, display_level: bool) -> Self

Sets whether or not an event’s level is displayed.

Source

pub fn compact(self) -> SamplingLayerBuilder<S, N, Format<Compact, T>, W>
where N: for<'writer> FormatFields<'writer> + 'static,

Use the compact formatter.

Source§

impl<S, N, E, W> SamplingLayerBuilder<S, N, E, W>
where W: for<'a> MakeWriter<'a> + 'static, S: Subscriber + for<'a> LookupSpan<'a>, N: for<'writer> FormatFields<'writer> + 'static, E: FormatEvent<S, N> + 'static,

Source

pub fn build(self) -> (SamplingLayer<S, N, E, W>, Stats)

Consume the builder and create a SamplingLayer and a Stats handle for reading event counters.

Auto Trait Implementations§

§

impl<S, N = DefaultFields, E = Format, W = fn() -> Stderr> !Freeze for SamplingLayerBuilder<S, N, E, W>

§

impl<S, N, E, W> RefUnwindSafe for SamplingLayerBuilder<S, N, E, W>

§

impl<S, N, E, W> Send for SamplingLayerBuilder<S, N, E, W>
where W: Send, N: Send, E: Send,

§

impl<S, N, E, W> Sync for SamplingLayerBuilder<S, N, E, W>
where W: Sync, N: Sync, E: Sync,

§

impl<S, N, E, W> Unpin for SamplingLayerBuilder<S, N, E, W>
where W: Unpin, N: Unpin, E: Unpin,

§

impl<S, N, E, W> UnsafeUnpin for SamplingLayerBuilder<S, N, E, W>

§

impl<S, N, E, W> UnwindSafe for SamplingLayerBuilder<S, N, E, W>
where W: UnwindSafe, N: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more