Skip to content

Commit cb410fb

Browse files
committed
fixed exceptions and made working azure_devops_agentpool_queue_length metric
1 parent be229c3 commit cb410fb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

metrics_agentpool.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,22 @@ func (m *MetricsCollectorAgentPool) Setup(collector *CollectorAgentPool) {
9090
},
9191
)
9292

93+
m.prometheus.agentPoolQueueLength = prometheus.NewGaugeVec(
94+
prometheus.GaugeOpts{
95+
Name: "azure_devops_agentpool_queue_length",
96+
Help: "Azure DevOps agentpool",
97+
},
98+
[]string{
99+
"agentPoolID",
100+
},
101+
)
102+
93103
prometheus.MustRegister(m.prometheus.agentPool)
94104
prometheus.MustRegister(m.prometheus.agentPoolSize)
95105
prometheus.MustRegister(m.prometheus.agentPoolAgent)
96106
prometheus.MustRegister(m.prometheus.agentPoolAgentStatus)
97107
prometheus.MustRegister(m.prometheus.agentPoolAgentJob)
108+
prometheus.MustRegister(m.prometheus.agentPoolQueueLength)
98109
}
99110

100111
func (m *MetricsCollectorAgentPool) Reset() {
@@ -206,7 +217,7 @@ func (m *MetricsCollectorAgentPool) collectAgentPoolJobs(ctx context.Context, ca
206217
return
207218
}
208219

209-
agentPoolQueueLength := NewMetricCollectorList()
220+
agentPoolQueueLengthMetric := NewMetricCollectorList()
210221

211222
notStartedJobCount := 0
212223

@@ -220,9 +231,9 @@ func (m *MetricsCollectorAgentPool) collectAgentPoolJobs(ctx context.Context, ca
220231
"agentPoolID": int64ToString(agentPoolId),
221232
}
222233

223-
agentPoolQueueLength.Add(infoLabels, 1)
234+
agentPoolQueueLengthMetric.Add(infoLabels, float64(notStartedJobCount))
224235

225236
callback <- func() {
226-
agentPoolQueueLength.GaugeSet(m.prometheus.agentPoolAgent)
237+
agentPoolQueueLengthMetric.GaugeSet(m.prometheus.agentPoolQueueLength)
227238
}
228239
}

0 commit comments

Comments
 (0)