Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: golden/go/ignore/monitor.go

Issue 1079833002: Add monitoring for expired ignore rules. (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | golden/go/skiacorrectness/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 package ignore
2
3 import (
4 "fmt"
5 "time"
6
7 "github.com/rcrowley/go-metrics"
8 "github.com/skia-dev/glog"
9 imetrics "go.skia.org/infra/go/metrics"
10 )
11
12 func oneStep(store IgnoreStore, metric metrics.Gauge) error {
13 list, err := store.List()
14 if err != nil {
15 return err
16 }
17 n := 0
18 for _, rule := range list {
19 if time.Now().After(rule.Expires) {
20 n += 1
21 }
22 }
23 metric.Update(int64(n))
24 return nil
25 }
26
27 // StartMonitoring starts a new monitoring routine for the given
28 // ignore store that counts expired ignore rules and pushes
29 // that info into a metric.
30 func Init(store IgnoreStore) error {
31 numExpired := metrics.NewRegisteredGauge("num-expired-ignore-rules", met rics.DefaultRegistry)
32 liveness := imetrics.NewLiveness("expired-ignore-rules-monitoring")
33
34 err := oneStep(store, numExpired)
35 if err != nil {
36 return fmt.Errorf("Unable to start monitoring ignore rules: %s", err)
37 }
38 go func() {
39 for _ = range time.Tick(time.Minute) {
40 err = oneStep(store, numExpired)
41 if err != nil {
42 glog.Errorf("Failed one step of monitoring ignor e rules: %s", err)
43 continue
44 }
45 liveness.Update()
46 }
47 }()
48
49 return nil
50 }
OLDNEW
« no previous file with comments | « no previous file | golden/go/skiacorrectness/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698