Skip to content

Commit

Permalink
Export configured gas prices to prometheus wallet balance metric (#1236)
Browse files Browse the repository at this point in the history
* export gas price to prom

* update label

* update fees spent metric

* snake case
  • Loading branch information
boojamya authored Jul 25, 2023
1 parent 22bce42 commit 55084bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion relayer/chains/cosmos/cosmos_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,6 @@ func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) {
bal := relayerWalletBalances.AmountOf(gasDenom.Denom)
// Convert to a big float to get a float64 for metrics
f, _ := big.NewFloat(0.0).SetInt(bal.BigInt()).Float64()
ccp.metrics.SetWalletBalance(ccp.chainProvider.ChainId(), ccp.chainProvider.Key(), address, gasDenom.Denom, f)
ccp.metrics.SetWalletBalance(ccp.chainProvider.ChainId(), ccp.chainProvider.PCfg.GasPrices, ccp.chainProvider.Key(), address, gasDenom.Denom, f)
}
}
2 changes: 1 addition & 1 deletion relayer/chains/cosmos/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ func (cc *CosmosProvider) UpdateFeesSpent(chain, key, address string, fees sdk.C
for _, fee := range cc.TotalFees {
// Convert to a big float to get a float64 for metrics
f, _ := big.NewFloat(0.0).SetInt(fee.Amount.BigInt()).Float64()
cc.metrics.SetFeesSpent(chain, key, address, fee.GetDenom(), f)
cc.metrics.SetFeesSpent(chain, cc.PCfg.GasPrices, key, address, fee.GetDenom(), f)
}
}

Expand Down
10 changes: 5 additions & 5 deletions relayer/processor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func (m *PrometheusMetrics) SetLatestHeight(chain string, height int64) {
m.LatestHeightGauge.WithLabelValues(chain).Set(float64(height))
}

func (m *PrometheusMetrics) SetWalletBalance(chain, key, address, denom string, balance float64) {
m.WalletBalance.WithLabelValues(chain, key, address, denom).Set(balance)
func (m *PrometheusMetrics) SetWalletBalance(chain, gasPrice, key, address, denom string, balance float64) {
m.WalletBalance.WithLabelValues(chain, gasPrice, key, address, denom).Set(balance)
}

func (m *PrometheusMetrics) SetFeesSpent(chain, key, address, denom string, amount float64) {
m.FeesSpent.WithLabelValues(chain, key, address, denom).Set(amount)
func (m *PrometheusMetrics) SetFeesSpent(chain, gasPrice, key, address, denom string, amount float64) {
m.FeesSpent.WithLabelValues(chain, gasPrice, key, address, denom).Set(amount)
}

func (m *PrometheusMetrics) SetClientExpiration(pathName, chain, clientID, trustingPeriod string, timeToExpiration time.Duration) {
Expand All @@ -44,7 +44,7 @@ func (m *PrometheusMetrics) SetClientExpiration(pathName, chain, clientID, trust
func NewPrometheusMetrics() *PrometheusMetrics {
packetLabels := []string{"path", "chain", "channel", "port", "type"}
heightLabels := []string{"chain"}
walletLabels := []string{"chain", "key", "address", "denom"}
walletLabels := []string{"chain", "gas_price", "key", "address", "denom"}
clientExpirationLables := []string{"path_name", "chain", "client_id", "trusting_period"}
registry := prometheus.NewRegistry()
registerer := promauto.With(registry)
Expand Down

0 comments on commit 55084bd

Please sign in to comment.