@@ -449,13 +449,16 @@ impl StacksClient {
449
449
"chosen_parent" => %chosen_parent,
450
450
"last_sortition" => %last_sortition,
451
451
) ;
452
+ let path = self . tenure_forking_info_path ( chosen_parent, last_sortition) ;
453
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
452
454
let send_request = || {
453
455
self . stacks_node_client
454
- . get ( self . tenure_forking_info_path ( chosen_parent , last_sortition ) )
456
+ . get ( & path )
455
457
. send ( )
456
458
. map_err ( backoff:: Error :: transient)
457
459
} ;
458
460
let response = retry_with_exponential_backoff ( send_request) ?;
461
+ timer. stop_and_record ( ) ;
459
462
if !response. status ( ) . is_success ( ) {
460
463
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
461
464
}
@@ -467,16 +470,16 @@ impl StacksClient {
467
470
/// Get the sortition information for the latest sortition
468
471
pub fn get_latest_sortition ( & self ) -> Result < SortitionInfo , ClientError > {
469
472
debug ! ( "stacks_node_client: Getting latest sortition..." ) ;
473
+ let path = self . sortition_info_path ( ) ;
474
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
470
475
let send_request = || {
471
- self . stacks_node_client
472
- . get ( self . sortition_info_path ( ) )
473
- . send ( )
474
- . map_err ( |e| {
475
- warn ! ( "Signer failed to request latest sortition" ; "err" => ?e) ;
476
- e
477
- } )
476
+ self . stacks_node_client . get ( & path) . send ( ) . map_err ( |e| {
477
+ warn ! ( "Signer failed to request latest sortition" ; "err" => ?e) ;
478
+ e
479
+ } )
478
480
} ;
479
481
let response = send_request ( ) ?;
482
+ timer. stop_and_record ( ) ;
480
483
if !response. status ( ) . is_success ( ) {
481
484
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
482
485
}
@@ -487,16 +490,16 @@ impl StacksClient {
487
490
/// Get the sortition information for a given sortition
488
491
pub fn get_sortition ( & self , ch : & ConsensusHash ) -> Result < SortitionInfo , ClientError > {
489
492
debug ! ( "stacks_node_client: Getting sortition with consensus hash {ch}..." ) ;
493
+ let path = format ! ( "{}/consensus/{}" , self . sortition_info_path( ) , ch. to_hex( ) ) ;
494
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
490
495
let send_request = || {
491
- self . stacks_node_client
492
- . get ( format ! ( "{}/consensus/{}" , self . sortition_info_path( ) , ch. to_hex( ) ) )
493
- . send ( )
494
- . map_err ( |e| {
495
- warn ! ( "Signer failed to request sortition" ; "consensus_hash" => %ch, "err" => ?e) ;
496
- e
497
- } )
496
+ self . stacks_node_client . get ( & path) . send ( ) . map_err ( |e| {
497
+ warn ! ( "Signer failed to request sortition" ; "consensus_hash" => %ch, "err" => ?e) ;
498
+ e
499
+ } )
498
500
} ;
499
501
let response = send_request ( ) ?;
502
+ timer. stop_and_record ( ) ;
500
503
if !response. status ( ) . is_success ( ) {
501
504
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
502
505
}
@@ -604,7 +607,6 @@ impl StacksClient {
604
607
. map_err ( backoff:: Error :: transient)
605
608
} ;
606
609
let response = retry_with_exponential_backoff ( send_request) ?;
607
- #[ cfg( feature = "monitoring_prom" ) ]
608
610
timer. stop_and_record ( ) ;
609
611
if !response. status ( ) . is_success ( ) {
610
612
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
@@ -723,13 +725,11 @@ impl StacksClient {
723
725
"block_id" => %block. header. block_id( ) ,
724
726
"block_height" => %block. header. chain_length,
725
727
) ;
728
+ let path = format ! ( "{}{}?broadcast=1" , self . http_origin, postblock_v3:: PATH ) ;
729
+ let timer = crate :: monitoring:: new_rpc_call_timer ( & path, & self . http_origin ) ;
726
730
let send_request = || {
727
731
self . stacks_node_client
728
- . post ( format ! (
729
- "{}{}?broadcast=1" ,
730
- self . http_origin,
731
- postblock_v3:: PATH
732
- ) )
732
+ . post ( & path)
733
733
. header ( "Content-Type" , "application/octet-stream" )
734
734
. header ( AUTHORIZATION , self . auth_password . clone ( ) )
735
735
. body ( block. serialize_to_vec ( ) )
@@ -740,6 +740,7 @@ impl StacksClient {
740
740
} )
741
741
} ;
742
742
let response = retry_with_exponential_backoff ( send_request) ?;
743
+ timer. stop_and_record ( ) ;
743
744
if !response. status ( ) . is_success ( ) {
744
745
return Err ( ClientError :: RequestFailure ( response. status ( ) ) ) ;
745
746
}
0 commit comments