diff --git a/stacks-signer/src/client/stacks_client.rs b/stacks-signer/src/client/stacks_client.rs index 5afec3f76e..75790dc54e 100644 --- a/stacks-signer/src/client/stacks_client.rs +++ b/stacks-signer/src/client/stacks_client.rs @@ -439,13 +439,16 @@ impl StacksClient { chosen_parent: &ConsensusHash, last_sortition: &ConsensusHash, ) -> Result, ClientError> { + let path = self.tenure_forking_info_path(chosen_parent, last_sortition); + let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin); let send_request = || { self.stacks_node_client - .get(self.tenure_forking_info_path(chosen_parent, last_sortition)) + .get(&path) .send() .map_err(backoff::Error::transient) }; let response = retry_with_exponential_backoff(send_request)?; + timer.stop_and_record(); if !response.status().is_success() { return Err(ClientError::RequestFailure(response.status())); } @@ -456,16 +459,16 @@ impl StacksClient { /// Get the sortition information for the latest sortition pub fn get_latest_sortition(&self) -> Result { + let path = self.sortition_info_path(); + let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin); let send_request = || { - self.stacks_node_client - .get(self.sortition_info_path()) - .send() - .map_err(|e| { - warn!("Signer failed to request latest sortition"; "err" => ?e); - e - }) + self.stacks_node_client.get(&path).send().map_err(|e| { + warn!("Signer failed to request latest sortition"; "err" => ?e); + e + }) }; let response = send_request()?; + timer.stop_and_record(); if !response.status().is_success() { return Err(ClientError::RequestFailure(response.status())); } @@ -475,16 +478,16 @@ impl StacksClient { /// Get the sortition information for a given sortition pub fn get_sortition(&self, ch: &ConsensusHash) -> Result { + let path = format!("{}/consensus/{}", self.sortition_info_path(), ch.to_hex()); + let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin); let send_request = || { - self.stacks_node_client - .get(format!("{}/consensus/{}", self.sortition_info_path(), ch.to_hex())) - .send() - .map_err(|e| { - warn!("Signer failed to request sortition"; "consensus_hash" => %ch, "err" => ?e); - e - }) + self.stacks_node_client.get(&path).send().map_err(|e| { + warn!("Signer failed to request sortition"; "consensus_hash" => %ch, "err" => ?e); + e + }) }; let response = send_request()?; + timer.stop_and_record(); if !response.status().is_success() { return Err(ClientError::RequestFailure(response.status())); } @@ -582,7 +585,6 @@ impl StacksClient { /// Retrieve the current pox data from the stacks node pub fn get_pox_data(&self) -> Result { debug!("Getting pox data..."); - #[cfg(feature = "monitoring_prom")] let timer = crate::monitoring::new_rpc_call_timer(&self.pox_path(), &self.http_origin); let send_request = || { self.stacks_node_client @@ -591,7 +593,6 @@ impl StacksClient { .map_err(backoff::Error::transient) }; let response = retry_with_exponential_backoff(send_request)?; - #[cfg(feature = "monitoring_prom")] timer.stop_and_record(); if !response.status().is_success() { return Err(ClientError::RequestFailure(response.status())); @@ -706,13 +707,11 @@ impl StacksClient { /// Returns `true` if the block was accepted or `false` if the block /// was rejected. pub fn post_block(&self, block: &NakamotoBlock) -> Result { + let path = format!("{}{}?broadcast=1", self.http_origin, postblock_v3::PATH); + let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin); let send_request = || { self.stacks_node_client - .post(format!( - "{}{}?broadcast=1", - self.http_origin, - postblock_v3::PATH - )) + .post(&path) .header("Content-Type", "application/octet-stream") .header(AUTHORIZATION, self.auth_password.clone()) .body(block.serialize_to_vec()) @@ -723,6 +722,7 @@ impl StacksClient { }) }; let response = retry_with_exponential_backoff(send_request)?; + timer.stop_and_record(); if !response.status().is_success() { return Err(ClientError::RequestFailure(response.status())); }