Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/org/tikv/common/policy/RetryPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,6 +33,12 @@ public abstract class RetryPolicy<RespT> {
.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<RespT> handler;
Expand Down Expand Up @@ -70,6 +77,7 @@ public RespT callWithRetry(Callable<RespT> proc, String methodName) {
// Handle request call error
boolean retry = handler.handleRequestError(backOffer, e);
if (retry) {
GRPC_REQUEST_RETRY_NUM.labels(methodName).inc();
continue;
}
}
Expand All @@ -78,7 +86,7 @@ public RespT callWithRetry(Callable<RespT> 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;
}
}
Expand Down