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
impl QueuingMetricSinkBuilder
sourcepub fn build<T>(self, sink: T) -> QueuingMetricSink
pub fn build<T>(self, sink: T) -> QueuingMetricSink
Construct a new QueuingMetricSink
instance wrapping another sink based on
the builder configuration.
sourcepub fn with_error_handler<F>(self, error_handler: F) -> Self
pub fn with_error_handler<F>(self, error_handler: F) -> Self
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.
sourcepub fn with_capacity(self, capacity: usize) -> Self
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
impl Default for QueuingMetricSinkBuilder
source§fn default() -> QueuingMetricSinkBuilder
fn default() -> QueuingMetricSinkBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for QueuingMetricSinkBuilder
impl RefUnwindSafe for QueuingMetricSinkBuilder
impl Send for QueuingMetricSinkBuilder
impl Sync for QueuingMetricSinkBuilder
impl Unpin for QueuingMetricSinkBuilder
impl !UnwindSafe for QueuingMetricSinkBuilder
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