change metric save interval

This commit is contained in:
Lee 2024-04-14 10:00:38 +01:00
parent 05d0aa500c
commit 6cea5a1f29

@ -25,12 +25,7 @@ public class MetricService {
/** /**
* The interval in which the metrics are saved. * The interval in which the metrics are saved.
*/ */
private final long saveInterval = TimeUnit.MINUTES.toMillis(1); private final long saveInterval = TimeUnit.SECONDS.toMillis(15);
/**
* The interval in which the metrics are written to InfluxDB.
*/
private final long writeInfluxInterval = TimeUnit.SECONDS.toMillis(30);
private final WriteApiBlocking influxWriteApi; private final WriteApiBlocking influxWriteApi;
private final MetricsRepository metricsRepository; private final MetricsRepository metricsRepository;
@ -49,8 +44,10 @@ public class MetricService {
// Load the metrics from Redis // Load the metrics from Redis
loadMetrics(); loadMetrics();
Timer.scheduleRepeating(this::saveMetrics, saveInterval, saveInterval); Timer.scheduleRepeating(() -> {
Timer.scheduleRepeating(this::writeToInflux, writeInfluxInterval, writeInfluxInterval); saveMetrics();
writeToInflux();
}, saveInterval, saveInterval);
} }
/** /**