Skip to content

Commit 6f24dd4

Browse files
committed
prevent panic if computer name is missing
Signed-off-by: Markus Blaschke <[email protected]>
1 parent e01c946 commit 6f24dd4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

metrics_agentpool.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ func (m *MetricsCollectorAgentPool) collectAgentQueues(ctx context.Context, logg
183183
agentPoolUsed := 0
184184
for _, agentPoolAgent := range list.List {
185185
agentPoolSize++
186+
187+
agentComputerName := ""
188+
if val, exists := agentPoolAgent.SystemCapabilities["Agent.ComputerName"]; exists {
189+
agentComputerName = val
190+
}
191+
186192
infoLabels := prometheus.Labels{
187193
"agentPoolID": int64ToString(agentPoolId),
188194
"agentPoolAgentID": int64ToString(agentPoolAgent.Id),
@@ -191,7 +197,7 @@ func (m *MetricsCollectorAgentPool) collectAgentQueues(ctx context.Context, logg
191197
"provisioningState": agentPoolAgent.ProvisioningState,
192198
"maxParallelism": int64ToString(agentPoolAgent.MaxParallelism),
193199
"agentPoolAgentOs": agentPoolAgent.OsDescription,
194-
"agentPoolAgentComputerName": agentPoolAgent.SystemCapabilities["Agent.ComputerName"],
200+
"agentPoolAgentComputerName": agentComputerName,
195201
"enabled": to.BoolString(agentPoolAgent.Enabled),
196202
"status": agentPoolAgent.Status,
197203
"hasAssignedRequest": to.BoolString(agentPoolAgent.AssignedRequest.RequestId > 0),

0 commit comments

Comments
 (0)