@@ -2,55 +2,52 @@ package basicstation
22
33import (
44 "github.com/prometheus/client_golang/prometheus"
5-
6- "github.com/brocaar/lora-gateway-bridge/internal/metrics"
5+ "github.com/prometheus/client_golang/prometheus/promauto"
76)
87
98var (
10- bsEventCounter func (string )
11- bsWebsocketSendCounter func (string )
12- bsWebsocketReceiveCounter func (string )
13- bsWebsocketPingPongCounter func (string )
9+ ppc = promauto .NewCounterVec (prometheus.CounterOpts {
10+ Name : "backend_basicstation_websocket_ping_pong_count" ,
11+ Help : "The number of WebSocket Ping/Pong requests sent and received (per event type)." ,
12+ }, []string {"type" })
13+
14+ wsr = promauto .NewCounterVec (prometheus.CounterOpts {
15+ Name : "backend_basicstation_websocket_received_count" ,
16+ Help : "The number of WebSocket messages received by the backend (per msgtype)." ,
17+ }, []string {"msgtype" })
18+
19+ wss = promauto .NewCounterVec (prometheus.CounterOpts {
20+ Name : "backend_basicstation_websocket_sent_count" ,
21+ Help : "The number of WebSocket messages sent by the backend (per msgtype)." ,
22+ }, []string {"msgtype" })
23+
24+ gwc = prometheus .NewCounter (prometheus.CounterOpts {
25+ Name : "backend_basicstation_gateway_connect_count" ,
26+ Help : "The number of gateway connections received by the backend." ,
27+ })
28+
29+ gwd = prometheus .NewCounter (prometheus.CounterOpts {
30+ Name : "backend_basicstation_gateway_disconnect_count" ,
31+ Help : "The number of gateways that disconnected from the backend." ,
32+ })
1433)
1534
16- func init () {
17- ec := metrics .MustRegisterNewCounter (
18- "backend_basicstation_event" ,
19- "Per gateway event type counter." ,
20- []string {"event" },
21- )
22-
23- wsc := metrics .MustRegisterNewCounter (
24- "backend_basicstation_websocket_send" ,
25- "Per message-type websocket write counter." ,
26- []string {"msgtype" },
27- )
28-
29- wrc := metrics .MustRegisterNewCounter (
30- "backend_basicstation_websocket_receive" ,
31- "Per message-type websocket receive counter." ,
32- []string {"msgtype" },
33- )
34-
35- ppc := metrics .MustRegisterNewCounter (
36- "backend_basicstation_websocket_ping_pong" ,
37- "Websocket Ping/Pong counter." ,
38- []string {"type" },
39- )
40-
41- bsEventCounter = func (event string ) {
42- ec (prometheus.Labels {"event" : event })
43- }
44-
45- bsWebsocketReceiveCounter = func (msgtype string ) {
46- wsc (prometheus.Labels {"msgtype" : msgtype })
47- }
48-
49- bsWebsocketSendCounter = func (msgtype string ) {
50- wrc (prometheus.Labels {"msgtype" : msgtype })
51- }
52-
53- bsWebsocketPingPongCounter = func (typ string ) {
54- ppc (prometheus.Labels {"type" : typ })
55- }
35+ func websocketPingPongCounter (typ string ) prometheus.Counter {
36+ return ppc .With (prometheus.Labels {"type" : typ })
37+ }
38+
39+ func websocketReceiveCounter (msgtype string ) prometheus.Counter {
40+ return wsr .With (prometheus.Labels {"msgtype" : msgtype })
41+ }
42+
43+ func websocketSendCounter (msgtype string ) prometheus.Counter {
44+ return wss .With (prometheus.Labels {"msgtype" : msgtype })
45+ }
46+
47+ func connectCounter () prometheus.Counter {
48+ return gwc
49+ }
50+
51+ func disconnectCounter () prometheus.Counter {
52+ return gwd
5653}
0 commit comments