adding rtc_init stat (#1316)

* adding rtc_initiated stat

* clean up signal and rtc init/connected

* update naming and break out stats update funcs

* update protocol dependency
This commit is contained in:
Dan McFaul
2023-01-23 12:49:15 -07:00
committed by GitHub
parent 56803a6b29
commit 9e3ca1e989
7 changed files with 83 additions and 64 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ require (
github.com/jxskiss/base62 v1.1.0 github.com/jxskiss/base62 v1.1.0
github.com/livekit/mageutil v0.0.0-20221221221243-f361fbe40290 github.com/livekit/mageutil v0.0.0-20221221221243-f361fbe40290
github.com/livekit/mediatransportutil v0.0.0-20230111071722-904079e94a7c github.com/livekit/mediatransportutil v0.0.0-20230111071722-904079e94a7c
github.com/livekit/protocol v1.3.2 github.com/livekit/protocol v1.3.3-0.20230123192015-7c8172cb6ec0
github.com/livekit/psrpc v0.2.4 github.com/livekit/psrpc v0.2.4
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995
github.com/mackerelio/go-osstat v0.2.3 github.com/mackerelio/go-osstat v0.2.3
+2
View File
@@ -235,6 +235,8 @@ github.com/livekit/mediatransportutil v0.0.0-20230111071722-904079e94a7c h1:wdzw
github.com/livekit/mediatransportutil v0.0.0-20230111071722-904079e94a7c/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw= github.com/livekit/mediatransportutil v0.0.0-20230111071722-904079e94a7c/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
github.com/livekit/protocol v1.3.2 h1:3goGWbB5HFRb3tMjog8KP0nvZL1Fy6zut3W1psBzqE4= github.com/livekit/protocol v1.3.2 h1:3goGWbB5HFRb3tMjog8KP0nvZL1Fy6zut3W1psBzqE4=
github.com/livekit/protocol v1.3.2/go.mod h1:gwCG03nKlHlC9hTjL4pXQpn783ALhmbyhq65UZxqbb8= github.com/livekit/protocol v1.3.2/go.mod h1:gwCG03nKlHlC9hTjL4pXQpn783ALhmbyhq65UZxqbb8=
github.com/livekit/protocol v1.3.3-0.20230123192015-7c8172cb6ec0 h1:l5VHOZj/vfKKWCp2dWpKnR9vp8USLCNd/ajQsj5FJVo=
github.com/livekit/protocol v1.3.3-0.20230123192015-7c8172cb6ec0/go.mod h1:gwCG03nKlHlC9hTjL4pXQpn783ALhmbyhq65UZxqbb8=
github.com/livekit/psrpc v0.2.4 h1:Fdxq56uJAIpRHCTgJsvp7ozw51dKtUmD3nxSXq9pCLs= github.com/livekit/psrpc v0.2.4 h1:Fdxq56uJAIpRHCTgJsvp7ozw51dKtUmD3nxSXq9pCLs=
github.com/livekit/psrpc v0.2.4/go.mod h1:+nJvbKx9DCZ6PSAsMHJPRAKjmRJ5WiyyhEmbKYqMKto= github.com/livekit/psrpc v0.2.4/go.mod h1:+nJvbKx9DCZ6PSAsMHJPRAKjmRJ5WiyyhEmbKYqMKto=
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw= github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw=
+2
View File
@@ -8,6 +8,7 @@ import (
"go.uber.org/atomic" "go.uber.org/atomic"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils"
@@ -82,6 +83,7 @@ func (r *LocalRouter) ListNodes() ([]*livekit.Node, error) {
} }
func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livekit.RoomName, pi ParticipantInit) (connectionID livekit.ConnectionID, reqSink MessageSink, resSource MessageSource, err error) { func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livekit.RoomName, pi ParticipantInit) (connectionID livekit.ConnectionID, reqSink MessageSink, resSource MessageSource, err error) {
prometheus.IncrementParticipantRtcInit(1)
// treat it as a new participant connecting // treat it as a new participant connecting
if r.onNewParticipant == nil { if r.onNewParticipant == nil {
err = ErrHandlerNotDefined err = ErrHandlerNotDefined
+1
View File
@@ -207,6 +207,7 @@ func (r *RedisRouter) WriteNodeRTC(_ context.Context, rtcNodeID string, msg *liv
} }
func (r *RedisRouter) startParticipantRTC(ss *livekit.StartSession, participantKey livekit.ParticipantKey, participantKeyB62 livekit.ParticipantKey) error { func (r *RedisRouter) startParticipantRTC(ss *livekit.StartSession, participantKey livekit.ParticipantKey, participantKeyB62 livekit.ParticipantKey) error {
prometheus.IncrementParticipantRtcInit(1)
// find the node where the room is hosted at // find the node where the room is hosted at
rtcNode, err := r.GetNodeForRoom(r.ctx, livekit.RoomName(ss.RoomName)) rtcNode, err := r.GetNodeForRoom(r.ctx, livekit.RoomName(ss.RoomName))
if err != nil { if err != nil {
+1 -1
View File
@@ -68,7 +68,7 @@ func (t *telemetryService) ParticipantJoined(
shouldSendEvent bool, shouldSendEvent bool,
) { ) {
t.enqueue(func() { t.enqueue(func() {
prometheus.IncrementParticipantJoin(1, true) prometheus.IncrementParticipantRtcConnected(1)
prometheus.AddParticipant() prometheus.AddParticipant()
t.createWorker( t.createWorker(
+12 -8
View File
@@ -132,8 +132,9 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
nackTotalNow := nackTotal.Load() nackTotalNow := nackTotal.Load()
retransmitBytesNow := retransmitBytes.Load() retransmitBytesNow := retransmitBytes.Load()
retransmitPacketsNow := retransmitPackets.Load() retransmitPacketsNow := retransmitPackets.Load()
participantJoinNow := participantJoin.Load() participantSignalConnectedNow := participantSignalConnected.Load()
participantRTCNow := participantRTC.Load() participantRTCInitNow := participantRTCInit.Load()
participantRTConnectedCNow := participantRTCConnected.Load()
trackPublishAttemptsNow := trackPublishAttempts.Load() trackPublishAttemptsNow := trackPublishAttempts.Load()
trackPublishSuccessNow := trackPublishSuccess.Load() trackPublishSuccessNow := trackPublishSuccess.Load()
trackSubscribeAttemptsNow := trackSubscribeAttempts.Load() trackSubscribeAttemptsNow := trackSubscribeAttempts.Load()
@@ -170,8 +171,9 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
RetransmitBytesOut: retransmitBytesNow, RetransmitBytesOut: retransmitBytesNow,
RetransmitPacketsOut: retransmitPacketsNow, RetransmitPacketsOut: retransmitPacketsNow,
NackTotal: nackTotalNow, NackTotal: nackTotalNow,
ParticipantJoin: participantJoinNow, ParticipantSignalConnected: participantSignalConnectedNow,
ParticipantRtc: participantRTCNow, ParticipantRtcInit: participantRTCInitNow,
ParticipantRtcConnected: participantRTConnectedCNow,
BytesInPerSec: prevAverage.BytesInPerSec, BytesInPerSec: prevAverage.BytesInPerSec,
BytesOutPerSec: prevAverage.BytesOutPerSec, BytesOutPerSec: prevAverage.BytesOutPerSec,
PacketsInPerSec: prevAverage.PacketsInPerSec, PacketsInPerSec: prevAverage.PacketsInPerSec,
@@ -179,8 +181,9 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
RetransmitBytesOutPerSec: prevAverage.RetransmitBytesOutPerSec, RetransmitBytesOutPerSec: prevAverage.RetransmitBytesOutPerSec,
RetransmitPacketsOutPerSec: prevAverage.RetransmitPacketsOutPerSec, RetransmitPacketsOutPerSec: prevAverage.RetransmitPacketsOutPerSec,
NackPerSec: prevAverage.NackPerSec, NackPerSec: prevAverage.NackPerSec,
ParticipantJoinPerSec: prevAverage.ParticipantJoinPerSec, ParticipantSignalConnectedPerSec: prevAverage.ParticipantSignalConnectedPerSec,
ParticipantRtcPerSec: prevAverage.ParticipantRtcPerSec, ParticipantRtcInitPerSec: prevAverage.ParticipantRtcInitPerSec,
ParticipantRtcConnectedPerSec: prevAverage.ParticipantRtcConnectedPerSec,
NumCpus: numCPUs, NumCpus: numCPUs,
CpuLoad: cpuLoad, CpuLoad: cpuLoad,
MemoryTotal: memTotal, MemoryTotal: memTotal,
@@ -205,8 +208,9 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
stats.RetransmitBytesOutPerSec = perSec(prevAverage.RetransmitBytesOut, retransmitBytesNow, elapsed) stats.RetransmitBytesOutPerSec = perSec(prevAverage.RetransmitBytesOut, retransmitBytesNow, elapsed)
stats.RetransmitPacketsOutPerSec = perSec(prevAverage.RetransmitPacketsOut, retransmitPacketsNow, elapsed) stats.RetransmitPacketsOutPerSec = perSec(prevAverage.RetransmitPacketsOut, retransmitPacketsNow, elapsed)
stats.NackPerSec = perSec(prevAverage.NackTotal, nackTotalNow, elapsed) stats.NackPerSec = perSec(prevAverage.NackTotal, nackTotalNow, elapsed)
stats.ParticipantJoinPerSec = perSec(prevAverage.ParticipantJoin, participantJoinNow, elapsed) stats.ParticipantSignalConnectedPerSec = perSec(prevAverage.ParticipantSignalConnected, participantSignalConnectedNow, elapsed)
stats.ParticipantRtcPerSec = perSec(prevAverage.ParticipantRtc, participantRTCNow, elapsed) stats.ParticipantRtcInitPerSec = perSec(prevAverage.ParticipantRtcInit, participantRTCInitNow, elapsed)
stats.ParticipantRtcConnectedPerSec = perSec(prevAverage.ParticipantRtcConnected, participantRTConnectedCNow, elapsed)
stats.SysPacketsOutPerSec = perSec(uint64(prevAverage.SysPacketsOut), uint64(sysPackets), elapsed) stats.SysPacketsOutPerSec = perSec(uint64(prevAverage.SysPacketsOut), uint64(sysPackets), elapsed)
stats.SysPacketsDroppedPerSec = perSec(uint64(prevAverage.SysPacketsDropped), uint64(sysDroppedPackets), elapsed) stats.SysPacketsDroppedPerSec = perSec(uint64(prevAverage.SysPacketsDropped), uint64(sysDroppedPackets), elapsed)
stats.TrackPublishAttemptsPerSec = perSec(uint64(prevAverage.NumTrackPublishAttempts), uint64(trackPublishAttemptsNow), elapsed) stats.TrackPublishAttemptsPerSec = perSec(uint64(prevAverage.NumTrackPublishAttempts), uint64(trackPublishAttemptsNow), elapsed)
+18 -8
View File
@@ -24,8 +24,9 @@ var (
nackTotal atomic.Uint64 nackTotal atomic.Uint64
retransmitBytes atomic.Uint64 retransmitBytes atomic.Uint64
retransmitPackets atomic.Uint64 retransmitPackets atomic.Uint64
participantJoin atomic.Uint64 participantSignalConnected atomic.Uint64
participantRTC atomic.Uint64 participantRTCConnected atomic.Uint64
participantRTCInit atomic.Uint64
promPacketLabels = []string{"direction", "transmission"} promPacketLabels = []string{"direction", "transmission"}
promPacketTotal *prometheus.CounterVec promPacketTotal *prometheus.CounterVec
@@ -191,16 +192,25 @@ func RecordRTT(direction Direction, trackSource livekit.TrackSource, trackType l
} }
} }
func IncrementParticipantJoin(join uint32, rtcConnected ...bool) { func IncrementParticipantJoin(join uint32) {
if join > 0 { if join > 0 {
if len(rtcConnected) > 0 && rtcConnected[0] { participantSignalConnected.Add(uint64(join))
participantRTC.Add(uint64(join))
promParticipantJoin.WithLabelValues("rtc_connected").Add(float64(join))
} else {
participantJoin.Add(uint64(join))
promParticipantJoin.WithLabelValues("signal_connected").Add(float64(join)) promParticipantJoin.WithLabelValues("signal_connected").Add(float64(join))
} }
} }
func IncrementParticipantRtcInit(join uint32) {
if join > 0 {
participantRTCInit.Add(uint64(join))
promParticipantJoin.WithLabelValues("rtc_init").Add(float64(join))
}
}
func IncrementParticipantRtcConnected(join uint32) {
if join > 0 {
participantRTCConnected.Add(uint64(join))
promParticipantJoin.WithLabelValues("rtc_connected").Add(float64(join))
}
} }
func AddConnection(direction Direction) { func AddConnection(direction Direction) {