Skip to content

Commit

Permalink
feat(lifecycle): emitter cluster health rate
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzhhb committed Jun 7, 2024
1 parent 11f15e8 commit 7646db3
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
metricsNameAgentReadyTotal = "agent_ready_total"
metricsNameAgentNotReadyTotal = "agent_not_ready_total"
metricsNameAgentNotFoundTotal = "agent_not_found_total"
metricsNameAgentReadyRate = "agent_ready_rate"

metricsTagKeyAgentName = "agentName"
metricsTagKeyNodeName = "nodeName"
Expand Down Expand Up @@ -243,6 +244,7 @@ func (h *HealthzHelper) syncHeartBeatMap() {
}
}

nodeCount := len(nodes)
for agent := range h.agentSelectors {
tag := metrics.MetricTag{Key: metricsTagKeyAgentName, Val: agent}
_ = h.emitter.StoreInt64(metricsNameAgentReadyTotal, totalReadyNode[agent],
Expand All @@ -251,6 +253,10 @@ func (h *HealthzHelper) syncHeartBeatMap() {
metrics.MetricTypeNameRaw, tag)
_ = h.emitter.StoreInt64(metricsNameAgentNotFoundTotal, totalNotFoundNode[agent],
metrics.MetricTypeNameRaw, tag)
if nodeCount > 0 {
_ = h.emitter.StoreFloat64(metricsNameAgentReadyRate, float64(totalNotReadyNode[agent])/float64(len(nodes)),
metrics.MetricTypeNameRaw, tag)
}
}

h.healthzMap.rangeNode(func(node string) bool {
Expand Down

0 comments on commit 7646db3

Please sign in to comment.