in pkg/scheduler/job.go [68:125]
func (m *metricJob) refreshMetrics() {
if m.GetClient().GetConfiguration().MetricTypes.HasType(config.CustomMetricType) {
customMetrics, err := m.c.ListCustomMetricInfos()
if err != nil {
m.logger.Error(err,
"Failed to update custom metric list",
"client_name", m.GetClient().GetConfiguration().Name,
"client_host", m.GetClient().GetConfiguration().ClientConfig.Host,
)
m.publishError(config.CustomMetricType, err)
return
}
m.logger.V(1).Info(
"Refreshed custom metrics",
"count", len(customMetrics),
"client_name", m.GetClient().GetConfiguration().Name,
"client_host", m.GetClient().GetConfiguration().ClientConfig.Host,
)
for _, listener := range m.listeners {
listener.UpdateCustomMetrics(m.c, customMetrics)
}
}
if m.GetClient().GetConfiguration().MetricTypes.HasType(config.ExternalMetricType) {
externalMetrics, err := m.c.ListExternalMetrics()
if err != nil {
m.logger.Error(err,
"Failed to update external metric list",
"client_name", m.GetClient().GetConfiguration().Name,
"client_host", m.GetClient().GetConfiguration().ClientConfig.Host,
)
m.publishError(config.ExternalMetricType, err)
return
}
m.logger.V(1).Info(
"Refreshed external metrics",
"metrics_count", len(externalMetrics),
"client_name", m.GetClient().GetConfiguration().Name,
"client_host", m.GetClient().GetConfiguration().ClientConfig.Host,
)
for _, listener := range m.listeners {
listener.UpdateExternalMetrics(m.c, externalMetrics)
}
}
m.syncDone.Do(func() {
m.logger.V(1).Info(
"First sync successful",
"client_name", m.GetClient().GetConfiguration().Name,
"client_host", m.GetClient().GetConfiguration().ClientConfig.Host,
)
m.wg.Done()
})
}