forked from centrifugal/centrifuge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
109 lines (94 loc) · 3.34 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
package centrifuge
import (
"github.com/prometheus/client_golang/prometheus"
)
var metricsNamespace = "centrifuge"
var (
messagesSentCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "messages_sent_count",
Help: "Number of messages sent.",
}, []string{"type"})
messagesReceivedCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "messages_received_count",
Help: "Number of messages received.",
}, []string{"type"})
actionCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "action_count",
Help: "Number of node actions called.",
}, []string{"action"})
numClientsGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "num_clients",
Help: "Number of clients connected.",
})
numUsersGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "num_users",
Help: "Number of unique users connected.",
})
buildInfoGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "build",
Help: "Node build info.",
}, []string{"version"})
numChannelsGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: "node",
Name: "num_channels",
Help: "Number of channels with one or more subscribers.",
})
replyErrorCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "client",
Name: "num_reply_errors",
Help: "Number of errors in replies sent to clients.",
}, []string{"method", "code"})
commandDurationSummary = prometheus.NewSummaryVec(prometheus.SummaryOpts{
Namespace: metricsNamespace,
Subsystem: "client",
Name: "command_duration_seconds",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
Help: "Client command duration summary.",
}, []string{"method"})
recoverCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "client",
Name: "recover",
Help: "Count of recover operations.",
}, []string{"recovered"})
transportConnectCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "transport",
Name: "connect_count",
Help: "Number of connections to specific transport.",
}, []string{"transport"})
transportMessagesSent = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: "transport",
Name: "messages_sent",
Help: "Number of messages sent over specific transport.",
}, []string{"transport"})
)
func init() {
prometheus.MustRegister(messagesSentCount)
prometheus.MustRegister(messagesReceivedCount)
prometheus.MustRegister(actionCount)
prometheus.MustRegister(numClientsGauge)
prometheus.MustRegister(numUsersGauge)
prometheus.MustRegister(numChannelsGauge)
prometheus.MustRegister(commandDurationSummary)
prometheus.MustRegister(replyErrorCount)
prometheus.MustRegister(recoverCount)
prometheus.MustRegister(transportConnectCount)
prometheus.MustRegister(transportMessagesSent)
prometheus.MustRegister(buildInfoGauge)
}