1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-27 19:12:07 +02:00

Store connected viewers in Prometheus and serve this amount

This commit is contained in:
Yohann D'ANELLO
2020-09-29 18:03:28 +02:00
parent c49b5eeb2b
commit 2005f3ece1
6 changed files with 31 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package webrtc
import (
"fmt"
"gitlab.crans.org/nounous/ghostream/internal/monitoring"
"io"
"log"
"math/rand"
@ -128,10 +129,12 @@ func newPeerHandler(remoteSdp webrtc.SessionDescription, cfg *Options) webrtc.Se
// Register tracks
videoTracks = append(videoTracks, videoTrack)
audioTracks = append(audioTracks, audioTrack)
monitoring.WebRTCConnectedSessions.Inc()
} else if connectionState == webrtc.ICEConnectionStateDisconnected {
// Unregister tracks
videoTracks = removeTrack(videoTracks, videoTrack)
audioTracks = removeTrack(audioTracks, audioTrack)
monitoring.WebRTCConnectedSessions.Dec()
}
})