From 55e90bf1275376d16029b0b9dfdf32bbdb4198b9 Mon Sep 17 00:00:00 2001 From: birdstorm Date: Fri, 4 Jun 2021 16:41:06 +0900 Subject: [PATCH] cherry pick #183 to release-3.1 Signed-off-by: ti-srebot --- src/main/java/org/tikv/common/policy/RetryPolicy.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/tikv/common/policy/RetryPolicy.java b/src/main/java/org/tikv/common/policy/RetryPolicy.java index 8e45b64fcb8..4c78f66a302 100644 --- a/src/main/java/org/tikv/common/policy/RetryPolicy.java +++ b/src/main/java/org/tikv/common/policy/RetryPolicy.java @@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableSet; import io.grpc.Status; +import io.prometheus.client.Counter; import io.prometheus.client.Histogram; import java.util.concurrent.Callable; import org.tikv.common.exception.GrpcException; @@ -32,6 +33,12 @@ public abstract class RetryPolicy { .help("grpc request latency.") .labelNames("type") .register(); + public static final Counter GRPC_REQUEST_RETRY_NUM = + Counter.build() + .name("client_java_grpc_requests_retry_num") + .help("grpc request retry num.") + .labelNames("type") + .register(); // handles PD and TiKV's error. private ErrorHandler handler; @@ -70,6 +77,7 @@ public RespT callWithRetry(Callable proc, String methodName) { // Handle request call error boolean retry = handler.handleRequestError(backOffer, e); if (retry) { + GRPC_REQUEST_RETRY_NUM.labels(methodName).inc(); continue; } } @@ -78,7 +86,7 @@ public RespT callWithRetry(Callable proc, String methodName) { if (handler != null) { boolean retry = handler.handleResponseError(backOffer, result); if (retry) { - // add retry counter + GRPC_REQUEST_RETRY_NUM.labels(methodName).inc(); continue; } }