Skip to content

Commit 0e8594d

Browse files
authored
refactor: init metrics (#5198)
1 parent 29ea2b7 commit 0e8594d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pkg/node/metrics.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ func newMetrics() nodeMetrics {
2626
Subsystem: subsystem,
2727
Name: "warmup_duration_seconds",
2828
Help: "Duration in seconds for node warmup to complete",
29+
// middle range should be more infrequent (because of addressbook)
30+
Buckets: []float64{10, 20, 25, 30, 35, 40, 45, 50, 60, 70, 90, 120, 180, 240, 300, 350, 380, 400, 420, 440, 460, 480, 550, 600},
2931
},
3032
),
3133
FullSyncDuration: prometheus.NewHistogram(
3234
prometheus.HistogramOpts{
3335
Namespace: metrics.Namespace,
3436
Subsystem: subsystem,
35-
Name: "full_sync_duration_seconds",
36-
Help: "Duration in seconds for node warmup to complete",
37+
Name: "full_sync_duration_minutes",
38+
Help: "Duration in minutes for node full sync to complete",
39+
// middle range should be more frequent
40+
Buckets: []float64{80, 90, 100, 110,
41+
120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, // 2-3 hours range
42+
190, 200, 210, 220, 230, 240},
3743
},
3844
),
3945
}

pkg/node/node.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ func NewBee(
611611
"totalMonitoredEvents", totalCount,
612612
"warmupDurationSeconds", warmupDuration)
613613

614-
// Record the warmup duration in the prometheus metric
615614
nodeMetrics.WarmupDuration.Observe(warmupDuration)
616615
pullSyncStartTime = t
617616
}
@@ -1166,10 +1165,11 @@ func NewBee(
11661165
return
11671166
case <-syncCheckTicker.C:
11681167
synced := isFullySynced()
1169-
logger.Debug("sync status check", "synced", synced, "reserveSize", localStore.ReserveSize(), "threshold", reserveTreshold, "syncRate", pullerService.SyncRate())
1168+
logger.Debug("sync status check", "synced", synced, "reserveSize", localStore.ReserveSize(), "syncRate", pullerService.SyncRate())
11701169
if synced {
11711170
fullSyncTime := pullSyncStartTime.Sub(t)
1172-
nodeMetrics.FullSyncDuration.Observe(fullSyncTime.Seconds())
1171+
logger.Info("full sync duration", "duration", fullSyncTime)
1172+
nodeMetrics.FullSyncDuration.Observe(fullSyncTime.Minutes())
11731173
syncCheckTicker.Stop()
11741174
return
11751175
}

0 commit comments

Comments
 (0)