add next retention metric (#2863)

Co-authored-by: wangfeng <wangfeng@zhihu.com>
This commit is contained in:
guidao 2022-07-13 17:37:04 +08:00 committed by GitHub
parent 29e53b9f55
commit 91faa152a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -846,6 +846,10 @@ func registerStorageMetrics(strg *storage.Storage) {
metrics.NewGauge(`vm_cache_collisions_total{type="storage/metricName"}`, func() float64 {
return float64(m().MetricNameCacheCollisions)
})
metrics.NewGauge(`vm_next_retention_seconds`, func() float64 {
return float64(m().NextRetentionSeconds)
})
}
func jsonResponseError(w http.ResponseWriter, err error) {

View File

@ -511,6 +511,8 @@ type Metrics struct {
PrefetchedMetricIDsSize uint64
PrefetchedMetricIDsSizeBytes uint64
NextRetentionSeconds uint64
IndexDBMetrics IndexDBMetrics
TableMetrics TableMetrics
}
@ -601,6 +603,8 @@ func (s *Storage) UpdateMetrics(m *Metrics) {
m.PrefetchedMetricIDsSize += uint64(prefetchedMetricIDs.Len())
m.PrefetchedMetricIDsSizeBytes += uint64(prefetchedMetricIDs.SizeBytes())
m.NextRetentionSeconds = uint64(nextRetentionDuration(s.retentionMsecs).Seconds())
s.idb().UpdateMetrics(&m.IndexDBMetrics)
s.tb.UpdateMetrics(&m.TableMetrics)
}