Skip to content

Commit

Permalink
fix issue with Unregistered metrics not reseting
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed Jul 27, 2017
1 parent 62da792 commit e9bf31d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/morgoth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func newHandler(a *agent.Agent) *Handler {

func (h *Handler) Close() {
for _, d := range h.detectors {
detectorGauge.Dec()
d.Close()
}
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e9bf31d

Please sign in to comment.