diff --git a/web3_proxy/src/bin/web3_proxy_cli/main.rs b/web3_proxy/src/bin/web3_proxy_cli/main.rs index da524b68..cea65a8f 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/main.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/main.rs @@ -366,7 +366,7 @@ fn main() -> anyhow::Result<()> { warn!("sentry_url is not set! Logs will only show in this console"); } - x.main(pagerduty_async).await + x.main(pagerduty_async, top_config).await } SubCommand::RpcAccounting(x) => { let db_url = cli_config diff --git a/web3_proxy/src/bin/web3_proxy_cli/sentryd/mod.rs b/web3_proxy/src/bin/web3_proxy_cli/sentryd/mod.rs index 26dc43bd..0708f7a7 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/sentryd/mod.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/sentryd/mod.rs @@ -1,6 +1,7 @@ mod compare; mod simple; +use anyhow::Context; use argh::FromArgs; use futures::{ stream::{FuturesUnordered, StreamExt}, @@ -11,7 +12,7 @@ use pagerduty_rs::{eventsv2async::EventsV2 as PagerdutyAsyncEventsV2, types::Eve use std::time::Duration; use tokio::sync::mpsc; use tokio::time::{interval, MissedTickBehavior}; -use web3_proxy::pagerduty::pagerduty_alert; +use web3_proxy::{config::TopConfig, pagerduty::pagerduty_alert}; #[derive(FromArgs, PartialEq, Debug, Eq)] /// Loop healthchecks and send pager duty alerts if any fail @@ -21,6 +22,10 @@ pub struct SentrydSubCommand { /// the main (HTTP only) web3-proxy being checked. web3_proxy: String, + /// the chain id to require. Only used if not using --config. + #[argh(option)] + chain_id: Option, + #[argh(option)] /// warning threshold for age of the best known head block max_age: i64, @@ -50,9 +55,18 @@ struct Error { } impl SentrydSubCommand { - pub async fn main(self, pagerduty_async: Option) -> anyhow::Result<()> { + pub async fn main( + self, + pagerduty_async: Option, + top_config: Option, + ) -> anyhow::Result<()> { // sentry logging should already be configured + let chain_id = self + .chain_id + .or_else(|| top_config.map(|x| x.app.chain_id)) + .context("--config or --chain-id required")?; + let web3_proxy = self.web3_proxy.trim_end_matches("/").to_string(); let other_proxy: Vec<_> = self @@ -85,7 +99,7 @@ impl SentrydSubCommand { if matches!(err.level, log::Level::Error) { let alert = pagerduty_alert( - None, + Some(chain_id), Some(err.class), "web3-proxy-sentry".to_string(), None,