-
Notifications
You must be signed in to change notification settings - Fork 9
/
metrics.go
73 lines (67 loc) · 2.33 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
package routetab
import (
m "github.com/gauss-project/aurorafs/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
// all metrics fields must be exported
// to be able to return them by Metrics()
// using reflection
FindRouteReqSentCount prometheus.Counter
FindRouteRespSentCount prometheus.Counter
FindRouteReqReceivedCount prometheus.Counter
FindRouteRespReceivedCount prometheus.Counter
TotalErrors prometheus.Counter
TotalOutboundConnections prometheus.Counter
TotalOutboundConnectionFailedAttempts prometheus.Counter
}
func newMetrics() metrics {
subsystem := "routetab"
return metrics{
FindRouteReqSentCount: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "route_req_sent_count",
Help: "Number of route requests sent.",
}),
FindRouteRespSentCount: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "route_resp_sent_count",
Help: "Number of route responses sent.",
}),
FindRouteReqReceivedCount: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "route_req_received_count",
Help: "Number of route requests received.",
}),
FindRouteRespReceivedCount: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "route_resp_received_count",
Help: "Number of route responses received.",
}),
TotalErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "route_errors_total_count",
Help: "Number of route errors total.",
}),
TotalOutboundConnections: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_outbound_connection",
Help: "Total outbound connection made.",
}),
TotalOutboundConnectionFailedAttempts: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_outbound_connection_failed_attempts",
Help: "Total outbound connection failed attempts made.",
}),
}
}
func (s *Service) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}