diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-09-16 11:39:07 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-09-16 11:39:07 +0200 |
commit | e562e019a633e58c75c51757d36d09001b668383 (patch) | |
tree | ef07fec8f49c9f02f5a8f20e5d44789bb143c765 /metrics-proxy | |
parent | ddba827f791b4906c7903e79346a9f605a13dea1 (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.java | 5 |
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)); + } } } |