[−][src]Struct cadence::BufferedSpyMetricSink
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]
writer: Arc<Mutex<dyn Write + Send + RefUnwindSafe + 'static>>
) -> Self
pub fn with_capacity(
writer: Arc<Mutex<dyn Write + Send + RefUnwindSafe + 'static>>,
cap: usize
) -> Self
[src]
writer: Arc<Mutex<dyn Write + Send + RefUnwindSafe + 'static>>,
cap: usize
) -> Self
Trait Implementations
impl Debug for BufferedSpyMetricSink
[src]
impl MetricSink for BufferedSpyMetricSink
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,