Commit 2d09010b authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-dispute-mon: Ensure a zero value is set for sufficient/insufficient labels (#10481)

If the collateral for a DelayedWETH contract is sufficient and then becomes insufficient, we need to zero out the metric with the sufficient label and set the values on the insufficient labelled version.
parent 48393a6a
...@@ -453,12 +453,18 @@ func (m *Metrics) RecordFailedGames(count int) { ...@@ -453,12 +453,18 @@ func (m *Metrics) RecordFailedGames(count int) {
} }
func (m *Metrics) RecordBondCollateral(addr common.Address, required *big.Int, available *big.Int) { func (m *Metrics) RecordBondCollateral(addr common.Address, required *big.Int, available *big.Int) {
balance := "sufficient" balanceLabel := "sufficient"
zeroBalanceLabel := "insufficient"
if required.Cmp(available) > 0 { if required.Cmp(available) > 0 {
balance = "insufficient" balanceLabel = "insufficient"
zeroBalanceLabel = "sufficient"
} }
m.requiredCollateral.WithLabelValues(addr.Hex(), balance).Set(weiToEther(required)) m.requiredCollateral.WithLabelValues(addr.Hex(), balanceLabel).Set(weiToEther(required))
m.availableCollateral.WithLabelValues(addr.Hex(), balance).Set(weiToEther(available)) m.availableCollateral.WithLabelValues(addr.Hex(), balanceLabel).Set(weiToEther(available))
// If the balance is sufficient, make sure the insufficient label is zeroed out and vice versa.
m.requiredCollateral.WithLabelValues(addr.Hex(), zeroBalanceLabel).Set(0)
m.availableCollateral.WithLabelValues(addr.Hex(), zeroBalanceLabel).Set(0)
} }
const ( const (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment