-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(en): Add health checks for EN components (#1088)
## What ❔ Adds health checks with intelligent details for most of components run by the external node. ## Why ❔ These health checks would allow monitoring what's going on with an EN easier both for humans and machines. The latter could be used in integration tests etc. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`. - [x] Linkcheck has been run via `zk linkcheck`.
- Loading branch information
Showing
16 changed files
with
476 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! Miscellaneous helpers for the EN. | ||
use zksync_health_check::{async_trait, CheckHealth, Health, HealthStatus}; | ||
use zksync_web3_decl::{jsonrpsee::http_client::HttpClient, namespaces::EthNamespaceClient}; | ||
|
||
/// Main node health check. | ||
#[derive(Debug)] | ||
pub(crate) struct MainNodeHealthCheck(HttpClient); | ||
|
||
impl From<HttpClient> for MainNodeHealthCheck { | ||
fn from(client: HttpClient) -> Self { | ||
Self(client) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl CheckHealth for MainNodeHealthCheck { | ||
fn name(&self) -> &'static str { | ||
"main_node_http_rpc" | ||
} | ||
|
||
async fn check_health(&self) -> Health { | ||
if let Err(err) = self.0.get_block_number().await { | ||
tracing::warn!("Health-check call to main node HTTP RPC failed: {err}"); | ||
let details = serde_json::json!({ | ||
"error": err.to_string(), | ||
}); | ||
return Health::from(HealthStatus::NotReady).with_details(details); | ||
} | ||
HealthStatus::Ready.into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.