This commit is contained in:
Michele Artini 2021-11-29 14:43:45 +01:00
parent e127a7e73c
commit 3e84eac3cb
1 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,9 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -24,10 +27,13 @@ public class MetricUtils {
@Autowired(required = false)
private Map<String, MetricInfo> kpiMetrics;
private static final Log log = LogFactory.getLog(MetricUtils.class);
@PostConstruct
public void registerToMainEndpoint() {
if (kpiMetrics != null) {
kpiMetrics.forEach((k, v) -> Metrics.gauge(k, v, o -> o.obtainValue()));
log.info("KPI METRICS REGISTERED: " + StringUtils.join(kpiMetrics.keySet(), ", "));
}
}