metric for lastUpdate

This commit is contained in:
Michele Artini 2021-08-02 09:36:02 +02:00
parent 91fccbae7f
commit 0a5c711629
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package eu.dnetlib.broker.common.metrics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import eu.dnetlib.common.metrics.MetricInfo;
@Component("provide_broker_last_metrics_updater_run_timestamp_seconds")
public class LastUpdateMetric extends MetricInfo {
@Autowired
private MetricsCacheUtils metricsCacheUtils;
@Override
public double obtainValue() {
return metricsCacheUtils.lastUpdateInSeconds();
}
}

View File

@ -73,6 +73,12 @@ public class MetricsCacheUtils {
return subscriptionRepository.countSubscribers();
}
@Cacheable(value = MetricsCacheUtils.metrics_cache, key = "#root.methodName")
public double lastUpdateInSeconds() {
log.debug("Call to cached method: lastUpdateInSeconds()");
return System.currentTimeMillis() / 1000;
}
@Cacheable(value = MetricsCacheUtils.metrics_cache, key = "#root.methodName")
public double countDatasourcesWithSubscriptions() {
log.debug("Call to cached method: countDatasourcesWithSubscriptions()");