metrics connection State Count.

This commit is contained in:
Miroslav Šedivý 2022-06-30 23:54:06 +02:00
parent fc5c017666
commit 7a1c8813e6

View File

@ -11,6 +11,7 @@ import (
type metrics struct {
connectionState prometheus.Gauge
connectionStateCount prometheus.Counter
connectionCount prometheus.Counter
iceCandidates map[string]struct{}
@ -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) {