pub struct Counter { /* private fields */ }Expand description
A counter metric instrument that optionally tracks values in memory for heartbeating.
Implementations§
Source§impl Counter
impl Counter
Sourcepub fn new(
inner: Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>,
) -> Self
pub fn new( inner: Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>, ) -> Self
Create a new counter from an attributable metric source.
Sourcepub fn new_with_in_memory(
primary: Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>,
in_memory: HeartbeatMetricType,
) -> Self
pub fn new_with_in_memory( primary: Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>, in_memory: HeartbeatMetricType, ) -> Self
Create a new counter with an additional in-memory tracker for heartbeat reporting.
Sourcepub fn add(&self, value: u64, attributes: &MetricAttributes)
pub fn add(&self, value: u64, attributes: &MetricAttributes)
Increment the counter by value with the given attributes.
Sourcepub fn update_attributes(&mut self, new_attributes: MetricAttributes)
pub fn update_attributes(&mut self, new_attributes: MetricAttributes)
Replace the attributes on the primary metric.
Trait Implementations§
Source§impl MetricAttributable<Counter> for Counter
impl MetricAttributable<Counter> for Counter
Source§fn with_attributes(
&self,
attributes: &MetricAttributes,
) -> Result<Counter, Box<dyn Error>>
fn with_attributes( &self, attributes: &MetricAttributes, ) -> Result<Counter, Box<dyn Error>>
Replace any existing attributes on this metric with new ones, and return a new copy
of the metric, or a base version, which can be used to record values. Read more
Auto Trait Implementations§
impl !Freeze for Counter
impl !RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnsafeUnpin for Counter
impl !UnwindSafe for Counter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request