Skip to content

Commit

Permalink
feat: add metrics for indexer slot and tip slot (#210)
Browse files Browse the repository at this point in the history
Fixes #204
  • Loading branch information
agaffney authored Sep 15, 2024
1 parent f2dd50f commit 61c7492
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/blinklabs-io/cdnsd/internal/config"
"github.com/blinklabs-io/cdnsd/internal/state"
ouroboros "github.com/blinklabs-io/gouroboros"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/blinklabs-io/adder/event"
filter_event "github.com/blinklabs-io/adder/filter/event"
Expand All @@ -34,6 +36,17 @@ const (
syncStatusLogInterval = 30 * time.Second
)

var (
metricSlot = promauto.NewGauge(prometheus.GaugeOpts{
Name: "indexer_slot",
Help: "Indexer current slot number",
})
metricTipSlot = promauto.NewGauge(prometheus.GaugeOpts{
Name: "indexer_tip_slot",
Help: "Slot number for upstream chain tip",
})
)

type Domain struct {
Name string
Nameservers map[string]string
Expand Down Expand Up @@ -108,6 +121,8 @@ func (i *Indexer) Start() error {
input_chainsync.WithStatusUpdateFunc(
func(status input_chainsync.ChainSyncStatus) {
i.syncStatus = status
metricSlot.Set(float64(status.SlotNumber))
metricTipSlot.Set(float64(status.TipSlotNumber))
if err := state.GetState().UpdateCursor(status.SlotNumber, status.BlockHash); err != nil {
slog.Error(
fmt.Sprintf("failed to update cursor: %s", err),
Expand Down

0 comments on commit 61c7492

Please sign in to comment.