/
metrics.go
82 lines (73 loc) · 2.92 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
package socks
import (
"github.com/cybozu-go/usocksd/metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
proxyElapsedHist = promauto.With(metrics.Registry).NewHistogramVec(prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "elapsed_seconds",
Help: "provides the time elapsed, in seconds, between proxy start and end",
}, []string{"result"})
proxyRequestsInflightGauge = promauto.With(metrics.Registry).NewGauge(prometheus.GaugeOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "inflight_requests",
Help: "provides the number of requests currently in-flight",
})
proxyBytesTxHist = promauto.With(metrics.Registry).NewHistogram(prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "tx_bytes",
Help: "bytes copied from the source connection to the destination connection",
})
proxyBytesRxHist = promauto.With(metrics.Registry).NewHistogram(prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "rx_bytes",
Help: "bytes copied from the destination connection to the source connection",
})
proxyErrTxCount = promauto.With(metrics.Registry).NewCounter(prometheus.CounterOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "tx_errors_total",
Help: "number of errors encountered copying from source to destination",
})
proxyErrRxCount = promauto.With(metrics.Registry).NewCounter(prometheus.CounterOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "rx_errors_total",
Help: "number of errors encountered copying from destination to source",
})
proxyElapsedTxHist = promauto.With(metrics.Registry).NewHistogram(prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "tx_seconds",
Help: "time spent copying from source to destination",
})
proxyElapsedRxHist = promauto.With(metrics.Registry).NewHistogram(prometheus.HistogramOpts{
Namespace: metrics.Namespace,
Subsystem: "proxy",
Name: "rx_seconds",
Help: "time spent copying from destination to source",
})
authNegotiateCounter = promauto.With(metrics.Registry).NewCounterVec(prometheus.CounterOpts{
Namespace: metrics.Namespace,
Subsystem: "socks5",
Name: "auth_negotiated_total",
Help: "number of auth negotiation",
}, []string{"type", "result"})
addressReadCounter = promauto.With(metrics.Registry).NewCounterVec(prometheus.CounterOpts{
Namespace: metrics.Namespace,
Subsystem: "socks5",
Name: "address_read_total",
Help: "address read total count",
}, []string{"type", "result"})
connectionCounter = promauto.With(metrics.Registry).NewCounterVec(prometheus.CounterOpts{
Namespace: metrics.Namespace,
Name: "connections_total",
Help: "number of TCP connections",
}, []string{"version", "status"})
)