more context on everything

This commit is contained in:
Bryan Stitt 2023-01-25 01:00:28 -08:00
parent 0c879c5613
commit e85965ec12
3 changed files with 10 additions and 7 deletions

@ -53,11 +53,13 @@ pub async fn main(
.post(&rpc)
.json(&block_by_number_request)
.send()
.await?
.await
.context(format!("error fetching block from {}", rpc))?
.json::<JsonRpcResponse<Block<TxHash>>>()
.await?
.await
.context(format!("error parsing block from {}", rpc))?
.result
.context(format!("error fetching block from {}", rpc))?;
.context(format!("no block from {}", rpc))?;
// check the parent because b and c might not be as fast as a
let parent_hash = a.parent_hash;

@ -95,7 +95,7 @@ impl SentrydSubCommand {
}
while let Some(err) = error_receiver.recv().await {
log::log!(err.level, "check failed: {:?}", err);
log::log!(err.level, "check failed: {:#?}", err);
if matches!(err.level, log::Level::Error) {
let alert = pagerduty_alert(
@ -108,20 +108,20 @@ impl SentrydSubCommand {
Some("web3-proxy-sentry".to_string()),
pagerduty_rs::types::Severity::Error,
None,
format!("{}", err.anyhow),
format!("{:#?}", err.anyhow),
None,
);
if let Some(pagerduty_async) = pagerduty_async.as_ref() {
info!(
"sending to pagerduty: {}",
"sending to pagerduty: {:#}",
serde_json::to_string_pretty(&alert)?
);
if let Err(err) =
pagerduty_async.event(Event::AlertTrigger(alert)).await
{
error!("Failed sending to pagerduty: {}", err);
error!("Failed sending to pagerduty: {:#?}", err);
}
}
}

@ -59,6 +59,7 @@ pub fn pagerduty_alert<T: Serialize>(
source.unwrap_or_else(|| gethostname().into_string().unwrap_or("unknown".to_string()));
let mut s = DefaultHasher::new();
// TODO: include severity here?
summary.hash(&mut s);
client.hash(&mut s);
client_url.hash(&mut s);