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

Formats the value using the given formatter. Read more

Send the Statsd metric using this sink and return the number of bytes written or an I/O error. Read more

Flush any currently buffered metrics to the underlying backend, returning an I/O error if they could not be written for some reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.