mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
stats ice Candidates Count.
This commit is contained in:
parent
8e80ef2c69
commit
fc5c017666
@ -411,6 +411,14 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
if ok {
|
||||
manager.metrics.SetTransportStats(session, data)
|
||||
}
|
||||
|
||||
for _, entry := range stats {
|
||||
// only remote ice candidate stats
|
||||
candidate, ok := entry.(webrtc.ICECandidateStats)
|
||||
if ok && candidate.Type == webrtc.StatsTypeRemoteCandidate {
|
||||
manager.metrics.NewICECandidate(session, candidate.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -13,6 +13,9 @@ type metrics struct {
|
||||
connectionState prometheus.Gauge
|
||||
connectionCount prometheus.Counter
|
||||
|
||||
iceCandidates map[string]struct{}
|
||||
iceCandidatesCount prometheus.Counter
|
||||
|
||||
bytesSent prometheus.Gauge
|
||||
bytesReceived prometheus.Gauge
|
||||
}
|
||||
@ -57,6 +60,18 @@ func (m *metricsCtx) getBySession(session types.Session) metrics {
|
||||
"session_id": session.ID(),
|
||||
},
|
||||
}),
|
||||
|
||||
iceCandidates: map[string]struct{}{},
|
||||
iceCandidatesCount: promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "ice_candidates_count",
|
||||
Namespace: "neko",
|
||||
Subsystem: "webrtc",
|
||||
Help: "Count of ICE candidates sent by a remote client.",
|
||||
ConstLabels: map[string]string{
|
||||
"session_id": session.ID(),
|
||||
},
|
||||
}),
|
||||
|
||||
bytesSent: promauto.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "bytes_sent",
|
||||
Namespace: "neko",
|
||||
@ -86,6 +101,17 @@ func (m *metricsCtx) NewConnection(session types.Session) {
|
||||
met.connectionCount.Add(1)
|
||||
}
|
||||
|
||||
func (m *metricsCtx) NewICECandidate(session types.Session, id string) {
|
||||
met := m.getBySession(session)
|
||||
|
||||
if _, found := met.iceCandidates[id]; found {
|
||||
return
|
||||
}
|
||||
|
||||
met.iceCandidates[id] = struct{}{}
|
||||
met.iceCandidatesCount.Add(1)
|
||||
}
|
||||
|
||||
func (m *metricsCtx) SetState(session types.Session, state webrtc.PeerConnectionState) {
|
||||
met := m.getBySession(session)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user