summaryrefslogtreecommitdiffstats
path: root/metrics-proxy
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-09-16 11:39:07 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-09-16 11:39:07 +0200
commite562e019a633e58c75c51757d36d09001b668383 (patch)
treeef07fec8f49c9f02f5a8f20e5d44789bb143c765 /metrics-proxy
parentddba827f791b4906c7903e79346a9f605a13dea1 (diff)
Empty snapshots are not valid.
Diffstat (limited to 'metrics-proxy')
-rw-r--r--metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/NodeMetricsClient.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/NodeMetricsClient.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/NodeMetricsClient.java
index f67d418f542..0a8597dc6e3 100644
--- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/NodeMetricsClient.java
+++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/NodeMetricsClient.java
@@ -61,7 +61,7 @@ public class NodeMetricsClient {
boolean updateSnapshots(ConsumerId consumer, Duration ttl) {
var snapshot = snapshots.get(consumer);
- if ((snapshot) != null && clock.instant().isBefore(snapshot.timestamp.plus(ttl))) return true;
+ if ((snapshot != null) && snapshot.isValid(clock.instant(), ttl)) return true;
snapshot = retrieveMetrics(consumer);
snapshots.put(consumer, snapshot);
@@ -113,6 +113,9 @@ public class NodeMetricsClient {
this.timestamp = timestamp;
this.metrics = metrics;
}
+ boolean isValid(Instant now, Duration ttl) {
+ return (metrics != null) && !metrics.isEmpty() && now.isBefore(timestamp.plus(ttl));
+ }
}
}