mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
split sctp and ice bytes.
This commit is contained in:
parent
7a1c8813e6
commit
bb35695255
@ -409,7 +409,12 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
|||||||
stats := connection.GetStats()
|
stats := connection.GetStats()
|
||||||
data, ok := stats["iceTransport"].(webrtc.TransportStats)
|
data, ok := stats["iceTransport"].(webrtc.TransportStats)
|
||||||
if ok {
|
if ok {
|
||||||
manager.metrics.SetTransportStats(session, data)
|
manager.metrics.SetIceTransportStats(session, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
data, ok = stats["sctpTransport"].(webrtc.TransportStats)
|
||||||
|
if ok {
|
||||||
|
manager.metrics.SetSctpTransportStats(session, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range stats {
|
for _, entry := range stats {
|
||||||
|
@ -17,8 +17,10 @@ type metrics struct {
|
|||||||
iceCandidates map[string]struct{}
|
iceCandidates map[string]struct{}
|
||||||
iceCandidatesCount prometheus.Counter
|
iceCandidatesCount prometheus.Counter
|
||||||
|
|
||||||
bytesSent prometheus.Gauge
|
iceBytesSent prometheus.Gauge
|
||||||
bytesReceived prometheus.Gauge
|
iceBytesReceived prometheus.Gauge
|
||||||
|
sctpBytesSent prometheus.Gauge
|
||||||
|
sctpBytesReceived prometheus.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
type metricsCtx struct {
|
type metricsCtx struct {
|
||||||
@ -82,20 +84,39 @@ func (m *metricsCtx) getBySession(session types.Session) metrics {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
bytesSent: promauto.NewGauge(prometheus.GaugeOpts{
|
iceBytesSent: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "bytes_sent",
|
Name: "ice_bytes_sent",
|
||||||
Namespace: "neko",
|
Namespace: "neko",
|
||||||
Subsystem: "webrtc",
|
Subsystem: "webrtc",
|
||||||
Help: "Sent bytes to a session.",
|
Help: "Sent bytes using ICE transport to a session.",
|
||||||
ConstLabels: map[string]string{
|
ConstLabels: map[string]string{
|
||||||
"session_id": session.ID(),
|
"session_id": session.ID(),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
bytesReceived: promauto.NewGauge(prometheus.GaugeOpts{
|
iceBytesReceived: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "bytes_received",
|
Name: "ice_bytes_received",
|
||||||
Namespace: "neko",
|
Namespace: "neko",
|
||||||
Subsystem: "webrtc",
|
Subsystem: "webrtc",
|
||||||
Help: "Received bytes from a session.",
|
Help: "Received bytes using ICE transport from a session.",
|
||||||
|
ConstLabels: map[string]string{
|
||||||
|
"session_id": session.ID(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
sctpBytesSent: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Name: "sctp_bytes_sent",
|
||||||
|
Namespace: "neko",
|
||||||
|
Subsystem: "webrtc",
|
||||||
|
Help: "Sent bytes using SCTP transport to a session.",
|
||||||
|
ConstLabels: map[string]string{
|
||||||
|
"session_id": session.ID(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
sctpBytesReceived: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Name: "sctp_bytes_received",
|
||||||
|
Namespace: "neko",
|
||||||
|
Subsystem: "webrtc",
|
||||||
|
Help: "Received bytes using SCTP transport from a session.",
|
||||||
ConstLabels: map[string]string{
|
ConstLabels: map[string]string{
|
||||||
"session_id": session.ID(),
|
"session_id": session.ID(),
|
||||||
},
|
},
|
||||||
@ -145,9 +166,16 @@ func (m *metricsCtx) SetState(session types.Session, state webrtc.PeerConnection
|
|||||||
met.connectionStateCount.Add(1)
|
met.connectionStateCount.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *metricsCtx) SetTransportStats(session types.Session, data webrtc.TransportStats) {
|
func (m *metricsCtx) SetIceTransportStats(session types.Session, data webrtc.TransportStats) {
|
||||||
met := m.getBySession(session)
|
met := m.getBySession(session)
|
||||||
|
|
||||||
met.bytesSent.Set(float64(data.BytesSent))
|
met.iceBytesSent.Set(float64(data.BytesSent))
|
||||||
met.bytesReceived.Set(float64(data.BytesReceived))
|
met.iceBytesReceived.Set(float64(data.BytesReceived))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *metricsCtx) SetSctpTransportStats(session types.Session, data webrtc.TransportStats) {
|
||||||
|
met := m.getBySession(session)
|
||||||
|
|
||||||
|
met.sctpBytesSent.Set(float64(data.BytesSent))
|
||||||
|
met.sctpBytesReceived.Set(float64(data.BytesReceived))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user