Closed kathoum closed 4 months ago
Design-wise, I'm not sure about the choice on the function signature:
FnMut(&K, &mut S::Counter) -> bool
or FnMut(&K, &S::Counter) -> bool
I went with &mut
because there's already a write lock, so the code has exclusive access to the underlying S::Counter
, and it shouldn't make much difference in the common case that Counter = Arc<impl CounterFn>
.
But I understand if we prefer not allowing mut
access to objects inside the storage.
Design-wise, I'm not sure about the choice on the function signature:
FnMut(&K, &mut S::Counter) -> bool
orFnMut(&K, &S::Counter) -> bool
Following the standard library, it might be best just to make it an immutable reference. Thinking more about it as well, mutable access really shouldn't even be a big deal since all metric types inevitably have to support concurrent immutable access for normal usage via Counter
, etc.
PR updated, changed the visitors to accept immutable references
Released in metrics-util@v0.16.3
.
Thanks again for your contribution!
This adds public functions retain_counters, retain_gauges, retain_histograms, that work like HashMap::retain