Hello team,
Several projects in the Prometheus ecosystem need to expire stale metric series from *Vec metrics (high-cardinality, ephemeral label sets / think per-pod, per-connection, etc.).
Today the only option is to maintain an external cache that shadows metricMap to track last-access times and periodically call Delete(). This duplicates memory (label sets stored twice), duplicates hashing and leads to a lot of reimplemented boilerplate across projects.
Projects that have independently built this:
I know #1397 was closed with "use Delete/Reset", but the number of projects reimplementing the same pattern suggests this would be valuable as a first-class feature. The core idea is simple: an atomic lastAccessed timestamp per child (+8 bytes, updated on GetMetricWith), and a way to clean up expired entries — either via an explicit method, during Collect(), or both.
Happy to discuss the design further and contribute a PR if there's interest. Would something like this be welcome ?
Hello team,
Several projects in the Prometheus ecosystem need to expire stale metric series from
*Vecmetrics (high-cardinality, ephemeral label sets / think per-pod, per-connection, etc.).Today the only option is to maintain an external cache that shadows
metricMapto track last-access times and periodically callDelete(). This duplicates memory (label sets stored twice), duplicates hashing and leads to a lot of reimplemented boilerplate across projects.Projects that have independently built this:
ttlmetric_expiration+lastSeenTimedCacheLRU shadowing every VecI know #1397 was closed with "use
Delete/Reset", but the number of projects reimplementing the same pattern suggests this would be valuable as a first-class feature. The core idea is simple: an atomiclastAccessedtimestamp per child (+8 bytes, updated onGetMetricWith), and a way to clean up expired entries — either via an explicit method, duringCollect(), or both.Happy to discuss the design further and contribute a PR if there's interest. Would something like this be welcome ?