Exposing waiting job count as metric

This commit is contained in:
Laszlo Fogas 2019-07-10 10:00:38 +02:00
parent ca67aff5f9
commit f0c641fa9d

View file

@ -207,6 +207,11 @@ func setupMetrics(g *errgroup.Group, store_ store.Store) {
Name: "pending_jobs", Name: "pending_jobs",
Help: "Total number of pending build processes.", Help: "Total number of pending build processes.",
}) })
waitingJobs := promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "drone",
Name: "waiting_jobs",
Help: "Total number of builds waiting on deps.",
})
runningJobs := promauto.NewGauge(prometheus.GaugeOpts{ runningJobs := promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "drone", Namespace: "drone",
Name: "running_jobs", Name: "running_jobs",
@ -237,6 +242,7 @@ func setupMetrics(g *errgroup.Group, store_ store.Store) {
for { for {
stats := droneserver.Config.Services.Queue.Info(nil) stats := droneserver.Config.Services.Queue.Info(nil)
pendingJobs.Set(float64(stats.Stats.Pending)) pendingJobs.Set(float64(stats.Stats.Pending))
waitingJobs.Set(float64(stats.Stats.WaitingOnDeps))
runningJobs.Set(float64(stats.Stats.Running)) runningJobs.Set(float64(stats.Stats.Running))
workers.Set(float64(stats.Stats.Workers)) workers.Set(float64(stats.Stats.Workers))
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)