Skip to content

Commit 5e23bc8

Browse files
committed
Implement metrics for concentratord backend.
1 parent 11fe9f0 commit 5e23bc8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

internal/backend/concentratord/concentratord.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ func (b *Backend) SendDownlinkFrame(pl gw.DownlinkFrame) error {
146146

147147
b.downlinkTXAckChan <- ack
148148

149+
commandCounter("down").Inc()
150+
149151
return nil
150152
}
151153

@@ -227,6 +229,8 @@ func (b *Backend) eventLoop() {
227229
"event": string(msg.Frames[0]),
228230
}).Error("backend/concentratord: handle event error")
229231
}
232+
233+
eventCounter(string(msg.Frames[0])).Inc()
230234
}
231235
}
232236

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package concentratord
2+
3+
import (
4+
"github.com/prometheus/client_golang/prometheus"
5+
"github.com/prometheus/client_golang/prometheus/promauto"
6+
)
7+
8+
var (
9+
ec = promauto.NewCounterVec(prometheus.CounterOpts{
10+
Name: "backend_concentratord_event_count",
11+
Help: "The number of received events (per type)",
12+
}, []string{"event"})
13+
14+
cc = promauto.NewCounterVec(prometheus.CounterOpts{
15+
Name: "backend_concentratord_command_count",
16+
Help: "The number of received commands (per type)",
17+
}, []string{"command"})
18+
)
19+
20+
func eventCounter(typ string) prometheus.Counter {
21+
return ec.With(prometheus.Labels{"event": typ})
22+
}
23+
24+
func commandCounter(typ string) prometheus.Counter {
25+
return cc.With(prometheus.Labels{"command": typ})
26+
}

0 commit comments

Comments
 (0)