mirror of https://github.com/tikv/client-java.git
Signed-off-by: ti-srebot <ti-srebot@pingcap.com> Co-authored-by: birdstorm <samuelwyf@hotmail.com>
This commit is contained in:
parent
01b391ff2f
commit
6a5ea6fb8b
|
|
@ -17,6 +17,7 @@ package org.tikv.common.policy;
|
|||
|
||||
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<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;
|
||||
|
|
@ -70,6 +77,7 @@ public abstract class RetryPolicy<RespT> {
|
|||
// 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 abstract class RetryPolicy<RespT> {
|
|||
if (handler != null) {
|
||||
boolean retry = handler.handleResponseError(backOffer, result);
|
||||
if (retry) {
|
||||
// add retry counter
|
||||
GRPC_REQUEST_RETRY_NUM.labels(methodName).inc();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue