Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Add metrics for rpc send-transaction failures (backport #18156) (#18163)
Browse files Browse the repository at this point in the history
* Add metrics for rpc send-tx failures (#18156)

(cherry picked from commit 64cff8c)

# Conflicts:
#	core/src/rpc.rs

* Fix conflict

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
  • Loading branch information
3 people authored Jun 23, 2021
1 parent 37f618f commit 07865a9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use solana_sdk::{
stake_history::StakeHistory,
system_instruction,
sysvar::stake_history,
transaction::{self, Transaction},
transaction::{self, Transaction, TransactionError},
};
use solana_stake_program::stake_state::StakeState;
use solana_transaction_status::{
Expand Down Expand Up @@ -3144,12 +3144,14 @@ pub mod rpc_full {
match meta.health.check() {
RpcHealthStatus::Ok => (),
RpcHealthStatus::Unknown => {
inc_new_counter_info!("rpc-send-tx_health-unknown", 1);
return Err(RpcCustomError::NodeUnhealthy {
num_slots_behind: None,
}
.into());
}
RpcHealthStatus::Behind { num_slots } => {
inc_new_counter_info!("rpc-send-tx_health-behind", 1);
return Err(RpcCustomError::NodeUnhealthy {
num_slots_behind: Some(num_slots),
}
Expand All @@ -3158,6 +3160,14 @@ pub mod rpc_full {
}

if let (Err(err), logs, _) = preflight_bank.simulate_transaction(&transaction) {
match err {
TransactionError::BlockhashNotFound => {
inc_new_counter_info!("rpc-send-tx_err-blockhash-not-found", 1);
}
_ => {
inc_new_counter_info!("rpc-send-tx_err-other", 1);
}
}
return Err(RpcCustomError::SendTransactionPreflightFailure {
message: format!("Transaction simulation failed: {}", err),
result: RpcSimulateTransactionResult {
Expand Down

0 comments on commit 07865a9

Please sign in to comment.