Skip to content

Commit

Permalink
fix: export block as label in upgrade_plan metric (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo authored Feb 19, 2025
1 parent f469369 commit 39e36a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func New(namespace string) *Metrics {
Name: "upgrade_plan",
Help: "Block height of the upcoming upgrade (hard fork)",
},
[]string{"chain_id", "version"},
[]string{"chain_id", "version", "block"},
),
ProposalEndTime: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Expand Down
6 changes: 3 additions & 3 deletions pkg/watcher/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"fmt"
"time"

"cosmossdk.io/x/upgrade/types"
upgrade "cosmossdk.io/x/upgrade/types"
ctypes "github.com/cometbft/cometbft/rpc/core/types"
comettypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/client"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govbeta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"cosmossdk.io/x/upgrade/types"
upgrade "cosmossdk.io/x/upgrade/types"
"github.com/gogo/protobuf/codec"
"github.com/kilnfi/cosmos-validator-watcher/pkg/metrics"
"github.com/kilnfi/cosmos-validator-watcher/pkg/rpc"
Expand Down Expand Up @@ -242,6 +242,6 @@ func (w *UpgradeWatcher) handleUpgradePlan(chainID string, plan *upgrade.Plan) {
if plan == nil {
w.metrics.UpgradePlan.Reset()
} else {
w.metrics.UpgradePlan.WithLabelValues(chainID, plan.Name).Set(float64(plan.Height))
w.metrics.UpgradePlan.WithLabelValues(chainID, plan.Name, fmt.Sprintf("%d", plan.Height)).Set(float64(plan.Height))
}
}
2 changes: 1 addition & 1 deletion pkg/watcher/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestUpgradeWatcher(t *testing.T) {
Height: blockHeight,
})

assert.Equal(t, float64(123456789), testutil.ToFloat64(watcher.metrics.UpgradePlan.WithLabelValues(chainID, version)))
assert.Equal(t, float64(123456789), testutil.ToFloat64(watcher.metrics.UpgradePlan.WithLabelValues(chainID, version, "123456789")))
})

t.Run("Handle No Upgrade Plan", func(t *testing.T) {
Expand Down

0 comments on commit 39e36a8

Please sign in to comment.