From 55084bd5844c42a5df8cf9e6fa2d74a84ccf304c Mon Sep 17 00:00:00 2001 From: Dan Kanefsky <56059752+boojamya@users.noreply.github.com> Date: Tue, 25 Jul 2023 12:21:03 -0700 Subject: [PATCH] Export configured gas prices to prometheus wallet balance metric (#1236) * export gas price to prom * update label * update fees spent metric * snake case --- relayer/chains/cosmos/cosmos_chain_processor.go | 2 +- relayer/chains/cosmos/tx.go | 2 +- relayer/processor/metrics.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/relayer/chains/cosmos/cosmos_chain_processor.go b/relayer/chains/cosmos/cosmos_chain_processor.go index b4bef6d47..9189e945d 100644 --- a/relayer/chains/cosmos/cosmos_chain_processor.go +++ b/relayer/chains/cosmos/cosmos_chain_processor.go @@ -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) } } diff --git a/relayer/chains/cosmos/tx.go b/relayer/chains/cosmos/tx.go index e4c06714d..8d9ae37d1 100644 --- a/relayer/chains/cosmos/tx.go +++ b/relayer/chains/cosmos/tx.go @@ -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) } } diff --git a/relayer/processor/metrics.go b/relayer/processor/metrics.go index 96de766b6..6c77b5f3e 100644 --- a/relayer/processor/metrics.go +++ b/relayer/processor/metrics.go @@ -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) { @@ -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)