-
Notifications
You must be signed in to change notification settings - Fork 34
/
metrics.go
107 lines (97 loc) · 2.88 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
package gossip
import "github.com/prometheus/client_golang/prometheus"
type Metrics struct {
// ConnectionsInbound is the total number of incoming stream
// connections.
ConnectionsInbound prometheus.Counter
// StreamBytesInbound is the total number of read bytes via a stream
// connection.
StreamBytesInbound prometheus.Counter
// PacketBytesInbound is the total number of read bytes via a packet
// connection.
PacketBytesInbound prometheus.Counter
// ConnectionsOutbound is the total number of outgoing stream
// connections.
ConnectionsOutbound prometheus.Counter
// StreamBytesOutbound is the total number of written bytes via a stream
// connection.
StreamBytesOutbound prometheus.Counter
// PacketBytesOutbound is the total number of written bytes via a packet
// connection.
PacketBytesOutbound prometheus.Counter
// Entries is the number of entries labelled by node_id, deleted and
// internal.
Entries *prometheus.GaugeVec
}
func newMetrics() *Metrics {
return &Metrics{
ConnectionsInbound: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "connections_inbound_total",
Help: "Total number of incoming stream connections",
},
),
StreamBytesInbound: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "stream_bytes_inbound_total",
Help: "Total number of read bytes via a stream connection",
},
),
PacketBytesInbound: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "packet_bytes_inbound_total",
Help: "Total number of read bytes via a packet connection",
},
),
ConnectionsOutbound: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "connections_outbound_total",
Help: "Total number of outbound stream connections",
},
),
StreamBytesOutbound: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "stream_bytes_outbound_total",
Help: "Total number of written bytes via a stream connection",
},
),
PacketBytesOutbound: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "packet_bytes_outbound_total",
Help: "Total number of written bytes via a packet connection",
},
),
Entries: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "piko",
Subsystem: "gossip",
Name: "entries",
Help: "Number of entries",
},
[]string{"node_id", "deleted", "internal"},
),
}
}
func (m *Metrics) Register(reg *prometheus.Registry) {
reg.MustRegister(
m.ConnectionsInbound,
m.StreamBytesInbound,
m.PacketBytesInbound,
m.ConnectionsOutbound,
m.StreamBytesOutbound,
m.PacketBytesOutbound,
m.Entries,
)
}