Record join/publish/subscribe cancellations. (#4102)
To get better picture of success/failure rate.
This commit is contained in:
+10
-2
@@ -1525,6 +1525,12 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
|
||||
}
|
||||
|
||||
p.pendingTracksLock.Lock()
|
||||
for _, pti := range p.pendingTracks {
|
||||
if len(pti.trackInfos) == 0 {
|
||||
continue
|
||||
}
|
||||
prometheus.RecordTrackPublishCancels(pti.trackInfos[0].Type.String(), int32(len(pti.trackInfos)))
|
||||
}
|
||||
p.pendingTracks = make(map[string]*pendingTrackInfo)
|
||||
p.pendingPublishingTracks = make(map[livekit.TrackID]*pendingTrackInfo)
|
||||
p.pendingTracksLock.Unlock()
|
||||
@@ -3006,7 +3012,8 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
|
||||
mimeType := codec.Codec
|
||||
videoLayerMode := codec.VideoLayerMode
|
||||
if req.Type == livekit.TrackType_VIDEO {
|
||||
switch req.Type {
|
||||
case livekit.TrackType_VIDEO:
|
||||
if !mime.IsMimeTypeStringVideo(mimeType) {
|
||||
mimeType = mime.MimeTypePrefixVideo + mimeType
|
||||
}
|
||||
@@ -3032,7 +3039,8 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if req.Type == livekit.TrackType_AUDIO {
|
||||
|
||||
case livekit.TrackType_AUDIO:
|
||||
if !mime.IsMimeTypeStringAudio(mimeType) {
|
||||
mimeType = mime.MimeTypePrefixAudio + mimeType
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ func (m *SubscriptionManager) Close(isExpectedToResume bool) {
|
||||
<-m.doneCh
|
||||
done.Store(true)
|
||||
|
||||
prometheus.RecordTrackSubscribeCancels(int32(m.getNumCancellations()))
|
||||
|
||||
subTracks := m.GetSubscribedTracks()
|
||||
downTracksToClose := make([]*sfu.DownTrack, 0, len(subTracks))
|
||||
for _, st := range subTracks {
|
||||
@@ -891,6 +893,19 @@ func (m *SubscriptionManager) handleSubscribedTrackClose(s *trackSubscription, i
|
||||
}
|
||||
}
|
||||
|
||||
func (m *SubscriptionManager) getNumCancellations() int {
|
||||
m.lock.RLock()
|
||||
defer m.lock.RUnlock()
|
||||
|
||||
numCancellations := 0
|
||||
for _, sub := range m.subscriptions {
|
||||
if sub.isCanceled() {
|
||||
numCancellations++
|
||||
}
|
||||
}
|
||||
return numCancellations
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
type trackSubscription struct {
|
||||
@@ -1173,6 +1188,10 @@ func (s *trackSubscription) maybeRecordSuccess(ts telemetry.TelemetryService, pI
|
||||
ts.TrackSubscribed(context.Background(), pID, mediaTrack.ToProto(), pi, !eventSent)
|
||||
}
|
||||
|
||||
func (s *trackSubscription) isCanceled() bool {
|
||||
return !s.eventSent.Load() && s.isDesired()
|
||||
}
|
||||
|
||||
func (s *trackSubscription) durationSinceStart() time.Duration {
|
||||
t := s.subStartedAt.Load()
|
||||
if t == nil {
|
||||
|
||||
Reference in New Issue
Block a user