Skip to content

Commit

Permalink
feat: add Counter::set
Browse files Browse the repository at this point in the history
Signed-off-by: K900 <[email protected]>
  • Loading branch information
K900 committed Nov 7, 2024
1 parent f0c9bc2 commit 2caf215
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ impl<P: Atomic> GenericCounter<P> {
self.v.get()
}

/// Set the counter to a specific value.
/// This is useful when you're reexporting metrics from another location
/// that pre-aggregates them.
#[inline]
pub fn set(&self, v: P::T) {
self.v.set(v)
}

/// Restart the counter, resetting its value back to 0.
#[inline]
pub fn reset(&self) {
Expand Down

0 comments on commit 2caf215

Please sign in to comment.