Skip to content

Commit

Permalink
fix(jsonrpc): Fix metrics usage and signature to prevent fails (#4070)
Browse files Browse the repository at this point in the history
Fixes #4063 wrong usage of metrics
  • Loading branch information
khorolets authored Mar 11, 2021
1 parent 8034c99 commit 48fa528
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions chain/jsonrpc-primitives/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lazy_static! {
pub static ref RPC_UNREACHABLE_ERROR_COUNT: near_metrics::Result<IntCounterVec> =
near_metrics::try_create_int_counter_vec(
"near_rpc_unreachable_errors_total",
"Total count of Unreachable RPC errors returned, by method",
&["method"]
"Total count of Unreachable RPC errors returned, by target error enum",
&["target_error_enum"]
);
}
2 changes: 1 addition & 1 deletion chain/jsonrpc-primitives/src/types/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl From<near_client_primitives::types::GetBlockError> for RpcBlockError {
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", &error_message);
near_metrics::inc_counter_vec(
&crate::metrics::RPC_UNREACHABLE_ERROR_COUNT,
&["RpcBlockError", &error_message],
&["RpcBlockError"],
);
Self::Unreachable(error_message)
}
Expand Down
2 changes: 1 addition & 1 deletion chain/jsonrpc-primitives/src/types/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl From<near_client_primitives::types::GetChunkError> for RpcChunkError {
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", &error_message);
near_metrics::inc_counter_vec(
&crate::metrics::RPC_UNREACHABLE_ERROR_COUNT,
&["RpcChunkError", &error_message],
&["RpcChunkError"],
);
Self::Unreachable(error_message)
}
Expand Down
2 changes: 1 addition & 1 deletion chain/jsonrpc-primitives/src/types/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl From<near_client_primitives::types::GetProtocolConfigError> for RpcProtocol
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", &error_message);
near_metrics::inc_counter_vec(
&crate::metrics::RPC_UNREACHABLE_ERROR_COUNT,
&["RpcProtocolConfigError", &error_message],
&["RpcProtocolConfigError"],
);
Self::Unreachable(error_message)
}
Expand Down
2 changes: 1 addition & 1 deletion chain/jsonrpc-primitives/src/types/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl From<near_client_primitives::types::QueryError> for RpcQueryError {
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", &error_message);
near_metrics::inc_counter_vec(
&crate::metrics::RPC_UNREACHABLE_ERROR_COUNT,
&["RpcQueryError", &error_message],
&["RpcQueryError"],
);
Self::Unreachable { error_message }
}
Expand Down
2 changes: 1 addition & 1 deletion chain/jsonrpc-primitives/src/types/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl From<near_client_primitives::types::GetReceiptError> for RpcReceiptError {
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", &error_message);
near_metrics::inc_counter_vec(
&crate::metrics::RPC_UNREACHABLE_ERROR_COUNT,
&["RpcReceiptError", &error_message],
&["RpcReceiptError"],
);
Self::Unreachable(error_message)
}
Expand Down
7 changes: 4 additions & 3 deletions chain/jsonrpc-primitives/src/types/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ impl From<near_client_primitives::types::GetValidatorInfoError> for RpcValidator
near_client_primitives::types::GetValidatorInfoError::IOError(s) => {
Self::InternalError(s)
}
near_client_primitives::types::GetValidatorInfoError::Unreachable(s) => {
near_client_primitives::types::GetValidatorInfoError::Unreachable(error_message) => {
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", &error_message);
near_metrics::inc_counter_vec(
&crate::metrics::RPC_UNREACHABLE_ERROR_COUNT,
&["RpcValidatorError", &s],
&["RpcValidatorError"],
);
Self::Unreachable(s)
Self::Unreachable(error_message)
}
}
}
Expand Down

0 comments on commit 48fa528

Please sign in to comment.