Track participant join total + rate in node stats (#741)

* Track participant join total + rate in node stats

* update protocol
This commit is contained in:
Raja Subramanian
2022-05-30 15:58:30 +05:30
committed by GitHub
parent 62308b2ce0
commit 508aa471a9
5 changed files with 34 additions and 11 deletions
+23 -7
View File
@@ -22,14 +22,16 @@ var (
nackTotal atomic.Uint64
retransmitBytes atomic.Uint64
retransmitPackets atomic.Uint64
participantJoin atomic.Uint64
promPacketLabels = []string{"direction", "transmission"}
promPacketTotal *prometheus.CounterVec
promPacketBytes *prometheus.CounterVec
promRTCPLabels = []string{"direction"}
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
promParticipantJoin *prometheus.CounterVec
)
func initPacketStats(nodeID string) {
@@ -63,12 +65,19 @@ func initPacketStats(nodeID string) {
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
}, promRTCPLabels)
promParticipantJoin = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "participant_join",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
}, nil)
prometheus.MustRegister(promPacketTotal)
prometheus.MustRegister(promPacketBytes)
prometheus.MustRegister(promNackTotal)
prometheus.MustRegister(promPliTotal)
prometheus.MustRegister(promFirTotal)
prometheus.MustRegister(promParticipantJoin)
}
func IncrementPackets(direction Direction, count uint64, retransmit bool) {
@@ -114,6 +123,13 @@ func IncrementRTCP(direction Direction, nack, pli, fir uint32) {
}
}
func IncrementParticipantJoin(join uint32) {
if join > 0 {
promParticipantJoin.WithLabelValues().Add(float64(join))
participantJoin.Add(uint64(join))
}
}
func transmissionLabel(retransmit bool) string {
if !retransmit {
return transmissionInitial