File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ mod pd;
107
107
mod proto;
108
108
mod region;
109
109
mod region_cache;
110
+ #[ cfg( feature = "prometheus" ) ]
110
111
mod stats;
111
112
mod store;
112
113
mod timestamp;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ use crate::proto::pdpb::{self};
20
20
use crate :: region:: RegionId ;
21
21
use crate :: region:: RegionWithLeader ;
22
22
use crate :: region:: StoreId ;
23
+ #[ cfg( feature = "prometheus" ) ]
23
24
use crate :: stats:: pd_stats;
24
25
use crate :: Error ;
25
26
use crate :: Result ;
@@ -75,15 +76,22 @@ impl<Cl> RetryClient<Cl> {
75
76
76
77
macro_rules! retry_core {
77
78
( $self: ident, $tag: literal, $call: expr) => { {
79
+ #[ cfg( feature = "prometheus" ) ]
78
80
let stats = pd_stats( $tag) ;
79
81
let mut last_err = Ok ( ( ) ) ;
80
82
for _ in 0 ..LEADER_CHANGE_RETRY {
81
83
let res = $call;
82
84
85
+ #[ cfg( feature = "prometheus" ) ]
83
86
match stats. done( res) {
84
87
Ok ( r) => return Ok ( r) ,
85
88
Err ( e) => last_err = Err ( e) ,
86
89
}
90
+ #[ cfg( not( feature = "prometheus" ) ) ]
91
+ match res {
92
+ Ok ( r) => return Ok ( r) ,
93
+ Err ( e) => last_err = Err ( e) ,
94
+ }
87
95
88
96
let mut reconnect_count = MAX_REQUEST_COUNT ;
89
97
while let Err ( e) = $self. reconnect( RECONNECT_INTERVAL_SEC ) . await {
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use crate::request::shard::HasNextBatch;
21
21
use crate :: request:: NextBatch ;
22
22
use crate :: request:: Shardable ;
23
23
use crate :: request:: { KvRequest , StoreRequest } ;
24
+ #[ cfg( feature = "prometheus" ) ]
24
25
use crate :: stats:: tikv_stats;
25
26
use crate :: store:: HasRegionError ;
26
27
use crate :: store:: HasRegionErrors ;
@@ -60,13 +61,15 @@ impl<Req: KvRequest> Plan for Dispatch<Req> {
60
61
type Result = Req :: Response ;
61
62
62
63
async fn execute ( & self ) -> Result < Self :: Result > {
64
+ #[ cfg( feature = "prometheus" ) ]
63
65
let stats = tikv_stats ( self . request . label ( ) ) ;
64
66
let result = self
65
67
. kv_client
66
68
. as_ref ( )
67
69
. expect ( "Unreachable: kv_client has not been initialised in Dispatch" )
68
70
. dispatch ( & self . request )
69
71
. await ;
72
+ #[ cfg( feature = "prometheus" ) ]
70
73
let result = stats. done ( result) ;
71
74
result. map ( |r| {
72
75
* r. downcast ( )
You can’t perform that action at this time.
0 commit comments