Add counter for pub&sub time metrics (#3084)
* Add counter for pub&sub time metrics The pub&sub shows large value in migration related case like muted/disabled migration, the subscription time depends on the time when publisher unmute the track(sending rtp packet after migration), add a counter to distinguish since we can't control the time in such cases and the first subscription attemps also is more meaningful than those cases. * Add info log for high publish delay
This commit is contained in:
@@ -759,7 +759,8 @@ type trackSubscription struct {
|
||||
subStartedAt atomic.Pointer[time.Time]
|
||||
|
||||
// the timestamp when the subscription was started, will be reset when downtrack is closed with expected resume
|
||||
subscribeAt atomic.Pointer[time.Time]
|
||||
subscribeAt atomic.Pointer[time.Time]
|
||||
succRecordCounter atomic.Int32
|
||||
}
|
||||
|
||||
func newTrackSubscription(subscriberID livekit.ParticipantID, trackID livekit.TrackID, l logger.Logger) *trackSubscription {
|
||||
@@ -1003,7 +1004,7 @@ func (s *trackSubscription) maybeRecordSuccess(ts telemetry.TelemetryService, pI
|
||||
d := time.Since(*s.subscribeAt.Load())
|
||||
s.logger.Debugw("track subscribed", "cost", d.Milliseconds())
|
||||
subscriber := subTrack.Subscriber()
|
||||
prometheus.RecordSubscribeTime(mediaTrack.Source(), mediaTrack.Kind(), d, subscriber.GetClientInfo().GetSdk(), subscriber.Kind())
|
||||
prometheus.RecordSubscribeTime(mediaTrack.Source(), mediaTrack.Kind(), d, subscriber.GetClientInfo().GetSdk(), subscriber.Kind(), int(s.succRecordCounter.Inc()))
|
||||
|
||||
eventSent := s.eventSent.Swap(true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user