record session once (#2381)

This commit is contained in:
Paul Wells
2024-01-12 05:55:56 -08:00
committed by GitHub
parent c726cbf2ba
commit 78bf642d67
+4 -1
View File
@@ -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)
}