@@ -33,19 +33,19 @@ public abstract class RetryPolicy<RespT> {
3333 HistogramUtils .buildDuration ()
3434 .name ("client_java_grpc_single_requests_latency" )
3535 .help ("grpc request latency." )
36- .labelNames ("type" )
36+ .labelNames ("type" , "cluster" )
3737 .register ();
3838 public static final Histogram CALL_WITH_RETRY_DURATION =
3939 HistogramUtils .buildDuration ()
4040 .name ("client_java_call_with_retry_duration" )
4141 .help ("callWithRetry duration." )
42- .labelNames ("type" )
42+ .labelNames ("type" , "cluster" )
4343 .register ();
4444 public static final Counter GRPC_REQUEST_RETRY_NUM =
4545 Counter .build ()
4646 .name ("client_java_grpc_requests_retry_num" )
4747 .help ("grpc request retry num." )
48- .labelNames ("type" )
48+ .labelNames ("type" , "cluster" )
4949 .register ();
5050
5151 // handles PD and TiKV's error.
@@ -70,16 +70,16 @@ private void rethrowNotRecoverableException(Exception e) {
7070 }
7171
7272 public RespT callWithRetry (Callable <RespT > proc , String methodName , BackOffer backOffer ) {
73- Histogram .Timer callWithRetryTimer = CALL_WITH_RETRY_DURATION .labels (methodName ).startTimer ();
73+ String [] labels = new String [] {methodName , backOffer .getClusterId ().toString ()};
74+ Histogram .Timer callWithRetryTimer = CALL_WITH_RETRY_DURATION .labels (labels ).startTimer ();
7475 SlowLogSpan callWithRetrySlowLogSpan =
7576 backOffer .getSlowLog ().start ("callWithRetry " + methodName );
7677 try {
7778 while (true ) {
7879 RespT result = null ;
7980 try {
8081 // add single request duration histogram
81- Histogram .Timer requestTimer =
82- GRPC_SINGLE_REQUEST_LATENCY .labels (methodName ).startTimer ();
82+ Histogram .Timer requestTimer = GRPC_SINGLE_REQUEST_LATENCY .labels (labels ).startTimer ();
8383 SlowLogSpan slowLogSpan = backOffer .getSlowLog ().start ("gRPC " + methodName );
8484 try {
8585 result = proc .call ();
@@ -93,7 +93,7 @@ public RespT callWithRetry(Callable<RespT> proc, String methodName, BackOffer ba
9393 backOffer .checkTimeout ();
9494 boolean retry = handler .handleRequestError (backOffer , e );
9595 if (retry ) {
96- GRPC_REQUEST_RETRY_NUM .labels (methodName ).inc ();
96+ GRPC_REQUEST_RETRY_NUM .labels (labels ).inc ();
9797 continue ;
9898 } else {
9999 return result ;
@@ -104,7 +104,7 @@ public RespT callWithRetry(Callable<RespT> proc, String methodName, BackOffer ba
104104 if (handler != null ) {
105105 boolean retry = handler .handleResponseError (backOffer , result );
106106 if (retry ) {
107- GRPC_REQUEST_RETRY_NUM .labels (methodName ).inc ();
107+ GRPC_REQUEST_RETRY_NUM .labels (labels ).inc ();
108108 continue ;
109109 }
110110 }
0 commit comments