-
Notifications
You must be signed in to change notification settings - Fork 15
/
stats.go
144 lines (137 loc) · 4.88 KB
/
stats.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
140
141
142
143
144
/*
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
package tacquito
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
// gauges and counters
serveReceived = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "serve_received",
Help: "total number of packets received within the server",
})
serveAccepted = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "tacquito",
Name: "serve_accepted",
Help: "number of accepted connections within the server that are currently being processed",
})
serveAcceptedError = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "serve_accepted_error",
Help: "number of accepted connection errors within the server",
})
handlers = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "tacquito",
Name: "handle_handlers",
Help: "number of handlers running within the server",
})
crypterRead = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_read",
Help: "number of crypt reads within the server",
})
crypterReadError = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_read_error",
Help: "number of crypt read errors within the server",
})
crypterWrite = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_write",
Help: "number of crypt writes within the server",
})
crypterWriteError = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_write_error",
Help: "number of crypt write errors within the server",
})
crypterBadSecret = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_badSecret",
Help: "number of bad secrets",
})
crypterUnmarshalError = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_unmarshal_error",
Help: "number of errors unmarshalling in crypter",
})
crypterCryptError = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_crypt_error",
Help: "number of errors in crypter crypt()",
})
crypterMarshalError = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "crypter_marshal_error",
Help: "number of errors marshalling in crypter",
})
waitgroupActive = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "tacquito",
Name: "waitgroup_handle_routines_active",
Help: "number of active waitgroup go routines within the server",
})
sessionsActive = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "tacquito",
Name: "sessions_active",
Help: "number of active sessions within the server",
})
sessionsGetHit = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "sessions_get_hit",
Help: "number of session cache hits within the server",
})
sessionsGetMiss = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "sessions_get_miss",
Help: "number of session cache misses within the server",
})
sessionsSet = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "tacquito",
Name: "sessions_set",
Help: "number of session set in the cache",
})
// durations
sessionDurations = prometheus.NewSummary(
prometheus.SummaryOpts{
Namespace: "tacquito",
Name: "sessions_duration_milliseconds",
Help: "the time a session is a live within tacquito, in milliseconds",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
)
connectionDuration = prometheus.NewSummary(
prometheus.SummaryOpts{
Namespace: "tacquito",
Name: "serve_connection_duration_milliseconds",
Help: "total time time of a net.Conn, including overhead, in milliseconds",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
)
)
func init() {
// gauges and counters
prometheus.MustRegister(serveReceived)
prometheus.MustRegister(serveAccepted)
prometheus.MustRegister(serveAcceptedError)
prometheus.MustRegister(handlers)
prometheus.MustRegister(crypterRead)
prometheus.MustRegister(crypterReadError)
prometheus.MustRegister(crypterWrite)
prometheus.MustRegister(crypterWriteError)
prometheus.MustRegister(crypterBadSecret)
prometheus.MustRegister(crypterUnmarshalError)
prometheus.MustRegister(crypterMarshalError)
prometheus.MustRegister(crypterCryptError)
prometheus.MustRegister(waitgroupActive)
prometheus.MustRegister(sessionsActive)
prometheus.MustRegister(sessionsGetHit)
prometheus.MustRegister(sessionsGetMiss)
prometheus.MustRegister(sessionsSet)
// durations
prometheus.MustRegister(sessionDurations)
prometheus.MustRegister(connectionDuration)
}