Fix SubParticipant twice when paticipant left (#2672)

This commit is contained in:
cnderrauber
2024-04-23 16:09:02 +08:00
committed by GitHub
parent 8f05385126
commit f239f8bff1
+3 -7
View File
@@ -161,18 +161,14 @@ func (t *telemetryService) ParticipantLeft(ctx context.Context,
) {
t.enqueue(func() {
isConnected := false
hasWorker := false
if worker, ok := t.getWorker(livekit.ParticipantID(participant.Sid)); ok {
hasWorker = true
isConnected = worker.IsConnected()
if worker.ClosedAt().IsZero() {
prometheus.SubParticipant()
}
worker.Close()
}
if hasWorker {
// signifies we had incremented participant count
prometheus.SubParticipant()
}
if isConnected && shouldSendEvent {
t.NotifyEvent(ctx, &livekit.WebhookEvent{
Event: webhook.EventParticipantLeft,