in pkg/monitoring/server.go [158:184]
func (m *Server) isReadyAndHealthy() (ClientsHealthResponse, error) {
m.lock.RLock()
defer m.lock.RUnlock()
healthResponse := ClientsHealthResponse{ClientFailures: m.clientFailures, ClientOk: m.clientSuccesses}
for _, server := range m.metricServers {
if customMetricsSuccess, hasCustomMetrics := m.clientSuccesses.CustomMetrics[server.Name]; hasCustomMetrics && customMetricsSuccess == 0 {
return healthResponse, errors.New("client has not retrieved an initial set of custom metrics yet")
}
if externalMetricsSuccess, hasExternalMetrics := m.clientSuccesses.ExternalMetrics[server.Name]; hasExternalMetrics && externalMetricsSuccess == 0 {
return healthResponse, errors.New("client has not retrieved an initial set of external metrics yet")
}
failures := m.clientFailures.CustomMetrics[server.Name]
if failures >= m.failureThreshold {
return healthResponse, fmt.Errorf("client got %d consecutive failures while retrieving custom metrics", failures)
}
failures = m.clientFailures.ExternalMetrics[server.Name]
if failures >= m.failureThreshold {
return healthResponse, fmt.Errorf("client got %d consecutive failures while retrieving external metrics", failures)
}
}
return healthResponse, nil
}