diff --git a/internal/webrtc/metrics.go b/internal/webrtc/metrics.go index 14daf21b..b682b070 100644 --- a/internal/webrtc/metrics.go +++ b/internal/webrtc/metrics.go @@ -10,8 +10,9 @@ import ( ) type metrics struct { - connectionState prometheus.Gauge - connectionCount prometheus.Counter + connectionState prometheus.Gauge + connectionStateCount prometheus.Counter + connectionCount prometheus.Counter iceCandidates map[string]struct{} iceCandidatesCount prometheus.Counter @@ -51,6 +52,15 @@ func (m *metricsCtx) getBySession(session types.Session) metrics { "session_id": session.ID(), }, }), + connectionStateCount: promauto.NewCounter(prometheus.CounterOpts{ + Name: "connection_state_count", + Namespace: "neko", + Subsystem: "webrtc", + Help: "Count of connection state changes for a session.", + ConstLabels: map[string]string{ + "session_id": session.ID(), + }, + }), connectionCount: promauto.NewCounter(prometheus.CounterOpts{ Name: "connection_count", Namespace: "neko", @@ -131,6 +141,8 @@ func (m *metricsCtx) SetState(session types.Session, state webrtc.PeerConnection default: met.connectionState.Set(-1) } + + met.connectionStateCount.Add(1) } func (m *metricsCtx) SetTransportStats(session types.Session, data webrtc.TransportStats) {