Skip to content

Commit

Permalink
Change upgrade_state metric to upgrade_step
Browse files Browse the repository at this point in the history
  • Loading branch information
sin3point14 committed Nov 19, 2024
1 parent 50c99b9 commit 655c98b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/daemon/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (

func (d *Daemon) updateMetrics() {
// the upgrade state may change, we don't want to persist the metric with the old status
d.metrics.State.Reset()
d.metrics.Step.Reset()
d.metrics.BlocksToUpgrade.Reset()

upcomingUpgrades := d.ur.GetUpcomingUpgradesWithCache(d.currHeight)
for _, upgrade := range upcomingUpgrades {
upgradeHeight := strconv.FormatInt(upgrade.Height, 10)
status := d.stateMachine.GetStatus(upgrade.Height)

d.metrics.State.WithLabelValues(upgradeHeight, upgrade.Name, status.String()).Set(float64(d.stateMachine.GetStep(upgrade.Height)))
d.metrics.Step.WithLabelValues(upgradeHeight, upgrade.Name, status.String()).Set(float64(d.stateMachine.GetStep(upgrade.Height)))
d.metrics.BlocksToUpgrade.WithLabelValues(upgradeHeight, upgrade.Name, status.String()).Set(float64(upgrade.Height - d.currHeight))
}
}
8 changes: 4 additions & 4 deletions internal/pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (

type Metrics struct {
Up prometheus.Gauge
State *prometheus.GaugeVec
Step *prometheus.GaugeVec
BlocksToUpgrade *prometheus.GaugeVec
UpwErrs prometheus.Counter
UiwErrs prometheus.Counter
Expand All @@ -35,11 +35,11 @@ func NewMetrics(composeFile string, hostname string, version string) (*Metrics,
ConstLabels: labels,
},
),
State: promauto.NewGaugeVec(
Step: promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "upgrade_state",
Help: "ID of the current stage of the upgrade process",
Name: "upgrade_step",
Help: "ID of the current step of the upgrade process",
ConstLabels: labels,
},
[]string{"upgrade_height", "upgrade_name", "proposal_status"},
Expand Down

0 comments on commit 655c98b

Please sign in to comment.