add --chain-id to sentryd too

This commit is contained in:
Bryan Stitt 2023-01-24 04:51:55 -08:00
parent 23f31c9129
commit 4f9d0f6336
2 changed files with 18 additions and 4 deletions

View File

@ -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

View File

@ -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<u64>,
#[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<PagerdutyAsyncEventsV2>) -> anyhow::Result<()> {
pub async fn main(
self,
pagerduty_async: Option<PagerdutyAsyncEventsV2>,
top_config: Option<TopConfig>,
) -> 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,