feat: reset metrics on every iteration

This commit is contained in:
Valentin Doreau 2024-04-02 08:31:26 +02:00
parent d7f0ea20e1
commit f249a35a8a
Signed by: vdoreau
GPG key ID: F3E456CF9A14098B
2 changed files with 17 additions and 0 deletions

View file

@ -57,6 +57,8 @@ func main() {
func RecordMetrics(m Metrics) {
for {
m.Reset()
entries, err := os.ReadDir(*backupDir)
if err != nil {
log.Fatalln(err)

View file

@ -41,3 +41,18 @@ func NewMetrics(reg prometheus.Registerer) *Metrics {
return metrics
}
// Reset all metrics
//
// This should be called on every loop iteration.
func (m *Metrics) Reset() {
m.ArchiveCount.Reset()
m.LastArchiveTime.Reset()
m.LastModified.Reset()
m.TotalChunks.Reset()
m.TotalCsize.Reset()
m.TotalSize.Reset()
m.TotalUniqueChunks.Reset()
m.UniqueCsize.Reset()
m.UniqueSize.Reset()
}