add ReceiverReport.

This commit is contained in:
Miroslav Šedivý 2022-07-04 01:01:03 +02:00
parent fb707f05a6
commit d5c934f2af
2 changed files with 48 additions and 0 deletions

View File

@ -404,6 +404,13 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
switch rtcpPacket := p.(type) {
case *rtcp.ReceiverEstimatedMaximumBitrate: // TODO: Deprecated.
manager.metrics.SetReceiverEstimatedMaximumBitrate(session, rtcpPacket.Bitrate)
case *rtcp.ReceiverReport:
l := len(rtcpPacket.Reports)
if l > 0 {
// use only last report
manager.metrics.SetReceiverReport(session, rtcpPacket.Reports[l-1])
}
}
})

View File

@ -3,6 +3,7 @@ package webrtc
import (
"sync"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
@ -23,6 +24,10 @@ type metrics struct {
receiverEstimatedMaximumBitrate prometheus.Gauge
receiverReportDelay prometheus.Gauge
receiverReportJitter prometheus.Gauge
receiverReportTotalLost prometheus.Gauge
iceBytesSent prometheus.Gauge
iceBytesReceived prometheus.Gauge
sctpBytesSent prometheus.Gauge
@ -104,6 +109,34 @@ func (m *metricsCtx) getBySession(session types.Session) metrics {
},
}),
receiverReportDelay: promauto.NewGauge(prometheus.GaugeOpts{
Name: "receiver_report_delay",
Namespace: "neko",
Subsystem: "webrtc",
Help: "Receiver Report Delay from SCTP, expressed in units of 1/65536 seconds.",
ConstLabels: map[string]string{
"session_id": session.ID(),
},
}),
receiverReportJitter: promauto.NewGauge(prometheus.GaugeOpts{
Name: "receiver_report_jitter",
Namespace: "neko",
Subsystem: "webrtc",
Help: "Receiver Report Jitter from SCTP.",
ConstLabels: map[string]string{
"session_id": session.ID(),
},
}),
receiverReportTotalLost: promauto.NewGauge(prometheus.GaugeOpts{
Name: "receiver_report_total_lost",
Namespace: "neko",
Subsystem: "webrtc",
Help: "Receiver Report Total Lost from SCTP.",
ConstLabels: map[string]string{
"session_id": session.ID(),
},
}),
iceBytesSent: promauto.NewGauge(prometheus.GaugeOpts{
Name: "bytes_sent",
Namespace: "neko",
@ -227,6 +260,14 @@ func (m *metricsCtx) SetReceiverEstimatedMaximumBitrate(session types.Session, b
met.receiverEstimatedMaximumBitrate.Set(float64(bitrate))
}
func (m *metricsCtx) SetReceiverReport(session types.Session, report rtcp.ReceptionReport) {
met := m.getBySession(session)
met.receiverReportDelay.Set(float64(report.Delay))
met.receiverReportJitter.Set(float64(report.Jitter))
met.receiverReportTotalLost.Set(float64(report.TotalLost))
}
func (m *metricsCtx) SetIceTransportStats(session types.Session, data webrtc.TransportStats) {
met := m.getBySession(session)