Skip to content

Commit

Permalink
Handle cutover
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed May 16, 2022
1 parent 6ed0154 commit cedad7d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pkg/exporter/consensus/jobs/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import (

type Forks struct {
MetricExporter
Epochs prometheus.GaugeVec
Activated prometheus.GaugeVec
Current prometheus.GaugeVec
client eth2client.Service
log logrus.FieldLogger
Epochs prometheus.GaugeVec
Activated prometheus.GaugeVec
Current prometheus.GaugeVec
client eth2client.Service
log logrus.FieldLogger
previousCurrentFork string
}

const (
Expand All @@ -30,8 +31,9 @@ func NewForksJob(client eth2client.Service, log logrus.FieldLogger, namespace st
constLabels["module"] = NameFork
namespace = namespace + "_fork"
return Forks{
client: client,
log: log,
client: client,
log: log,
previousCurrentFork: "",
Epochs: *prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down Expand Up @@ -148,7 +150,11 @@ func (f *Forks) GetCurrent(ctx context.Context) error {
}
}

f.Current.WithLabelValues(current).Set(1)
if current != f.previousCurrentFork {
f.Current.WithLabelValues(current).Set(1)
f.Current.WithLabelValues(f.previousCurrentFork).Set(0)
f.previousCurrentFork = current
}

return nil
}
Expand Down

0 comments on commit cedad7d

Please sign in to comment.