diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java index 911583f9fc2..f10fae3c0eb 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java @@ -585,6 +585,8 @@ public void processRequest(Request request) { err = Code.MARSHALLINGERROR; } + updateReplyErrorCountMetrics(err); + ReplyHeader hdr = new ReplyHeader(request.cxid, lastZxid, err.intValue()); updateStats(request, lastOp, lastZxid); @@ -626,6 +628,12 @@ public void processRequest(Request request) { } } + private void updateReplyErrorCountMetrics(Code errorCode) { + if (!Code.OK.equals(errorCode)) { + ServerMetrics.getMetrics().REPLY_ERROR_COUNT.add(errorCode.name(), 1); + } + } + private Record handleGetChildrenRequest(Record request, ServerCnxn cnxn, List authInfo) throws KeeperException, IOException { GetChildrenRequest getChildrenRequest = (GetChildrenRequest) request; String path = getChildrenRequest.getPath(); diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerMetrics.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerMetrics.java index e3476ff6dd7..18c5ab3783d 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerMetrics.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerMetrics.java @@ -269,6 +269,8 @@ private ServerMetrics(MetricsProvider metricsProvider) { JVM_PAUSE_TIME = metricsContext.getSummary("jvm_pause_time_ms", DetailLevel.ADVANCED); QUOTA_EXCEEDED_ERROR_PER_NAMESPACE = metricsContext.getCounterSet(QuotaMetricsUtils.QUOTA_EXCEEDED_ERROR_PER_NAMESPACE); + + REPLY_ERROR_COUNT = metricsContext.getCounterSet("reply_error_count"); } /** @@ -547,6 +549,8 @@ private ServerMetrics(MetricsProvider metricsProvider) { public final CounterSet QUOTA_EXCEEDED_ERROR_PER_NAMESPACE; + public final CounterSet REPLY_ERROR_COUNT; + private final MetricsProvider metricsProvider; public void resetAll() {