-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
86 lines (80 loc) · 2.59 KB
/
metrics.go
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package pusher
import (
"github.com/prometheus/client_golang/prometheus"
m "github.com/redesblock/mop/core/metrics"
)
type metrics struct {
TotalToPush prometheus.Counter
TotalSynced prometheus.Counter
TotalErrors prometheus.Counter
MarkAndSweepTime prometheus.Histogram
SyncTime prometheus.Histogram
ErrorTime prometheus.Histogram
ReceiptDepth *prometheus.CounterVec
ShallowReceiptDepth *prometheus.CounterVec
}
func newMetrics() metrics {
subsystem := "pusher"
return metrics{
TotalToPush: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_to_push",
Help: "Total chunks to push (chunks may be repeated).",
}),
TotalSynced: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_synced",
Help: "Total chunks synced successfully with valid receipts.",
}),
TotalErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_errors",
Help: "Total errors encountered.",
}),
MarkAndSweepTime: prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mark_and_sweep_time",
Help: "Histogram of time spent in mark and sweep.",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10, 60},
}),
SyncTime: prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "sync_time",
Help: "Histogram of time spent to chainsync a chunk.",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10, 60},
}),
ErrorTime: prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "error_time",
Help: "Histogram of time spent before giving up on syncing a chunk.",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10, 60},
}),
ReceiptDepth: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "receipt_depth",
Help: "Counter of receipts received at different depths.",
},
[]string{"depth"},
),
ShallowReceiptDepth: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "shallow_receipt_depth",
Help: "Counter of shallow receipts received at different depths.",
},
[]string{"depth"},
),
}
}
func (s *Service) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}