Skip to content

Commit

Permalink
bugfix: don't periodically delete *all* bad entries, do too old check
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieterbe committed Jun 24, 2016
1 parent be384f1 commit 6de5e67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions badmetrics/badMetrics.go
Expand Up @@ -14,8 +14,8 @@ type BadMetrics struct {
}

type Record struct {
Metric string
LastMsg string
Metric string // the key parsed, or "" if parse failure
LastMsg string // metric line read
LastErr string
LastSeen time.Time
}
Expand Down Expand Up @@ -66,9 +66,9 @@ func (b *BadMetrics) manage() {
case in := <-b.In:
b.seen[in.Metric] = in
case <-clean.C:
now := time.Now()
cutoff := time.Now().Add(-b.maxAge)
for metric, record := range b.seen {
if record.LastSeen.Before(now) {
if record.LastSeen.Before(cutoff) {
delete(b.seen, metric)
}
}
Expand Down

0 comments on commit 6de5e67

Please sign in to comment.