Stats collect v2 (#1291)
* initial commit * add correct label * clean up * more cleanup on adding stats * cleanup * move things to pub and sub monitors, ensure stats are correctly updated * fix merge conflict * Fix panic on MacOS (#1296) * fixing last feedback Co-authored-by: Raja Subramanian <raja.gobi@tutanota.com>
This commit is contained in:
co-authored by
Raja Subramanian
parent
0ca80a4fa7
commit
4d6f0cd0f7
@@ -589,7 +589,7 @@ func (p *ParticipantImpl) SetMigrateInfo(
|
||||
for _, t := range mediaTracks {
|
||||
ti := t.GetTrack()
|
||||
|
||||
p.supervisor.AddPublication(livekit.TrackID(ti.Sid))
|
||||
p.supervisor.AddPublication(livekit.TrackID(ti.Sid), ti.Type)
|
||||
p.supervisor.SetPublicationMute(livekit.TrackID(ti.Sid), ti.Muted)
|
||||
|
||||
p.pendingTracks[t.GetCid()] = &pendingTrackInfo{trackInfos: []*livekit.TrackInfo{ti}, migrated: true}
|
||||
@@ -1548,7 +1548,7 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
}
|
||||
|
||||
if p.getPublishedTrackBySignalCid(req.Cid) != nil || p.getPublishedTrackBySdpCid(req.Cid) != nil || p.pendingTracks[req.Cid] != nil {
|
||||
p.supervisor.AddPublication(livekit.TrackID(ti.Sid))
|
||||
p.supervisor.AddPublication(livekit.TrackID(ti.Sid), ti.Type)
|
||||
p.supervisor.SetPublicationMute(livekit.TrackID(ti.Sid), ti.Muted)
|
||||
|
||||
if p.pendingTracks[req.Cid] == nil {
|
||||
@@ -1560,7 +1560,7 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
return nil
|
||||
}
|
||||
|
||||
p.supervisor.AddPublication(livekit.TrackID(ti.Sid))
|
||||
p.supervisor.AddPublication(livekit.TrackID(ti.Sid), ti.Type)
|
||||
p.supervisor.SetPublicationMute(livekit.TrackID(ti.Sid), ti.Muted)
|
||||
|
||||
p.pendingTracks[req.Cid] = &pendingTrackInfo{trackInfos: []*livekit.TrackInfo{ti}}
|
||||
|
||||
@@ -221,12 +221,10 @@ func (r *Room) Join(participant types.LocalParticipant, opts *ParticipantOptions
|
||||
defer r.lock.Unlock()
|
||||
|
||||
if r.IsClosed() {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("participant_join", "error", "room_closed").Add(1)
|
||||
return ErrRoomClosed
|
||||
}
|
||||
|
||||
if r.participants[participant.Identity()] != nil {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("participant_join", "error", "already_joined").Add(1)
|
||||
return ErrAlreadyJoined
|
||||
}
|
||||
|
||||
@@ -239,7 +237,6 @@ func (r *Room) Join(participant types.LocalParticipant, opts *ParticipantOptions
|
||||
}
|
||||
|
||||
if participantCount >= int(r.protoRoom.MaxParticipants) {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("participant_join", "error", "max_exceeded").Add(1)
|
||||
return ErrMaxParticipantsExceeded
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -91,7 +92,7 @@ func (p *ParticipantSupervisor) SetPublisherPeerConnectionConnected(isConnected
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *ParticipantSupervisor) AddPublication(trackID livekit.TrackID) {
|
||||
func (p *ParticipantSupervisor) AddPublication(trackID livekit.TrackID, trackType livekit.TrackType) {
|
||||
p.lock.Lock()
|
||||
pm, ok := p.publications[trackID]
|
||||
if !ok {
|
||||
@@ -106,7 +107,7 @@ func (p *ParticipantSupervisor) AddPublication(trackID livekit.TrackID) {
|
||||
}
|
||||
p.publications[trackID] = pm
|
||||
}
|
||||
pm.opMon.PostEvent(types.OperationMonitorEventAddPendingPublication, nil)
|
||||
pm.opMon.PostEvent(types.OperationMonitorEventAddPendingPublication, trackType.String())
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gammazero/deque"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
@@ -56,7 +58,7 @@ func (p *PublicationMonitor) PostEvent(ome types.OperationMonitorEvent, omd type
|
||||
case types.OperationMonitorEventPublisherPeerConnectionConnected:
|
||||
p.setConnected(omd.(bool))
|
||||
case types.OperationMonitorEventAddPendingPublication:
|
||||
p.addPending()
|
||||
p.addPending(omd.(string))
|
||||
case types.OperationMonitorEventSetPublicationMute:
|
||||
p.setMute(omd.(bool))
|
||||
case types.OperationMonitorEventSetPublishedTrack:
|
||||
@@ -66,7 +68,9 @@ func (p *PublicationMonitor) PostEvent(ome types.OperationMonitorEvent, omd type
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PublicationMonitor) addPending() {
|
||||
func (p *PublicationMonitor) addPending(trackType string) {
|
||||
prometheus.AddPublishAttempt(trackType)
|
||||
|
||||
p.lock.Lock()
|
||||
p.desiredPublishes.PushBack(
|
||||
&publish{
|
||||
@@ -166,6 +170,10 @@ func (p *PublicationMonitor) update() {
|
||||
return
|
||||
}
|
||||
|
||||
if pub.isStart && p.publishedTrack != nil {
|
||||
prometheus.AddPublishSuccess(p.publishedTrack.Kind().String())
|
||||
}
|
||||
|
||||
if (pub.isStart && p.publishedTrack == nil) || (!pub.isStart && p.publishedTrack != nil) {
|
||||
// put it back as the condition is not satisfied
|
||||
p.desiredPublishes.PushFront(pub)
|
||||
|
||||
@@ -6,7 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gammazero/deque"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
@@ -73,6 +75,10 @@ func (s *SubscriptionMonitor) PostEvent(ome types.OperationMonitorEvent, omd typ
|
||||
}
|
||||
|
||||
func (s *SubscriptionMonitor) updateSubscription(params SubscriptionOpParams) {
|
||||
if params.IsSubscribe {
|
||||
prometheus.AddSubscribeAttempt(params.SourceTrack.Kind().String())
|
||||
}
|
||||
|
||||
s.lock.Lock()
|
||||
|
||||
so := s.getOrCreateSubscriptionOpsForSource(params.SourceTrack)
|
||||
@@ -171,6 +177,10 @@ func (s *SubscriptionMonitor) update() {
|
||||
break
|
||||
}
|
||||
|
||||
if tx.isSubscribe && so.subscribedTrack != nil {
|
||||
prometheus.AddSubscribeSuccess(so.subscribedTrack.MediaTrack().Kind().String())
|
||||
}
|
||||
|
||||
if so.desiredTransitions.Len() == 0 && so.subscribedTrack == nil {
|
||||
delete(s.subscriptionOpsBySource, sourceTrack)
|
||||
}
|
||||
|
||||
@@ -409,7 +409,6 @@ func (t *PCTransport) setICEConnectedAt(at time.Time) {
|
||||
// This prevents reset of connected at time if ICE goes `Connected` -> `Disconnected` -> `Connected`.
|
||||
//
|
||||
t.iceConnectedAt = at
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("ice_connection", "success", "").Add(1)
|
||||
}
|
||||
t.lock.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user