@@ -439,13 +439,16 @@ impl StacksClient {
439
439
chosen_parent : & ConsensusHash ,
440
440
last_sortition : & ConsensusHash ,
441
441
) -> Result < VecDeque < TenureForkingInfo > , ClientError > {
442
+ let path = self . tenure_forking_info_path ( chosen_parent, last_sortition) ;
443
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
442
444
let send_request = || {
443
445
self . stacks_node_client
444
- . get ( self . tenure_forking_info_path ( chosen_parent , last_sortition ) )
446
+ . get ( & path )
445
447
. send ( )
446
448
. map_err ( backoff:: Error :: transient)
447
449
} ;
448
450
let response = retry_with_exponential_backoff ( send_request) ?;
451
+ timer. stop_and_record ( ) ;
449
452
if !response. status ( ) . is_success ( ) {
450
453
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
451
454
}
@@ -456,16 +459,16 @@ impl StacksClient {
456
459
457
460
/// Get the sortition information for the latest sortition
458
461
pub fn get_latest_sortition ( & self ) -> Result < SortitionInfo , ClientError > {
462
+ let path = self . sortition_info_path ( ) ;
463
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
459
464
let send_request = || {
460
- self . stacks_node_client
461
- . get ( self . sortition_info_path ( ) )
462
- . send ( )
463
- . map_err ( |e| {
464
- warn ! ( "Signer failed to request latest sortition" ; "err" => ?e) ;
465
- e
466
- } )
465
+ self . stacks_node_client . get ( & path) . send ( ) . map_err ( |e| {
466
+ warn ! ( "Signer failed to request latest sortition" ; "err" => ?e) ;
467
+ e
468
+ } )
467
469
} ;
468
470
let response = send_request ( ) ?;
471
+ timer. stop_and_record ( ) ;
469
472
if !response. status ( ) . is_success ( ) {
470
473
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
471
474
}
@@ -475,16 +478,16 @@ impl StacksClient {
475
478
476
479
/// Get the sortition information for a given sortition
477
480
pub fn get_sortition ( & self , ch : & ConsensusHash ) -> Result < SortitionInfo , ClientError > {
481
+ let path = format ! ( "{}/consensus/{}" , self . sortition_info_path( ) , ch. to_hex( ) ) ;
482
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
478
483
let send_request = || {
479
- self . stacks_node_client
480
- . get ( format ! ( "{}/consensus/{}" , self . sortition_info_path( ) , ch. to_hex( ) ) )
481
- . send ( )
482
- . map_err ( |e| {
483
- warn ! ( "Signer failed to request sortition" ; "consensus_hash" => %ch, "err" => ?e) ;
484
- e
485
- } )
484
+ self . stacks_node_client . get ( & path) . send ( ) . map_err ( |e| {
485
+ warn ! ( "Signer failed to request sortition" ; "consensus_hash" => %ch, "err" => ?e) ;
486
+ e
487
+ } )
486
488
} ;
487
489
let response = send_request ( ) ?;
490
+ timer. stop_and_record ( ) ;
488
491
if !response. status ( ) . is_success ( ) {
489
492
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
490
493
}
@@ -582,7 +585,6 @@ impl StacksClient {
582
585
/// Retrieve the current pox data from the stacks node
583
586
pub fn get_pox_data ( & self ) -> Result < RPCPoxInfoData , ClientError > {
584
587
debug ! ( "Getting pox data..." ) ;
585
- #[ cfg( feature = "monitoring_prom" ) ]
586
588
let timer = crate :: monitoring:: new_rpc_call_timer ( & self . pox_path ( ) , & self . http_origin ) ;
587
589
let send_request = || {
588
590
self . stacks_node_client
@@ -591,7 +593,6 @@ impl StacksClient {
591
593
. map_err ( backoff:: Error :: transient)
592
594
} ;
593
595
let response = retry_with_exponential_backoff ( send_request) ?;
594
- #[ cfg( feature = "monitoring_prom" ) ]
595
596
timer. stop_and_record ( ) ;
596
597
if !response. status ( ) . is_success ( ) {
597
598
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
@@ -706,13 +707,11 @@ impl StacksClient {
706
707
/// Returns `true` if the block was accepted or `false` if the block
707
708
/// was rejected.
708
709
pub fn post_block ( & self , block : & NakamotoBlock ) -> Result < bool , ClientError > {
710
+ let path = format ! ( "{}{}?broadcast=1" , self . http_origin, postblock_v3:: PATH ) ;
711
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
709
712
let send_request = || {
710
713
self . stacks_node_client
711
- . post ( format ! (
712
- "{}{}?broadcast=1" ,
713
- self . http_origin,
714
- postblock_v3:: PATH
715
- ) )
714
+ . post ( & path)
716
715
. header ( "Content-Type" , "application/octet-stream" )
717
716
. header ( AUTHORIZATION , self . auth_password . clone ( ) )
718
717
. body ( block. serialize_to_vec ( ) )
@@ -723,6 +722,7 @@ impl StacksClient {
723
722
} )
724
723
} ;
725
724
let response = retry_with_exponential_backoff ( send_request) ?;
725
+ timer. stop_and_record ( ) ;
726
726
if !response. status ( ) . is_success ( ) {
727
727
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
728
728
}
0 commit comments