diff --git a/relayer/processor/message_processor.go b/relayer/processor/message_processor.go index bb0f66b12..fe355cfa7 100644 --- a/relayer/processor/message_processor.go +++ b/relayer/processor/message_processor.go @@ -141,8 +141,14 @@ func (mp *messageProcessor) shouldUpdateClientNow(ctx context.Context, src, dst shouldUpdateClientNow := enoughBlocksPassed && (pastTwoThirdsTrustingPeriod || pastConfiguredClientUpdateThreshold) + if mp.metrics != nil { + timeToExpiration := dst.clientState.TrustingPeriod - time.Since(consensusHeightTime) + mp.metrics.SetClientExpiration(src.info.PathName, dst.info.ChainID, dst.clientState.ClientID, fmt.Sprint(dst.clientState.TrustingPeriod.String()), timeToExpiration) + } + if shouldUpdateClientNow { mp.log.Info("Client update threshold condition met", + zap.String("path_name", src.info.PathName), zap.String("chain_id", dst.info.ChainID), zap.String("client_id", dst.info.ClientID), zap.Int64("trusting_period", dst.clientState.TrustingPeriod.Milliseconds()), @@ -249,6 +255,7 @@ func (mp *messageProcessor) assembleMsgUpdateClient(ctx context.Context, src, ds clientConsensusHeight.RevisionHeight+1, src.info.ChainID, err) } mp.log.Debug("Had to query for client trusted IBC header", + zap.String("path_name", src.info.PathName), zap.String("chain_id", src.info.ChainID), zap.String("counterparty_chain_id", dst.info.ChainID), zap.String("counterparty_client_id", clientID), diff --git a/relayer/processor/metrics.go b/relayer/processor/metrics.go index a549eb40a..96de766b6 100644 --- a/relayer/processor/metrics.go +++ b/relayer/processor/metrics.go @@ -1,6 +1,8 @@ package processor import ( + "time" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) @@ -12,6 +14,7 @@ type PrometheusMetrics struct { LatestHeightGauge *prometheus.GaugeVec WalletBalance *prometheus.GaugeVec FeesSpent *prometheus.GaugeVec + ClientExpiration *prometheus.GaugeVec } func (m *PrometheusMetrics) AddPacketsObserved(path, chain, channel, port, eventType string, count int) { @@ -34,10 +37,15 @@ func (m *PrometheusMetrics) SetFeesSpent(chain, key, address, denom string, amou m.FeesSpent.WithLabelValues(chain, key, address, denom).Set(amount) } +func (m *PrometheusMetrics) SetClientExpiration(pathName, chain, clientID, trustingPeriod string, timeToExpiration time.Duration) { + m.ClientExpiration.WithLabelValues(pathName, chain, clientID, trustingPeriod).Set(timeToExpiration.Seconds()) +} + func NewPrometheusMetrics() *PrometheusMetrics { packetLabels := []string{"path", "chain", "channel", "port", "type"} heightLabels := []string{"chain"} walletLabels := []string{"chain", "key", "address", "denom"} + clientExpirationLables := []string{"path_name", "chain", "client_id", "trusting_period"} registry := prometheus.NewRegistry() registerer := promauto.With(registry) return &PrometheusMetrics{ @@ -62,5 +70,9 @@ func NewPrometheusMetrics() *PrometheusMetrics { Name: "cosmos_relayer_fees_spent", Help: "The amount of fees spent from the relayer's wallet", }, walletLabels), + ClientExpiration: registerer.NewGaugeVec(prometheus.GaugeOpts{ + Name: "cosmos_relayer_client_expiration_seconds", + Help: "Seconds until the client expires", + }, clientExpirationLables), } }