[#2372] Move config reload metrics to Coordinator.Reload() (#2373)

* prometheus/alertmanager#2372 Move config reload metrics to Coordinator.Reload()

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* #2372 Minor refactoring.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>
This commit is contained in:
Kevin Hellemun 2020-09-28 14:43:57 +02:00 committed by GitHub
parent 59a96579cc
commit dd1a8fb77b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@ import (
"crypto/md5"
"encoding/binary"
"sync"
"time"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
@ -97,15 +96,10 @@ func (c *Coordinator) notifySubscribers() error {
func (c *Coordinator) loadFromFile() error {
conf, err := LoadFile(c.configFilePath)
if err != nil {
c.configSuccessMetric.Set(0)
return err
}
c.config = conf
c.configSuccessMetric.Set(1)
c.configSuccessTimeMetric.Set(float64(time.Now().Unix()))
hash := md5HashAsMetricValue([]byte(c.config.original))
c.configHashMetric.Set(hash)
return nil
}
@ -126,6 +120,7 @@ func (c *Coordinator) Reload() error {
"file", c.configFilePath,
"err", err,
)
c.configSuccessMetric.Set(0)
return err
}
level.Info(c.logger).Log(
@ -139,9 +134,15 @@ func (c *Coordinator) Reload() error {
"file", c.configFilePath,
"err", err,
)
c.configSuccessMetric.Set(0)
return err
}
c.configSuccessMetric.Set(1)
c.configSuccessTimeMetric.SetToCurrentTime()
hash := md5HashAsMetricValue([]byte(c.config.original))
c.configHashMetric.Set(hash)
return nil
}