-
Notifications
You must be signed in to change notification settings - Fork 339
/
metrics.go
139 lines (129 loc) · 4.21 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// 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 storageincentives
import (
m "github.com/ethersphere/bee/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
// phase gauge and counter
CurrentPhase prometheus.Gauge
RevealPhase prometheus.Counter
CommitPhase prometheus.Counter
ClaimPhase prometheus.Counter
Winner prometheus.Counter
NeighborhoodSelected prometheus.Counter
SampleDuration prometheus.Gauge
Round prometheus.Gauge
// total calls to chain backend
BackendCalls prometheus.Counter
BackendErrors prometheus.Counter
// metrics for err processing
ErrReveal prometheus.Counter
ErrCommit prometheus.Counter
ErrClaim prometheus.Counter
ErrWinner prometheus.Counter
ErrCheckIsPlaying prometheus.Counter
}
func newMetrics() metrics {
subsystem := "storageincentives"
return metrics{
CurrentPhase: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "current_phase",
Help: "Enum value of the current phase.",
}),
RevealPhase: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "reveal_phases",
Help: "Count of reveal phases entered.",
}),
CommitPhase: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "commit_phases",
Help: "Count of commit phases entered.",
}),
ClaimPhase: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "claim_phases",
Help: "Count of claim phases entered.",
}),
Winner: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "winner",
Help: "Count of won rounds.",
}),
NeighborhoodSelected: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "neighborhood_selected",
Help: "Count of the neighborhood being selected.",
}),
SampleDuration: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "reserve_sample_duration",
Help: "Time taken to produce a reserve sample.",
}),
Round: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "round",
Help: "Current round calculated from the block height.",
}),
// 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",
}),
// phase errors
ErrReveal: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "reveal_phase_errors",
Help: "total reveal phase errors while processing",
}),
ErrCommit: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "commit_phase_errors",
Help: "total commit phase errors while processing",
}),
ErrClaim: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "claim_phase_errors",
Help: "total claim phase errors while processing",
}),
ErrWinner: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "win_phase_errors",
Help: "total win phase while processing",
}),
ErrCheckIsPlaying: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "is_playing_errors",
Help: "total neighborhood selected errors while processing",
}),
}
}
// TODO: register metric
func (s *Agent) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}