1
1
package processor
2
2
3
3
import (
4
+ "time"
5
+
4
6
"github.com/prometheus/client_golang/prometheus"
5
7
"github.com/prometheus/client_golang/prometheus/promauto"
6
8
)
@@ -12,6 +14,7 @@ type PrometheusMetrics struct {
12
14
LatestHeightGauge * prometheus.GaugeVec
13
15
WalletBalance * prometheus.GaugeVec
14
16
FeesSpent * prometheus.GaugeVec
17
+ ClientExpiration * prometheus.GaugeVec
15
18
}
16
19
17
20
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
34
37
m .FeesSpent .WithLabelValues (chain , key , address , denom ).Set (amount )
35
38
}
36
39
40
+ func (m * PrometheusMetrics ) SetClientExpiration (pathName , chain , clientID , trustingPeriod string , timeToExpiration time.Duration ) {
41
+ m .ClientExpiration .WithLabelValues (pathName , chain , clientID , trustingPeriod ).Set (timeToExpiration .Seconds ())
42
+ }
43
+
37
44
func NewPrometheusMetrics () * PrometheusMetrics {
38
45
packetLabels := []string {"path" , "chain" , "channel" , "port" , "type" }
39
46
heightLabels := []string {"chain" }
40
47
walletLabels := []string {"chain" , "key" , "address" , "denom" }
48
+ clientExpirationLables := []string {"path_name" , "chain" , "client_id" , "trusting_period" }
41
49
registry := prometheus .NewRegistry ()
42
50
registerer := promauto .With (registry )
43
51
return & PrometheusMetrics {
@@ -62,5 +70,9 @@ func NewPrometheusMetrics() *PrometheusMetrics {
62
70
Name : "cosmos_relayer_fees_spent" ,
63
71
Help : "The amount of fees spent from the relayer's wallet" ,
64
72
}, walletLabels ),
73
+ ClientExpiration : registerer .NewGaugeVec (prometheus.GaugeOpts {
74
+ Name : "cosmos_relayer_client_expiration_seconds" ,
75
+ Help : "Seconds until the client expires" ,
76
+ }, clientExpirationLables ),
65
77
}
66
78
}
0 commit comments