-
Notifications
You must be signed in to change notification settings - Fork 383
Expand file tree
/
Copy pathmetrics.go
More file actions
52 lines (46 loc) · 1.69 KB
/
metrics.go
File metadata and controls
52 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2022 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package node
import (
"github.com/ethersphere/bee/v2/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type nodeMetrics struct {
// WarmupDuration measures time in seconds for the node warmup to complete
WarmupDuration prometheus.Histogram
// FullSyncDuration measures time in seconds for the full sync to complete
FullSyncDuration prometheus.Histogram
}
func newMetrics() nodeMetrics {
subsystem := "init"
return nodeMetrics{
WarmupDuration: prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: subsystem,
Name: "warmup_duration_seconds",
Help: "Duration in seconds for node warmup to complete",
// middle range should be more infrequent (because of addressbook)
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},
},
),
FullSyncDuration: prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: subsystem,
Name: "full_sync_duration_minutes",
Help: "Duration in minutes for node full sync to complete",
// middle range should be more frequent
Buckets: []float64{80, 90, 100, 110,
120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, // 2-3 hours range
190, 200, 210, 220, 230, 240},
},
),
}
}
// RegisterMetrics registers all metrics from the package
func (m nodeMetrics) RegisterMetrics() {
prometheus.MustRegister(m.WarmupDuration)
prometheus.MustRegister(m.FullSyncDuration)
}