Prometheus counter for Signal/RTC messages (#139)
This commit is contained in:
@@ -344,22 +344,28 @@ func (r *RedisRouter) redisWorker(startedChan chan struct{}) {
|
|||||||
sm := livekit.SignalNodeMessage{}
|
sm := livekit.SignalNodeMessage{}
|
||||||
if err := proto.Unmarshal([]byte(msg.Payload), &sm); err != nil {
|
if err := proto.Unmarshal([]byte(msg.Payload), &sm); err != nil {
|
||||||
logger.Errorw("could not unmarshal signal message on sigchan", err)
|
logger.Errorw("could not unmarshal signal message on sigchan", err)
|
||||||
|
stats.PromMessageCounter.WithLabelValues("signal", "failure").Add(1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := r.handleSignalMessage(&sm); err != nil {
|
if err := r.handleSignalMessage(&sm); err != nil {
|
||||||
logger.Errorw("error processing signal message", err)
|
logger.Errorw("error processing signal message", err)
|
||||||
|
stats.PromMessageCounter.WithLabelValues("signal", "failure").Add(1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
stats.PromMessageCounter.WithLabelValues("signal", "success").Add(1)
|
||||||
} else if msg.Channel == rtcChannel {
|
} else if msg.Channel == rtcChannel {
|
||||||
rm := livekit.RTCNodeMessage{}
|
rm := livekit.RTCNodeMessage{}
|
||||||
if err := proto.Unmarshal([]byte(msg.Payload), &rm); err != nil {
|
if err := proto.Unmarshal([]byte(msg.Payload), &rm); err != nil {
|
||||||
logger.Errorw("could not unmarshal RTC message on rtcchan", err)
|
logger.Errorw("could not unmarshal RTC message on rtcchan", err)
|
||||||
|
stats.PromMessageCounter.WithLabelValues("rtc", "failure").Add(1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := r.handleRTCMessage(&rm); err != nil {
|
if err := r.handleRTCMessage(&rm); err != nil {
|
||||||
logger.Errorw("error processing RTC message", err)
|
logger.Errorw("error processing RTC message", err)
|
||||||
|
stats.PromMessageCounter.WithLabelValues("rtc", "failure").Add(1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
stats.PromMessageCounter.WithLabelValues("rtc", "success").Add(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
// function exits when websocket terminates, it'll close the event reading off of response sink as well
|
// function exits when websocket terminates, it'll close the event reading off of response sink as well
|
||||||
defer func() {
|
defer func() {
|
||||||
logger.Infow("WS connection closed", "participant", pi.Identity, "connID", connId)
|
logger.Infow("server closing WS connection", "participant", pi.Identity, "connID", connId)
|
||||||
reqSink.Close()
|
reqSink.Close()
|
||||||
close(done)
|
close(done)
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// Code generated by Wire. DO NOT EDIT.
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
//go:generate go run github.com/google/wire/cmd/wire
|
//go:generate go run github.com/google/wire/cmd/wire
|
||||||
//+build !wireinject
|
//go:build !wireinject
|
||||||
|
// +build !wireinject
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
|
|||||||
@@ -15,31 +15,33 @@ var (
|
|||||||
atomicPacketsOut uint64
|
atomicPacketsOut uint64
|
||||||
atomicNackTotal uint64
|
atomicNackTotal uint64
|
||||||
|
|
||||||
|
promPacketLabels = []string{"direction"}
|
||||||
|
|
||||||
promPacketTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promPacketTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "packet",
|
Subsystem: "packet",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
}, promLabels)
|
}, promPacketLabels)
|
||||||
promPacketBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promPacketBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "packet",
|
Subsystem: "packet",
|
||||||
Name: "bytes",
|
Name: "bytes",
|
||||||
}, promLabels)
|
}, promPacketLabels)
|
||||||
promNackTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promNackTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "nack",
|
Subsystem: "nack",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
}, promLabels)
|
}, promPacketLabels)
|
||||||
promPliTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promPliTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "pli",
|
Subsystem: "pli",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
}, promLabels)
|
}, promPacketLabels)
|
||||||
promFirTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promFirTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "fir",
|
Subsystem: "fir",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
}, promLabels)
|
}, promPacketLabels)
|
||||||
)
|
)
|
||||||
|
|
||||||
func initPacketStats() {
|
func initPacketStats() {
|
||||||
|
|||||||
@@ -9,15 +9,25 @@ import (
|
|||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
"github.com/pion/transport/packetio"
|
"github.com/pion/transport/packetio"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const livekitNamespace = "livekit"
|
const livekitNamespace = "livekit"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
promLabels = []string{"direction"}
|
PromMessageCounter = prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Namespace: livekitNamespace,
|
||||||
|
Subsystem: "node",
|
||||||
|
Name: "messages",
|
||||||
|
},
|
||||||
|
[]string{"type", "status"},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
prometheus.MustRegister(PromMessageCounter)
|
||||||
|
|
||||||
initPacketStats()
|
initPacketStats()
|
||||||
initRoomStatsReporter()
|
initRoomStatsReporter()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user