diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index a6348783..e02104d9 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -452,6 +452,8 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, bitrate int, peer := &WebRTCPeerCtx{ logger: logger, + session: session, + metrics: metrics, connection: connection, // tracks & channels audioTrack: audioTrack, diff --git a/internal/webrtc/metrics.go b/internal/webrtc/metrics.go index f0b2b3fc..025bb4ba 100644 --- a/internal/webrtc/metrics.go +++ b/internal/webrtc/metrics.go @@ -13,16 +13,16 @@ import ( type metricsManager struct { mu sync.Mutex - sessions map[string]metrics + sessions map[string]*metrics } func newMetricsManager() *metricsManager { return &metricsManager{ - sessions: map[string]metrics{}, + sessions: map[string]*metrics{}, } } -func (m *metricsManager) getBySession(session types.Session) metrics { +func (m *metricsManager) getBySession(session types.Session) *metrics { m.mu.Lock() defer m.mu.Unlock() @@ -33,7 +33,7 @@ func (m *metricsManager) getBySession(session types.Session) metrics { return met } - met = metrics{ + met = &metrics{ sessionId: sessionId, connectionState: promauto.NewGauge(prometheus.GaugeOpts{ diff --git a/internal/webrtc/peer.go b/internal/webrtc/peer.go index 7edd3e8f..322e71d8 100644 --- a/internal/webrtc/peer.go +++ b/internal/webrtc/peer.go @@ -16,6 +16,8 @@ import ( type WebRTCPeerCtx struct { mu sync.Mutex logger zerolog.Logger + session types.Session + metrics *metrics connection *webrtc.PeerConnection // tracks & channels audioTrack *Track