| OLD | NEW |
| 1 package stats | 1 package stats |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "time" | 4 "time" |
| 5 | 5 |
| 6 metrics "github.com/rcrowley/go-metrics" | 6 metrics "github.com/rcrowley/go-metrics" |
| 7 "github.com/skia-dev/glog" | 7 "github.com/skia-dev/glog" |
| 8 "go.skia.org/infra/go/gitinfo" | 8 "go.skia.org/infra/go/gitinfo" |
| 9 » "go.skia.org/infra/go/tiling" | 9 » "go.skia.org/infra/go/trace/db" |
| 10 ) | 10 ) |
| 11 | 11 |
| 12 // Start calculating and reporting statistics on the repo and tiles. | 12 // Start calculating and reporting statistics on the repo and tiles. |
| 13 // | 13 // |
| 14 // We presume the git.Update(true) is called somewhere else, usually this is don
e | 14 // We presume the git.Update(true) is called somewhere else, usually this is don
e |
| 15 // in the ingester, so the repo is always as good as the ingested tiles. | 15 // in the ingester, so the repo is always as good as the ingested tiles. |
| 16 func Start(tileStore tiling.TileStore, git *gitinfo.GitInfo) { | 16 func Start(nanoTileStore *db.Builder, git *gitinfo.GitInfo) { |
| 17 coverage := metrics.NewRegisteredGaugeFloat64("stats.tests.bench_runs_pe
r_changelist", metrics.DefaultRegistry) | 17 coverage := metrics.NewRegisteredGaugeFloat64("stats.tests.bench_runs_pe
r_changelist", metrics.DefaultRegistry) |
| 18 skpLatency := metrics.NewRegisteredTimer("stats.skp.update_latency", met
rics.DefaultRegistry) | 18 skpLatency := metrics.NewRegisteredTimer("stats.skp.update_latency", met
rics.DefaultRegistry) |
| 19 commits := metrics.NewRegisteredGauge("stats.commits.total", metrics.Def
aultRegistry) | 19 commits := metrics.NewRegisteredGauge("stats.commits.total", metrics.Def
aultRegistry) |
| 20 | 20 |
| 21 go func() { | 21 go func() { |
| 22 for _ = range time.Tick(2 * time.Minute) { | 22 for _ = range time.Tick(2 * time.Minute) { |
| 23 » » » tile, err := tileStore.Get(0, -1) | 23 » » » tile := nanoTileStore.GetTile() |
| 24 » » » if err != nil { | |
| 25 » » » » glog.Warning("Failed to get tile: %s", err) | |
| 26 » » » » continue | |
| 27 » » » } | |
| 28 numCommits := tile.LastCommitIndex() + 1 | 24 numCommits := tile.LastCommitIndex() + 1 |
| 29 numTraces := len(tile.Traces) | 25 numTraces := len(tile.Traces) |
| 30 total := 0 | 26 total := 0 |
| 31 for _, tr := range tile.Traces { | 27 for _, tr := range tile.Traces { |
| 32 for i := 0; i < numCommits; i++ { | 28 for i := 0; i < numCommits; i++ { |
| 33 if !tr.IsMissing(i) { | 29 if !tr.IsMissing(i) { |
| 34 total += 1 | 30 total += 1 |
| 35 } | 31 } |
| 36 } | 32 } |
| 37 } | 33 } |
| 38 cov := float64(total) / float64(numCommits*numTraces) | 34 cov := float64(total) / float64(numCommits*numTraces) |
| 39 glog.Info("Coverage: ", cov) | 35 glog.Info("Coverage: ", cov) |
| 40 coverage.Update(cov) | 36 coverage.Update(cov) |
| 41 | 37 |
| 42 last, err := git.LastSkpCommit() | 38 last, err := git.LastSkpCommit() |
| 43 if err != nil { | 39 if err != nil { |
| 44 glog.Warning("Failed to read last SKP commit: %s
", err) | 40 glog.Warning("Failed to read last SKP commit: %s
", err) |
| 45 continue | 41 continue |
| 46 } | 42 } |
| 47 skpLatency.Update(time.Since(last)) | 43 skpLatency.Update(time.Since(last)) |
| 48 commits.Update(int64(git.NumCommits())) | 44 commits.Update(int64(git.NumCommits())) |
| 49 } | 45 } |
| 50 }() | 46 }() |
| 51 } | 47 } |
| OLD | NEW |