Skip to content

Commit 2caf215

Browse files
committed
feat: add Counter::set
Signed-off-by: K900 <[email protected]>
1 parent f0c9bc2 commit 2caf215

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/counter.rs

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ impl<P: Atomic> GenericCounter<P> {
7575
self.v.get()
7676
}
7777

78+
/// Set the counter to a specific value.
79+
/// This is useful when you're reexporting metrics from another location
80+
/// that pre-aggregates them.
81+
#[inline]
82+
pub fn set(&self, v: P::T) {
83+
self.v.set(v)
84+
}
85+
7886
/// Restart the counter, resetting its value back to 0.
7987
#[inline]
8088
pub fn reset(&self) {

0 commit comments

Comments
 (0)