Skip to content

Commit

Permalink
Add last_observed_height metric
Browse files Browse the repository at this point in the history
  • Loading branch information
sin3point14 authored and mkaczanowski committed Dec 19, 2024
1 parent 90fc26b commit bd8502c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func (d *Daemon) waitForUpgrade(ctx context.Context, cfg *config.Config) (int64,
logger.Err(err).Error("Error received from HeightWatcher")
continue
}
d.metrics.LastObservedHeight.Set(float64(newHeight.Height))
currBlockHeight := newHeight.Height
lastBlockHeight := d.currHeight

Expand Down
21 changes: 15 additions & 6 deletions internal/pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const (
)

type Metrics struct {
Up prometheus.Gauge
BlocksToUpgrade *prometheus.GaugeVec
UpwErrs prometheus.Counter
UiwErrs prometheus.Counter
HwErrs prometheus.Counter
NotifErrs prometheus.Counter
Up prometheus.Gauge
BlocksToUpgrade *prometheus.GaugeVec
LastObservedHeight prometheus.Gauge
UpwErrs prometheus.Counter
UiwErrs prometheus.Counter
HwErrs prometheus.Counter
NotifErrs prometheus.Counter
}

func NewMetrics(composeFile, hostname, version string) *Metrics {
Expand All @@ -43,6 +44,14 @@ func NewMetrics(composeFile, hostname, version string) *Metrics {
},
[]string{"upgrade_height", "upgrade_name", "upgrade_status", "upgrade_step", "chain_id", "validator_address"},
),
LastObservedHeight: promauto.NewGauge(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "last_observed_height",
Help: "Last block height observed by the height watcher",
ConstLabels: labels,
},
),
UpwErrs: promauto.NewCounter(
prometheus.CounterOpts{
Namespace: namespace,
Expand Down

0 comments on commit bd8502c

Please sign in to comment.