aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2021-11-23 11:18:23 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2021-11-23 11:18:23 +0100
commitb042ab7c783bf51b803d27fe56c5f4bc69033081 (patch)
tree46eed402d65fdda378adbc1964d5effa53e9a476 /vespaclient-container-plugin
parenteddbd9d4264e126fb862c0b33e952cec299e8a7c (diff)
Track test-and-set condition not met as success + in new metric
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java27
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java1
2 files changed, 17 insertions, 11 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java
index 11fd97f2a1d..1a4a845bec2 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java
@@ -1,21 +1,20 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.server;
-import java.util.Set;
-import java.util.logging.Logger;
-
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;
import com.yahoo.documentapi.metrics.DocumentApiMetrics;
import com.yahoo.documentapi.metrics.DocumentOperationStatus;
import com.yahoo.documentapi.metrics.DocumentOperationType;
import com.yahoo.jdisc.Metric;
-import java.util.logging.Level;
import com.yahoo.messagebus.Reply;
import com.yahoo.messagebus.ReplyHandler;
import com.yahoo.messagebus.Trace;
import com.yahoo.vespa.http.client.core.ErrorCode;
import com.yahoo.vespa.http.client.core.OperationStatus;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/**
* Catch message bus replies and make the available to a given session.
*
@@ -42,20 +41,26 @@ public class FeedReplyReader implements ReplyHandler {
final double latencyInSeconds = (System.currentTimeMillis() - context.creationTime) / 1000.0d;
metric.set(MetricNames.LATENCY, latencyInSeconds, null);
- if (reply.hasErrors()) {
- Set<Integer> errorCodes = reply.getErrorCodes();
- metricsHelper.reportFailure(DocumentOperationType.fromMessage(reply.getMessage()),
- DocumentOperationStatus.fromMessageBusErrorCodes(errorCodes));
+ DocumentOperationType type = DocumentOperationType.fromMessage(reply.getMessage());
+ boolean conditionNotMet = conditionNotMet(reply);
+ if (!conditionNotMet && reply.hasErrors()) {
+ DocumentOperationStatus status = DocumentOperationStatus.fromMessageBusErrorCodes(reply.getErrorCodes());
+ metricsHelper.reportFailure(type, status);
metric.add(MetricNames.FAILED, 1, null);
- enqueue(context, reply.getError(0).getMessage(), ErrorCode.ERROR,
- reply.getError(0).getCode() == DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED, reply.getTrace());
+ enqueue(context, reply.getError(0).getMessage(), ErrorCode.ERROR, conditionNotMet, reply.getTrace());
} else {
- metricsHelper.reportSuccessful(DocumentOperationType.fromMessage(reply.getMessage()), latencyInSeconds);
+ metricsHelper.reportSuccessful(type, latencyInSeconds);
metric.add(MetricNames.SUCCEEDED, 1, null);
+ if (conditionNotMet)
+ metric.add(MetricNames.TEST_AND_SET_CONDITION_NOT_MET, 1, null);
enqueue(context, "Document processed.", ErrorCode.OK, false, reply.getTrace());
}
}
+ private static boolean conditionNotMet(Reply reply) {
+ return reply.hasErrors() && reply.getError(0).getCode() == DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED;
+ }
+
private void enqueue(ReplyContext context, String message, ErrorCode status, boolean isConditionNotMet, Trace trace) {
try {
String traceMessage = (trace != null && trace.getLevel() > 0) ? trace.toString() : "";
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
index 8cd628a83d9..4b49e3594f8 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
@@ -18,6 +18,7 @@ public final class MetricNames {
public static final String OPERATIONS_PER_SEC = PREFIX + "ops_per_sec";
public static final String LATENCY = PREFIX + "latency";
public static final String FAILED = PREFIX + "failed";
+ public static final String TEST_AND_SET_CONDITION_NOT_MET = PREFIX + "test_and_set_condition_not_met";
public static final String PARSE_ERROR = PREFIX + "parse_error";
public static final String SUCCEEDED = PREFIX + "succeeded";
public static final String PENDING = PREFIX + "pending";