pub struct MetricsPusher { /* private fields */ }Expand description
Facilitates the push-style publishing of metrics.
When creating a push-mode event, you must provide an instance of MetricsPusher to the event
builder. This instance is typically stored in a thread-local static variable.
On a regular basis, you must then call the push method on this instance to publish the metrics
to a storage location where they can be included in reports.
Implementations§
Source§impl MetricsPusher
impl MetricsPusher
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new MetricsPusher instance.
§Example
use nm::MetricsPusher;
thread_local! {
static PUSHER: MetricsPusher = MetricsPusher::new();
}Sourcepub fn push(&self)
pub fn push(&self)
Pushes the metrics to a storage location where they can be included in reports.
This method should be called periodically to ensure that push-model metrics are published.
§Example
use nm::{Event, MetricsPusher, Push};
thread_local! {
static PUSHER: MetricsPusher = MetricsPusher::new();
static PUSH_EVENT: Event<Push> = Event::builder()
.name("push_example")
.pusher_local(&PUSHER)
.build();
}
// Observe some events first
PUSH_EVENT.with(|e| e.observe_once());
// Periodically push the accumulated metrics
PUSHER.with(MetricsPusher::push);Trait Implementations§
Source§impl Debug for MetricsPusher
impl Debug for MetricsPusher
Auto Trait Implementations§
impl Freeze for MetricsPusher
impl !RefUnwindSafe for MetricsPusher
impl !Send for MetricsPusher
impl !Sync for MetricsPusher
impl Unpin for MetricsPusher
impl !UnwindSafe for MetricsPusher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more