-
Notifications
You must be signed in to change notification settings - Fork 338
/
metrics.go
115 lines (100 loc) · 3.13 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package listener
import (
m "github.com/ethersphere/bee/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
// aggregate events handled
EventsProcessed prometheus.Counter
EventErrors prometheus.Counter
PagesProcessed prometheus.Counter
// individual event counters
CreatedCounter prometheus.Counter
TopupCounter prometheus.Counter
DepthCounter prometheus.Counter
PriceCounter prometheus.Counter
// total calls to chain backend
BackendCalls prometheus.Counter
BackendErrors prometheus.Counter
// processing durations
PageProcessDuration prometheus.Counter
EventProcessDuration prometheus.Counter
}
func newMetrics() metrics {
subsystem := "postage_listener"
return metrics{
// aggregate events handled
EventsProcessed: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "events_processed",
Help: "total events processed",
}),
EventErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "event_errors",
Help: "total event errors while processing",
}),
PagesProcessed: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "pages_processed",
Help: "total pages processed",
}),
// individual event counters
CreatedCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "created_events",
Help: "total batch created events processed",
}),
TopupCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "topup_events",
Help: "total batch topup events handled",
}),
DepthCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "depth_events",
Help: "total batch depth change events handled",
}),
PriceCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "price_events",
Help: "total price change events handled",
}),
// total call
BackendCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "backend_calls",
Help: "total chain backend calls",
}),
BackendErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "backend_errors",
Help: "total chain backend errors",
}),
// processing durations
PageProcessDuration: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "page_duration",
Help: "how long it took to process a page",
}),
EventProcessDuration: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "event_duration",
Help: "how long it took to process a single event",
}),
}
}
func (s *listener) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}