From 78bf642d670d4771a59266bf1fa0e3a457bbb0a6 Mon Sep 17 00:00:00 2001 From: Paul Wells Date: Fri, 12 Jan 2024 05:55:56 -0800 Subject: [PATCH] record session once (#2381) --- pkg/rtc/participant.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 06171a837..bfb3112ca 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -145,6 +145,7 @@ type ParticipantImpl struct { hidden atomic.Bool isPublisher atomic.Bool + sessionStartRecorded atomic.Bool // when first connected connectedAt time.Time // timer that's set when disconnect is detected on primary PC @@ -1422,7 +1423,9 @@ func (p *ParticipantImpl) onPrimaryTransportInitialConnected() { } func (p *ParticipantImpl) onPrimaryTransportFullyEstablished() { - prometheus.RecordSessionStartTime(int(p.ProtocolVersion()), time.Since(p.params.SessionStartTime)) + if !p.sessionStartRecorded.Swap(true) { + prometheus.RecordSessionStartTime(int(p.ProtocolVersion()), time.Since(p.params.SessionStartTime)) + } p.updateState(livekit.ParticipantInfo_ACTIVE) }