Struct cadence::BufferedSpyMetricSink
source · [−]pub struct BufferedSpyMetricSink { /* private fields */ }
Expand description
MetricSink
implementation that buffers metrics and writes them to the
Sender
half of a channel while callers are given ownership of the Receiver
half.
This is not a general purpose sink, rather it’s a sink meant for verifying
metrics written during the course of integration tests. By default, the channel
used is unbounded. The channel size can be limited using the with_capacity
method.
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
Trait Implementations
sourceimpl Debug for BufferedSpyMetricSink
impl Debug for BufferedSpyMetricSink
sourceimpl MetricSink for BufferedSpyMetricSink
impl MetricSink for BufferedSpyMetricSink
Auto Trait Implementations
impl RefUnwindSafe for BufferedSpyMetricSink
impl Send for BufferedSpyMetricSink
impl Sync for BufferedSpyMetricSink
impl Unpin for BufferedSpyMetricSink
impl UnwindSafe for BufferedSpyMetricSink
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more