[−][src]Struct metrics_util::Recency
Tracks recency of metric updates by their registry generation and time.
In many cases, a user may have a long-running process where metrics are stored over time using labels that change for some particular reason, leaving behind versions of that metric with labels that are no longer relevant to the current process state. This can lead to cases where metrics that no longer matter are still present in rendered output, adding bloat.
When coupled with Registry
, Recency
can be used to track when the last
update to a metric has occurred for the purposes of removing idle metrics from the registry. In
addition, it will remove the value from the registry itself to reduce the aforementioned bloat.
Recency
is separate from Registry
specifically to avoid imposing any
slowdowns when tracking recency does not matter, despite their otherwise tight coupling.
Implementations
impl<K> Recency<K>
[src]
pub fn new(
clock: Clock,
mask: MetricKind,
idle_timeout: Option<Duration>
) -> Recency<K>
[src]
clock: Clock,
mask: MetricKind,
idle_timeout: Option<Duration>
) -> Recency<K>
Creates a new Recency
.
If idle_timeout
is None
, no recency checking will occur. mask
controls which metrics
are covered by the recency logic. For example, if mask
only contains counters and
histograms, then gauges will not be considered for recency, and thus will never be deleted.
If idle_timeout
is not None
, then metrics which have not been updated within the given
duration will be subject to deletion when checked. Specifically, the deletions done by this
object only happen when the object is "driven" by calling
should_store
, and so handles will not necessarily be deleted
immediately after execeeding their idle timeout.
Refer to the documentation for MetricKind
for more information on
defining a metric kind mask.
pub fn should_store<H>(
&self,
kind: MetricKind,
key: &K,
gen: Generation,
registry: &Registry<K, H>
) -> bool where
K: Eq + Hash + Clone + 'static,
H: Clone + 'static,
[src]
&self,
kind: MetricKind,
key: &K,
gen: Generation,
registry: &Registry<K, H>
) -> bool where
K: Eq + Hash + Clone + 'static,
H: Clone + 'static,
Checks if the given key should be stored, based on its known recency.
kind
will be used to see if the given metric kind is subject to recency tracking for this
instance. generation
should be obtained from the the same reference to registry
that
been given.
If the given key has been updated recently enough, and should continue to be stored, this
method will return true
and will update the last update time internally. If the given key
has not been updated recently enough, the key will be removed from the given registry if the
given generation also matches.
If the generation does not match, this indicates that the key was updated between querying
it from the registry and calling this method, and this method will return true
in those
cases, and false
for all remaining cases.
Trait Implementations
Auto Trait Implementations
impl<K> !RefUnwindSafe for Recency<K>
impl<K> Send for Recency<K> where
K: Send,
K: Send,
impl<K> Sync for Recency<K> where
K: Send,
K: Send,
impl<K> Unpin for Recency<K> where
K: Unpin,
K: Unpin,
impl<K> UnwindSafe for Recency<K> where
K: UnwindSafe,
K: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,