feat(webrtc): add StreamCount() for metrics snapshot
Some checks failed
ci / race tests (push) Blocked by required conditions
ci / WebRTC smoke (5-viewer fanout) (push) Blocked by required conditions
ci / WebRTC latency p95 gate (push) Blocked by required conditions
ci / vet + build (push) Has been cancelled

This commit is contained in:
Zac Gaetano 2026-05-06 15:57:13 -04:00
parent 15af16ce97
commit 1d7cd5b520

View file

@ -12,8 +12,7 @@ import (
// Subsystem is the app-level WebRTC egress manager. It sits alongside // Subsystem is the app-level WebRTC egress manager. It sits alongside
// api.API as a sibling — both consume the Restream service, both wire // api.API as a sibling — both consume the Restream service, both wire
// themselves into the Echo HTTP router. The subsystem is responsible // themselves into the Echo HTTP router. The subsystem is responsible for:
// for:
// //
// - Translating the global config.DataWebRTC into the core-level // - Translating the global config.DataWebRTC into the core-level
// corewebrtc.Config used by the PeerFactory. // corewebrtc.Config used by the PeerFactory.
@ -129,6 +128,14 @@ func (s *Subsystem) SetTeardownHook(fn func(streamID string)) {
s.teardown = fn s.teardown = fn
} }
// StreamCount returns the number of processes currently registered with
// active WebRTC egress. Used by the Prometheus snapshot collector.
func (s *Subsystem) StreamCount() int {
s.mu.Lock()
defer s.mu.Unlock()
return len(s.streams)
}
// lookup returns the per-process stream pair for id, or nil, false. // lookup returns the per-process stream pair for id, or nil, false.
// Used by the WHEP handler. // Used by the WHEP handler.
func (s *Subsystem) lookup(id string) (*processStream, bool) { func (s *Subsystem) lookup(id string) (*processStream, bool) {