Struct cadence::QueuingMetricSinkBuilder

source ·
pub struct QueuingMetricSinkBuilder { /* private fields */ }
Expand description

Implementation of a builder pattern for QueuingMetricSink.

The builder can be used to set an error handler for the sink being wrapped by a QueuingMetricSink as well as setting the capacity of the QueuingMetricSink.

§Example

use cadence::{MetricSink, QueuingMetricSinkBuilder, NopMetricSink};

let queue_size = 64 * 1024;
let wrapped = NopMetricSink;

let queuing = QueuingMetricSinkBuilder::new()
    .with_capacity(queue_size)
    .with_error_handler(|e| {
        eprintln!("Error while sending metrics: {:?}", e);
    })
    .build(wrapped);

queuing.emit("foo.counter:4|c");

Implementations§

source§

impl QueuingMetricSinkBuilder

source

pub fn new() -> Self

Construct a new builder.

source

pub fn build<T>(self, sink: T) -> QueuingMetricSink
where T: MetricSink + Sync + Send + RefUnwindSafe + 'static,

Construct a new QueuingMetricSink instance wrapping another sink based on the builder configuration.

source

pub fn with_error_handler<F>(self, error_handler: F) -> Self
where F: Fn(Error) + Sync + Send + RefUnwindSafe + 'static,

Set error handler called when the wrapped sink fails to emit a metric.

The error handler will be run in the same thread as the wrapped sink and must not panic.

source

pub fn with_capacity(self, capacity: usize) -> Self

Set queue size used to send metrics to the wrapped sink.

See QueuingMetricSink::with_capacity for more information.

Trait Implementations§

source§

impl Default for QueuingMetricSinkBuilder

source§

fn default() -> QueuingMetricSinkBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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>,

§

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>,

§

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.