chore: agent metric log tweaks (#4244)

### Description

- some small tweaks as I looked into a recent issue with metrics

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
pull/4246/head
Trevor Porter 4 months ago committed by GitHub
parent 5125b798df
commit fe9365fdb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      rust/chains/hyperlane-ethereum/src/rpc_clients/provider.rs
  2. 14
      rust/hyperlane-base/src/metrics/agent_metrics.rs

@ -126,6 +126,7 @@ where
ChainCommunicationError::Other(HyperlaneCustomErrorWrapper::new(Box::new(e))) ChainCommunicationError::Other(HyperlaneCustomErrorWrapper::new(Box::new(e)))
})? })?
else { else {
tracing::trace!(domain=?self.domain, "Latest block not found");
return Ok(None); return Ok(None);
}; };

@ -179,19 +179,21 @@ impl MetricsUpdater {
return; return;
}; };
let chain = self.conf.domain.name(); let chain = self.conf.domain.name();
debug!(?chain, "Updating metrics"); debug!(chain, "Updating metrics");
let chain_metrics = match self.provider.get_chain_metrics().await { let chain_metrics = match self.provider.get_chain_metrics().await {
Ok(Some(chain_metrics)) => chain_metrics, Ok(Some(chain_metrics)) => chain_metrics,
Err(err) => { Err(err) => {
trace!(?chain, ?err, "Failed to get chain metrics"); trace!(chain, ?err, "Failed to get chain metrics");
return;
}
_ => {
trace!(chain, "No chain metrics available");
return; return;
} }
// This is the case hit by chains with an empty impl, no need to log an error
_ => return,
}; };
let height = chain_metrics.latest_block.number as i64; let height = chain_metrics.latest_block.number as i64;
trace!("Block height for chain {chain} is {height}"); trace!(chain, height, "Fetched block height for metrics");
block_height block_height
.with(&hashmap! { "chain" => chain }) .with(&hashmap! { "chain" => chain })
.set(height); .set(height);
@ -201,7 +203,7 @@ impl MetricsUpdater {
let gas = u256_as_scaled_f64(chain_metrics.min_gas_price.unwrap_or_default(), protocol) let gas = u256_as_scaled_f64(chain_metrics.min_gas_price.unwrap_or_default(), protocol)
* decimals_scale; * decimals_scale;
trace!( trace!(
?chain, chain,
gas = format!("{gas:.2}"), gas = format!("{gas:.2}"),
"Gas price updated for chain (using lowest denomination)" "Gas price updated for chain (using lowest denomination)"
); );

Loading…
Cancel
Save