From 6cea5a1f2915ce9b74cae80248d1d1cf3eb583a0 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 14 Apr 2024 10:00:38 +0100 Subject: [PATCH] change metric save interval --- .../xyz/mcutils/backend/service/MetricService.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/xyz/mcutils/backend/service/MetricService.java b/src/main/java/xyz/mcutils/backend/service/MetricService.java index 07a7fe0..dc5e770 100644 --- a/src/main/java/xyz/mcutils/backend/service/MetricService.java +++ b/src/main/java/xyz/mcutils/backend/service/MetricService.java @@ -25,12 +25,7 @@ public class MetricService { /** * The interval in which the metrics are saved. */ - private final long saveInterval = TimeUnit.MINUTES.toMillis(1); - - /** - * The interval in which the metrics are written to InfluxDB. - */ - private final long writeInfluxInterval = TimeUnit.SECONDS.toMillis(30); + private final long saveInterval = TimeUnit.SECONDS.toMillis(15); private final WriteApiBlocking influxWriteApi; private final MetricsRepository metricsRepository; @@ -49,8 +44,10 @@ public class MetricService { // Load the metrics from Redis loadMetrics(); - Timer.scheduleRepeating(this::saveMetrics, saveInterval, saveInterval); - Timer.scheduleRepeating(this::writeToInflux, writeInfluxInterval, writeInfluxInterval); + Timer.scheduleRepeating(() -> { + saveMetrics(); + writeToInflux(); + }, saveInterval, saveInterval); } /**