Skip to content

Commit 8f0cb89

Browse files
committed
tide: add more metrics
1 parent 8026e80 commit 8f0cb89

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

pkg/tide/tide.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ var (
216216

217217
// Per controller
218218
syncHeartbeat *prometheus.CounterVec
219+
220+
// Retesting metrics
221+
retests *prometheus.CounterVec
222+
poolMissingPRs *prometheus.GaugeVec
223+
poolPendingPRs *prometheus.GaugeVec
224+
poolSuccessfulPRs *prometheus.GaugeVec
225+
poolBatchPendingPRs *prometheus.GaugeVec
219226
}{
220227
pooledPRs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
221228
Name: "pooledprs",
@@ -280,6 +287,47 @@ var (
280287
}, []string{
281288
"controller",
282289
}),
290+
retests: prometheus.NewCounterVec(prometheus.CounterOpts{
291+
Name: "tide_retests_total",
292+
Help: "Total number of test retriggers by org, repo, branch, and action. Incremented when Tide triggers tests for PRs that need retesting. Action is either TRIGGER (serial) or TRIGGER_BATCH (batch).",
293+
}, []string{
294+
"org",
295+
"repo",
296+
"branch",
297+
"action",
298+
}),
299+
poolMissingPRs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
300+
Name: "tide_pool_missing_prs",
301+
Help: "Number of PRs with missing or failed tests in each pool. High values indicate testing bottlenecks.",
302+
}, []string{
303+
"org",
304+
"repo",
305+
"branch",
306+
}),
307+
poolPendingPRs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
308+
Name: "tide_pool_pending_prs",
309+
Help: "Number of PRs with pending tests in each pool.",
310+
}, []string{
311+
"org",
312+
"repo",
313+
"branch",
314+
}),
315+
poolSuccessfulPRs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
316+
Name: "tide_pool_successful_prs",
317+
Help: "Number of PRs with all tests passing in each pool.",
318+
}, []string{
319+
"org",
320+
"repo",
321+
"branch",
322+
}),
323+
poolBatchPendingPRs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
324+
Name: "tide_pool_batch_pending_prs",
325+
Help: "Number of PRs in a pending batch test in each pool.",
326+
}, []string{
327+
"org",
328+
"repo",
329+
"branch",
330+
}),
283331
}
284332
)
285333

@@ -292,6 +340,11 @@ func init() {
292340
prometheus.MustRegister(tideMetrics.syncHeartbeat)
293341
prometheus.MustRegister(tideMetrics.poolErrors)
294342
prometheus.MustRegister(tideMetrics.queryResults)
343+
prometheus.MustRegister(tideMetrics.retests)
344+
prometheus.MustRegister(tideMetrics.poolMissingPRs)
345+
prometheus.MustRegister(tideMetrics.poolPendingPRs)
346+
prometheus.MustRegister(tideMetrics.poolSuccessfulPRs)
347+
prometheus.MustRegister(tideMetrics.poolBatchPendingPRs)
295348
}
296349

297350
type manager interface {
@@ -1705,8 +1758,16 @@ func (c *syncController) syncSubpool(sp subpool, blocks []blockers.Blocker) (Poo
17051758
"action": string(act),
17061759
"targets": prNumbers(targets),
17071760
}).Info("Subpool synced.")
1761+
17081762
tideMetrics.pooledPRs.WithLabelValues(sp.org, sp.repo, sp.branch).Set(float64(len(sp.prs)))
17091763
tideMetrics.updateTime.WithLabelValues(sp.org, sp.repo, sp.branch).Set(float64(time.Now().Unix()))
1764+
tideMetrics.poolMissingPRs.WithLabelValues(sp.org, sp.repo, sp.branch).Set(float64(len(missings)))
1765+
tideMetrics.poolPendingPRs.WithLabelValues(sp.org, sp.repo, sp.branch).Set(float64(len(pendings)))
1766+
tideMetrics.poolSuccessfulPRs.WithLabelValues(sp.org, sp.repo, sp.branch).Set(float64(len(successes)))
1767+
tideMetrics.poolBatchPendingPRs.WithLabelValues(sp.org, sp.repo, sp.branch).Set(float64(len(batchPending)))
1768+
if act == Trigger || act == TriggerBatch {
1769+
tideMetrics.retests.WithLabelValues(sp.org, sp.repo, sp.branch, string(act)).Add(float64(len(targets)))
1770+
}
17101771
return Pool{
17111772
Org: sp.org,
17121773
Repo: sp.repo,

0 commit comments

Comments
 (0)