-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
stages.go
39 lines (33 loc) · 1.03 KB
/
stages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
// +build !oss
package metric
import (
"github.com/drone/drone/core"
"github.com/prometheus/client_golang/prometheus"
)
// RunningJobCount provides metrics for running job counts.
func RunningJobCount(stages core.StageStore) {
prometheus.MustRegister(
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Name: "drone_running_jobs",
Help: "Total number of running jobs.",
}, func() float64 {
list, _ := stages.ListState(noContext, core.StatusRunning)
return float64(len(list))
}),
)
}
// PendingJobCount provides metrics for pending job counts.
func PendingJobCount(stages core.StageStore) {
prometheus.MustRegister(
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Name: "drone_pending_jobs",
Help: "Total number of pending jobs.",
}, func() float64 {
list, _ := stages.ListState(noContext, core.StatusPending)
return float64(len(list))
}),
)
}