[−][src]Struct cadence::UnixMetricSink
Implementation of a MetricSink
that emits metrics over a Unix socket.
This is the most basic version of MetricSink
that sends metrics over
a Unix socket. It accepts a Unix socket instance over which to write metrics
and the path of the socket for the Statsd server to send metrics to.
Each metric is sent to the Statsd server when the .emit()
method is
called, in the thread of the caller.
Note that unlike the UDP sinks, if there is no receiving socket at the path specified or nothing listening at the path, an error will be returned when metrics are emitted.
Methods
impl UnixMetricSink
[src]
pub fn from<P>(path: P, socket: UnixDatagram) -> UnixMetricSink where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Construct a new UnixMetricSink
instance.
The socket does not need to be bound (i.e. UnixDatagram::unbound()
is
fine) but should have with any desired configuration already applied
(blocking vs non-blocking, timeouts, etc.).
Example
use std::os::unix::net::UnixDatagram; use cadence::UnixMetricSink; let socket = UnixDatagram::unbound().unwrap(); let sink = UnixMetricSink::from("/run/statsd.sock", socket);
To send metrics over a non-blocking socket, simply put the socket in non-blocking mode before creating the Unix metric sink.
Non-blocking Example
use std::os::unix::net::UnixDatagram; use cadence::UnixMetricSink; let socket = UnixDatagram::unbound().unwrap(); socket.set_nonblocking(true).unwrap(); let sink = UnixMetricSink::from("/run/statsd.sock", socket);
Trait Implementations
impl MetricSink for UnixMetricSink
[src]
impl Debug for UnixMetricSink
[src]
Auto Trait Implementations
impl Send for UnixMetricSink
impl Sync for UnixMetricSink
impl Unpin for UnixMetricSink
impl UnwindSafe for UnixMetricSink
impl RefUnwindSafe for UnixMetricSink
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,