@@ -32,6 +32,7 @@ use crate::frame::response::result;
3232use crate :: network:: Connection ;
3333use crate :: observability:: driver_tracing:: RequestSpan ;
3434use crate :: observability:: history:: { self , HistoryListener } ;
35+ #[ cfg( feature = "metrics" ) ]
3536use crate :: observability:: metrics:: Metrics ;
3637use crate :: policies:: load_balancing:: { self , RoutingInfo } ;
3738use crate :: policies:: retry:: { RequestInfo , RetryDecision , RetrySession } ;
@@ -66,6 +67,7 @@ pub(crate) struct PreparedIteratorConfig {
6667 pub ( crate ) values : SerializedValues ,
6768 pub ( crate ) execution_profile : Arc < ExecutionProfileInner > ,
6869 pub ( crate ) cluster_state : Arc < ClusterState > ,
70+ #[ cfg( feature = "metrics" ) ]
6971 pub ( crate ) metrics : Arc < Metrics > ,
7072}
7173
@@ -139,6 +141,7 @@ struct PagerWorker<'a, QueryFunc, SpanCreatorFunc> {
139141 query_consistency : Consistency ,
140142 retry_session : Box < dyn RetrySession > ,
141143 execution_profile : Arc < ExecutionProfileInner > ,
144+ #[ cfg( feature = "metrics" ) ]
142145 metrics : Arc < Metrics > ,
143146
144147 paging_state : PagingState ,
@@ -237,11 +240,13 @@ where
237240
238241 match retry_decision {
239242 RetryDecision :: RetrySameTarget ( cl) => {
243+ #[ cfg( feature = "metrics" ) ]
240244 self . metrics . inc_retries_num ( ) ;
241245 current_consistency = cl. unwrap_or ( current_consistency) ;
242246 continue ' same_node_retries;
243247 }
244248 RetryDecision :: RetryNextTarget ( cl) => {
249+ #[ cfg( feature = "metrics" ) ]
245250 self . metrics . inc_retries_num ( ) ;
246251 current_consistency = cl. unwrap_or ( current_consistency) ;
247252 continue ' nodes_in_plan;
@@ -301,6 +306,7 @@ where
301306 node : NodeRef < ' _ > ,
302307 request_span : & RequestSpan ,
303308 ) -> Result < ControlFlow < PageSendAttemptedProof , ( ) > , RequestAttemptError > {
309+ #[ cfg( feature = "metrics" ) ]
304310 self . metrics . inc_total_paged_queries ( ) ;
305311 let query_start = std:: time:: Instant :: now ( ) ;
306312
@@ -326,6 +332,7 @@ where
326332 tracing_id,
327333 ..
328334 } ) => {
335+ #[ cfg( feature = "metrics" ) ]
329336 let _ = self . metrics . log_query_latency ( elapsed. as_millis ( ) as u64 ) ;
330337 self . log_attempt_success ( ) ;
331338 self . log_request_success ( ) ;
@@ -361,6 +368,7 @@ where
361368 Ok ( ControlFlow :: Continue ( ( ) ) )
362369 }
363370 Err ( err) => {
371+ #[ cfg( feature = "metrics" ) ]
364372 self . metrics . inc_failed_paged_queries ( ) ;
365373 self . execution_profile
366374 . load_balancing_policy
@@ -380,6 +388,7 @@ where
380388 Ok ( ControlFlow :: Break ( proof) )
381389 }
382390 Ok ( response) => {
391+ #[ cfg( feature = "metrics" ) ]
383392 self . metrics . inc_failed_paged_queries ( ) ;
384393 let err =
385394 RequestAttemptError :: UnexpectedResponse ( response. response . to_response_kind ( ) ) ;
@@ -664,7 +673,7 @@ impl QueryPager {
664673 statement : Statement ,
665674 execution_profile : Arc < ExecutionProfileInner > ,
666675 cluster_state : Arc < ClusterState > ,
667- metrics : Arc < Metrics > ,
676+ # [ cfg ( feature = "metrics" ) ] metrics : Arc < Metrics > ,
668677 ) -> Result < Self , NextPageError > {
669678 let ( sender, receiver) = mpsc:: channel :: < Result < ReceivedPage , NextPageError > > ( 1 ) ;
670679
@@ -727,6 +736,7 @@ impl QueryPager {
727736 query_consistency : consistency,
728737 retry_session,
729738 execution_profile,
739+ #[ cfg( feature = "metrics" ) ]
730740 metrics,
731741 paging_state : PagingState :: start ( ) ,
732742 history_listener : statement. config . history_listener . clone ( ) ,
@@ -847,6 +857,7 @@ impl QueryPager {
847857 query_consistency : consistency,
848858 retry_session,
849859 execution_profile : config. execution_profile ,
860+ #[ cfg( feature = "metrics" ) ]
850861 metrics : config. metrics ,
851862 paging_state : PagingState :: start ( ) ,
852863 history_listener : config. prepared . config . history_listener . clone ( ) ,
0 commit comments