pub struct Sink<T: Clone + Eq + Hash + Display> { /* private fields */ }Expand description
Handle for sending metric samples into the receiver.
Sink is cloneable, and can not only send metric samples but can register and deregister
metric facets at any time.
Implementations§
Source§impl<T: Clone + Eq + Hash + Display> Sink<T>
impl<T: Clone + Eq + Hash + Display> Sink<T>
Sourcepub fn scoped<'a, S: AsScoped<'a> + ?Sized>(&self, scope: &'a S) -> Sink<T>
pub fn scoped<'a, S: AsScoped<'a> + ?Sized>(&self, scope: &'a S) -> Sink<T>
Creates a scoped clone of this Sink.
Scoping controls the resulting metric name for any metrics sent by this Sink. For
example, you might have a metric called messages_sent.
With scoping, you could have independent versions of the same metric. This is useful for having the same “base” metric name but with broken down values.
Going further with the above example, if you had a server, and listened on multiple
addresses, maybe you would have a scoped Sink per listener, and could end up with
metrics that look like this:
listener.a.messages_sentlistener.b.messages_sentlistener.c.messages_sent- etc
Scopes are also inherited. If you create a scoped Sink from another Sink which is
already scoped, the scopes will be merged together using a . as the string separator.
This makes it easy to nest scopes. Cloning a scoped Sink, though, will inherit the
same scope as the original.
Sourcepub fn update_count(&self, key: T, delta: i64)
pub fn update_count(&self, key: T, delta: i64)
Updates the count for a given metric.
Sourcepub fn update_gauge(&self, key: T, value: u64)
pub fn update_gauge(&self, key: T, value: u64)
Updates the value for a given metric.
This can be used either for setting a gauge or updating a value histogram.
Sourcepub fn update_timing(&self, key: T, start: u64, end: u64)
pub fn update_timing(&self, key: T, start: u64, end: u64)
Updates the timing histogram for a given metric.
Sourcepub fn update_timing_with_count(&self, key: T, start: u64, end: u64, count: u64)
pub fn update_timing_with_count(&self, key: T, start: u64, end: u64, count: u64)
Updates the timing histogram for a given metric, with a count.
Sourcepub fn update_value(&self, key: T, value: u64)
pub fn update_value(&self, key: T, value: u64)
Updates the value histogram for a given metric.