From e9bf31d599b4f108239956d743b688f1c5d3cdcc Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Thu, 27 Jul 2017 15:49:47 -0600 Subject: [PATCH] fix issue with Unregistered metrics not reseting --- cmd/morgoth/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/morgoth/main.go b/cmd/morgoth/main.go index e25beb3..be9ef43 100644 --- a/cmd/morgoth/main.go +++ b/cmd/morgoth/main.go @@ -278,6 +278,7 @@ func newHandler(a *agent.Agent) *Handler { func (h *Handler) Close() { for _, d := range h.detectors { + detectorGauge.Dec() d.Close() } } @@ -484,6 +485,9 @@ func (h *Handler) createDetectorMetrics(group string) *morgoth.DetectorMetrics { metrics.FingerprinterMetrics[i] = &counter.Metrics{ UniqueFingerprints: uniqueFingerpintsGauge.With(labels), } + // Unregistering a gauge does not forget the last value. + // We need to explicitly set the value back down to 0. + metrics.FingerprinterMetrics[i].UniqueFingerprints.Set(0) } return metrics }