Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last_observed_height metric #32

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading