Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit 3a4f8dc

Browse files
authored
Merge pull request #1208 from lavalamp/ff6
add metrics for health poller
2 parents dba64c5 + 51fea8f commit 3a4f8dc

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

mungegithub/mungers/flake-manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (p *FlakeManager) Initialize(config *github.Config, features *features.Feat
7979
p.config = config
8080
p.googleGCSBucketUtils = utils.NewUtils(utils.KubekinsBucket, utils.LogDir)
8181

82-
var owner *testowner.ReloadingOwnerList
82+
var owner sync.OwnerMapper
8383
var err error
8484
if p.ownerPath != "" {
8585
owner, err = testowner.NewReloadingOwnerList(p.ownerPath)

mungegithub/mungers/submit-queue.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,15 @@ type healthRecord struct {
116116
// information about the sq itself including how fast things are merging and
117117
// how long since the last merge
118118
type submitQueueStats struct {
119-
StartTime time.Time
120-
LastMergeTime time.Time
121-
MergeRate float64
122-
RetestsAvoided int
123-
FlakesIgnored int
119+
StartTime time.Time
120+
LastMergeTime time.Time
121+
MergesSinceRestart int
122+
MergeRate float64
123+
RetestsAvoided int
124+
FlakesIgnored int
125+
126+
// Will be true if we've made at least one complete pass.
127+
Initialized bool
124128
}
125129

126130
// pull-request that has been tested as successful, but interrupted because head flaked
@@ -159,7 +163,9 @@ type SubmitQueue struct {
159163
clock util.Clock
160164
startTime time.Time // when the queue started (duh)
161165
lastMergeTime time.Time
166+
totalMerges int32
162167
mergeRate float64 // per 24 hours
168+
loopStarts int32 // if > 1, then we must have made a complete pass.
163169

164170
githubE2ERunning *github.MungeObject // protect by sync.Mutex!
165171
githubE2EQueue map[int]*github.MungeObject // protected by sync.Mutex!
@@ -250,11 +256,13 @@ func calcMergeRate(oldRate float64, last, now time.Time) float64 {
250256

251257
// updates a smoothed rate at which PRs are merging per day.
252258
// returns 'Now()' and the rate.
259+
// Should be called once after every merge. Also updates sq.totalMerges.
253260
func (sq *SubmitQueue) updateMergeRate() {
254261
now := sq.clock.Now()
255262

256263
sq.mergeRate = calcMergeRate(sq.mergeRate, sq.lastMergeTime, now)
257264
sq.lastMergeTime = now
265+
atomic.AddInt32(&sq.totalMerges, 1)
258266
}
259267

260268
// This calculated the smoothed merge rate BUT it looks at the time since
@@ -386,6 +394,7 @@ func (sq *SubmitQueue) EachLoop() error {
386394
// This should recheck it and clean up the queue, we don't care about the result
387395
_ = sq.validForMerge(obj)
388396
}
397+
atomic.AddInt32(&sq.loopStarts, 1)
389398
return nil
390399
}
391400

@@ -1130,11 +1139,13 @@ func (sq *SubmitQueue) serveHealth(res http.ResponseWriter, req *http.Request) {
11301139

11311140
func (sq *SubmitQueue) serveSQStats(res http.ResponseWriter, req *http.Request) {
11321141
data := submitQueueStats{
1133-
StartTime: sq.startTime,
1134-
LastMergeTime: sq.lastMergeTime,
1135-
MergeRate: sq.calcMergeRateWithTail(),
1136-
RetestsAvoided: int(atomic.LoadInt32(&sq.retestsAvoided)),
1137-
FlakesIgnored: int(atomic.LoadInt32(&sq.flakesIgnored)),
1142+
StartTime: sq.startTime,
1143+
LastMergeTime: sq.lastMergeTime,
1144+
MergesSinceRestart: int(atomic.LoadInt32(&sq.totalMerges)),
1145+
MergeRate: sq.calcMergeRateWithTail(),
1146+
RetestsAvoided: int(atomic.LoadInt32(&sq.retestsAvoided)),
1147+
FlakesIgnored: int(atomic.LoadInt32(&sq.flakesIgnored)),
1148+
Initialized: atomic.LoadInt32(&sq.loopStarts) > 1,
11381149
}
11391150
sq.serve(sq.marshal(data), res, req)
11401151
}

0 commit comments

Comments
 (0)