Keep track of retransmissions in NodeStats (#677)
This commit is contained in:
@@ -8,24 +8,28 @@ import (
|
||||
type Direction string
|
||||
|
||||
const (
|
||||
Incoming Direction = "incoming"
|
||||
Outgoing Direction = "outgoing"
|
||||
Incoming Direction = "incoming"
|
||||
Outgoing Direction = "outgoing"
|
||||
transmissionInitial = "initial"
|
||||
transmissionRetransmit = "retransmit"
|
||||
)
|
||||
|
||||
var (
|
||||
bytesIn atomic.Uint64
|
||||
bytesOut atomic.Uint64
|
||||
packetsIn atomic.Uint64
|
||||
packetsOut atomic.Uint64
|
||||
nackTotal atomic.Uint64
|
||||
bytesIn atomic.Uint64
|
||||
bytesOut atomic.Uint64
|
||||
packetsIn atomic.Uint64
|
||||
packetsOut atomic.Uint64
|
||||
nackTotal atomic.Uint64
|
||||
retransmitBytes atomic.Uint64
|
||||
retransmitPackets atomic.Uint64
|
||||
|
||||
promPacketLabels = []string{"direction"}
|
||||
|
||||
promPacketTotal *prometheus.CounterVec
|
||||
promPacketBytes *prometheus.CounterVec
|
||||
promNackTotal *prometheus.CounterVec
|
||||
promPliTotal *prometheus.CounterVec
|
||||
promFirTotal *prometheus.CounterVec
|
||||
promPacketLabels = []string{"direction", "transmission"}
|
||||
promPacketTotal *prometheus.CounterVec
|
||||
promPacketBytes *prometheus.CounterVec
|
||||
promRTCPLabels = []string{"direction"}
|
||||
promNackTotal *prometheus.CounterVec
|
||||
promPliTotal *prometheus.CounterVec
|
||||
promFirTotal *prometheus.CounterVec
|
||||
)
|
||||
|
||||
func initPacketStats(nodeID string) {
|
||||
@@ -46,19 +50,19 @@ func initPacketStats(nodeID string) {
|
||||
Subsystem: "nack",
|
||||
Name: "total",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
||||
}, promPacketLabels)
|
||||
}, promRTCPLabels)
|
||||
promPliTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "pli",
|
||||
Name: "total",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
||||
}, promPacketLabels)
|
||||
}, promRTCPLabels)
|
||||
promFirTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "fir",
|
||||
Name: "total",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
||||
}, promPacketLabels)
|
||||
}, promRTCPLabels)
|
||||
|
||||
prometheus.MustRegister(promPacketTotal)
|
||||
prometheus.MustRegister(promPacketBytes)
|
||||
@@ -67,21 +71,33 @@ func initPacketStats(nodeID string) {
|
||||
prometheus.MustRegister(promFirTotal)
|
||||
}
|
||||
|
||||
func IncrementPackets(direction Direction, count uint64) {
|
||||
promPacketTotal.WithLabelValues(string(direction)).Add(float64(count))
|
||||
func IncrementPackets(direction Direction, count uint64, retransmit bool) {
|
||||
promPacketTotal.WithLabelValues(
|
||||
string(direction),
|
||||
transmissionLabel(retransmit),
|
||||
).Add(float64(count))
|
||||
if direction == Incoming {
|
||||
packetsIn.Add(count)
|
||||
} else {
|
||||
packetsOut.Add(count)
|
||||
if retransmit {
|
||||
retransmitPackets.Add(count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func IncrementBytes(direction Direction, count uint64) {
|
||||
promPacketBytes.WithLabelValues(string(direction)).Add(float64(count))
|
||||
func IncrementBytes(direction Direction, count uint64, retransmit bool) {
|
||||
promPacketBytes.WithLabelValues(
|
||||
string(direction),
|
||||
transmissionLabel(retransmit),
|
||||
).Add(float64(count))
|
||||
if direction == Incoming {
|
||||
bytesIn.Add(count)
|
||||
} else {
|
||||
bytesOut.Add(count)
|
||||
if retransmit {
|
||||
retransmitBytes.Add(count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,3 +113,11 @@ func IncrementRTCP(direction Direction, nack, pli, fir uint32) {
|
||||
promFirTotal.WithLabelValues(string(direction)).Add(float64(fir))
|
||||
}
|
||||
}
|
||||
|
||||
func transmissionLabel(retransmit bool) string {
|
||||
if retransmit {
|
||||
return transmissionInitial
|
||||
} else {
|
||||
return transmissionRetransmit
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user