From b6546b9b6250945ebc87fc174852056856a1abff Mon Sep 17 00:00:00 2001 From: scooletz Date: Mon, 2 Sep 2024 11:32:20 +0200 Subject: [PATCH] proper math on intervals --- .../Nethermind.Monitoring/Metrics/MetricsController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.Monitoring/Metrics/MetricsController.cs b/src/Nethermind/Nethermind.Monitoring/Metrics/MetricsController.cs index e73988c043e..fef44a8c0b4 100644 --- a/src/Nethermind/Nethermind.Monitoring/Metrics/MetricsController.cs +++ b/src/Nethermind/Nethermind.Monitoring/Metrics/MetricsController.cs @@ -211,8 +211,8 @@ public void StartUpdating(Action onForced) return; async Task RunLoop(CancellationToken ct) { - var constantDelay = TimeSpan.FromSeconds(Math.Max(_intervalSeconds - _minIntervalSeconds, 1)); - var waitTime = TimeSpan.FromSeconds(_intervalSeconds) - constantDelay; + var minDelay = TimeSpan.FromSeconds(_minIntervalSeconds); + TimeSpan waitTime = TimeSpan.FromSeconds(_intervalSeconds) - minDelay; while (ct.IsCancellationRequested == false) { @@ -245,7 +245,7 @@ async Task RunLoop(CancellationToken ct) // Always wait a minimal amount of time so that the metrics are not flooded try { - await Task.Delay(constantDelay, ct).ConfigureAwait(false); + await Task.Delay(minDelay, ct).ConfigureAwait(false); } catch (OperationCanceledException) {