-
Notifications
You must be signed in to change notification settings - Fork 3
/
metrics.go
59 lines (54 loc) · 1.86 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
package handshake
import (
m "github.com/gauss-project/aurorafs/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
// metrics groups handshake related prometheus counters.
type metrics struct {
SynRx prometheus.Counter
SynRxFailed prometheus.Counter
SynAckTx prometheus.Counter
SynAckTxFailed prometheus.Counter
AckRx prometheus.Counter
AckRxFailed prometheus.Counter
}
// newMetrics is a convenient constructor for creating new metrics.
func newMetrics() metrics {
const subsystem = "handshake"
return metrics{
SynRx: prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: subsystem,
Name: "syn_rx",
Help: "The number of syn messages that were successfully read.",
}),
SynRxFailed: prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: subsystem,
Name: "syn_rx_failed",
Help: "The number of syn messages that were unsuccessfully read.",
}),
SynAckTx: prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: subsystem,
Name: "syn_ack_tx",
Help: "The number of syn-ack messages that were successfully written.",
}),
SynAckTxFailed: prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: subsystem,
Name: "syn_ack_tx_failed",
Help: "The number of syn-ack messages that were unsuccessfully written.",
}),
AckRx: prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: subsystem,
Name: "ack_rx",
Help: "The number of ack messages that were successfully read.",
}),
AckRxFailed: prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: subsystem,
Name: "ack_rx_failed",
Help: "The number of ack messages that were unsuccessfully read.",
}),
}
}
// Metrics returns set of prometheus collectors.
func (s *Service) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}