[][src]Struct cadence::BufferedSpyMetricSink

pub struct BufferedSpyMetricSink { /* fields omitted */ }

MetricSink implementation that buffers metrics and writes them to a shared Write instance that callers retain a reference to.

This is not a general purpose sink, rather it's a sink meant for verifying metrics written during the course of integration tests. Due to the requirement that callers retain a shared reference to the underlying Write implementation, this sink uses more locking (mutexes) than other sinks in Cadence. Thus, it should not be used in production, only testing.

Metrics are line buffered, meaning that a trailing "\n" is added after each metric written to this sink. When the buffer is sufficiently full and a write is attempted, the contents of the buffer are flushed to the underlying writer and then the metric is written to the buffer. The buffer is also flushed when this sink is destroyed.

The default size of the buffer is 512 bytes. This is to be consistent with the default for the BufferedUdpMetricSink. The buffer size can be customized using the with_capacity method to create the sink if desired.

If a metric larger than the buffer is emitted, it will be written directly to the underlying writer, bypassing the buffer.

Note that since metrics are buffered until a certain size is reached, it's possible that they may sit in the buffer for a while for applications that do not emit metrics frequently or at a high volume. For these low- throughput use cases, it may make more sense to use the SpyMetricSink since it sends metrics immediately with no buffering.

Implementations

impl BufferedSpyMetricSink[src]

pub fn from(
    writer: Arc<Mutex<dyn Write + Send + RefUnwindSafe + 'static>>
) -> Self
[src]

pub fn with_capacity(
    writer: Arc<Mutex<dyn Write + Send + RefUnwindSafe + 'static>>,
    cap: usize
) -> Self
[src]

Trait Implementations

impl Debug for BufferedSpyMetricSink[src]

impl MetricSink for BufferedSpyMetricSink[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.