From 38d7efca83f5a18f15a4dfaa3d6942179eda1154 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Thu, 16 Jul 2026 12:49:27 +0530 Subject: [PATCH] Record `rtc_success` prom as soon as RTC connects. (#4677) Was doing it on participant close. But, that misaligns `rtc_init` (number of attempts) a bit if the participant sessions are long. Record it as soon as RTC connects so that it is more time aligned with `rtc_init`. --- pkg/rtc/participant.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index c70cb3f1a..06f1ab55b 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -1434,13 +1434,13 @@ func (p *ParticipantImpl) IsMigration() bool { func (p *ParticipantImpl) recordRTCState(closeReason types.ParticipantCloseReason) { if p.HasConnected() { - prometheus.IncrementParticipantRtcSuccess(1) + return + } + + if p.IsConnectionCanceled(closeReason) { + prometheus.IncrementParticipantRtcCanceled(1) } else { - if p.IsConnectionCanceled(closeReason) { - prometheus.IncrementParticipantRtcCanceled(1) - } else { - prometheus.IncrementParticipantRtcFailure(1) - } + prometheus.IncrementParticipantRtcFailure(1) } } @@ -2648,6 +2648,7 @@ func (p *ParticipantImpl) onPrimaryTransportInitialConnected() { if !p.sessionStartRecorded.Swap(true) { prometheus.RecordSessionStartTime(int(p.ProtocolVersion()), time.Since(p.params.SessionStartTime)) + prometheus.IncrementParticipantRtcSuccess(1) } p.updateState(livekit.ParticipantInfo_ACTIVE) }