From 7a68e45006d57ea786070b64495b02a44e3787b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Christian=20Seime?= Date: Mon, 27 Jan 2025 14:09:23 +0100 Subject: [PATCH] Add convenience method for retrieving stats for given code Also add trailing new line to `BenchmarkingClusterTest` --- .../src/main/java/ai/vespa/feed/client/OperationStats.java | 4 ++++ .../ai/vespa/feed/client/impl/BenchmarkingClusterTest.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 fdff25928c42..b90e651bbabd 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 @@ -2,6 +2,7 @@ package ai.vespa.feed.client; import java.util.Map; +import java.util.Optional; /** * Statistics for feed operations over HTTP against a Vespa cluster. @@ -57,6 +58,9 @@ public long successes() { /** Statistics per response code. */ public Map statsByCode() { return statsByCode; } + /** Statistics for the given code. */ + public Optional response(int code) { return Optional.ofNullable(statsByCode.get(code)); } + /** Number of exceptions (instead of responses). */ public long exceptions() { return exceptions; diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/BenchmarkingClusterTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/BenchmarkingClusterTest.java index c5b4bf71e961..89ebe24c7bde 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/BenchmarkingClusterTest.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/BenchmarkingClusterTest.java @@ -59,4 +59,4 @@ private static Void processRequest(AtomicLong nanoClock, InvocationOnMock invoca vessel.complete(HttpResponse.of(statusCode, "body".getBytes(StandardCharsets.UTF_8))); return null; } -} \ No newline at end of file +}