diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-05 09:49:43 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-05 09:49:43 +0200 |
commit | bf7c818c5cc2ba91be13573e45e3578c28de29ba (patch) | |
tree | 4e61eaf5461060e1513d1545519926411f4d36b5 /vespa-feed-client-api | |
parent | c6908fefe8f527312ade2e938d724cda754ac2ef (diff) |
Print rate.
Diffstat (limited to 'vespa-feed-client-api')
-rw-r--r-- | vespa-feed-client-api/src/main/java/ai/vespa/feed/client/OperationStats.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/OperationStats.java b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/OperationStats.java index 2eb41838560..e9337ab7a43 100644 --- a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/OperationStats.java +++ b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/OperationStats.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; */ public class OperationStats { + private final double duration; private final long requests; private final Map<Integer, Long> responsesByCode; private final long inflight; @@ -22,9 +23,10 @@ public class OperationStats { private final long bytesSent; private final long bytesReceived; - public OperationStats(long requests, Map<Integer, Long> responsesByCode, long exceptions, long inflight, - long averageLatencyMillis, long minLatencyMillis, long maxLatencyMillis, + public OperationStats(double duration, long requests, Map<Integer, Long> responsesByCode, long exceptions, + long inflight, long averageLatencyMillis, long minLatencyMillis, long maxLatencyMillis, long bytesSent, long bytesReceived) { + this.duration = duration; this.requests = requests; this.responsesByCode = responsesByCode; this.exceptions = exceptions; @@ -38,9 +40,10 @@ public class OperationStats { /** Returns the difference between this and the initial. Min and max latency are not modified. */ public OperationStats since(OperationStats initial) { - return new OperationStats(requests - initial.requests, + return new OperationStats(duration - initial.duration, + requests - initial.requests, responsesByCode.entrySet().stream() - .collect(Collectors.toMap(entry -> entry.getKey(), + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue() - initial.responsesByCode.getOrDefault(entry.getKey(), 0L))), exceptions - initial.exceptions, inflight - initial.inflight, @@ -123,9 +126,12 @@ public class OperationStats { @Override public String toString() { + Map<Integer, Double> rateByCode = responsesByCode.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()/duration)); return "Stats{" + "requests=" + requests + ", responsesByCode=" + responsesByCode + + ", responseRateByCode=" + rateByCode + ", exceptions=" + exceptions + ", inflight=" + inflight + ", averageLatencyMillis=" + averageLatencyMillis + |