Skip to content

Commit 61c7492

Browse files
authored
feat: add metrics for indexer slot and tip slot (#210)
Fixes #204
1 parent f2dd50f commit 61c7492

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/indexer/indexer.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"github.com/blinklabs-io/cdnsd/internal/config"
1818
"github.com/blinklabs-io/cdnsd/internal/state"
1919
ouroboros "github.com/blinklabs-io/gouroboros"
20+
"github.com/prometheus/client_golang/prometheus"
21+
"github.com/prometheus/client_golang/prometheus/promauto"
2022

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

39+
var (
40+
metricSlot = promauto.NewGauge(prometheus.GaugeOpts{
41+
Name: "indexer_slot",
42+
Help: "Indexer current slot number",
43+
})
44+
metricTipSlot = promauto.NewGauge(prometheus.GaugeOpts{
45+
Name: "indexer_tip_slot",
46+
Help: "Slot number for upstream chain tip",
47+
})
48+
)
49+
3750
type Domain struct {
3851
Name string
3952
Nameservers map[string]string
@@ -108,6 +121,8 @@ func (i *Indexer) Start() error {
108121
input_chainsync.WithStatusUpdateFunc(
109122
func(status input_chainsync.ChainSyncStatus) {
110123
i.syncStatus = status
124+
metricSlot.Set(float64(status.SlotNumber))
125+
metricTipSlot.Set(float64(status.TipSlotNumber))
111126
if err := state.GetState().UpdateCursor(status.SlotNumber, status.BlockHash); err != nil {
112127
slog.Error(
113128
fmt.Sprintf("failed to update cursor: %s", err),

0 commit comments

Comments
 (0)