Skip to content

Commit

Permalink
fix(exe): Reset web3_client_version when version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Aug 14, 2024
1 parent 8a207d6 commit 01a4acb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/exporter/execution/jobs/web3.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (

// Web3 exposes metrics defined by the Web3 module.
type Web3 struct {
client *ethclient.Client
api api.ExecutionClient
ethRPCClient *ethrpc.EthRPC
log logrus.FieldLogger
ClientVersion prometheus.GaugeVec
client *ethclient.Client
api api.ExecutionClient
ethRPCClient *ethrpc.EthRPC
log logrus.FieldLogger
ClientVersion prometheus.GaugeVec
previousVersion string
}

const (
Expand Down Expand Up @@ -76,6 +77,12 @@ func (w *Web3) tick(ctx context.Context) {
if err != nil {
w.log.WithError(err).Error("Failed to get node info")
} else {
w.ClientVersion.WithLabelValues(clientVersion).Set(1)
if w.previousVersion != clientVersion {
w.ClientVersion.Reset()

w.ClientVersion.WithLabelValues(clientVersion).Set(1)
}

w.previousVersion = clientVersion
}
}

0 comments on commit 01a4acb

Please sign in to comment.