Add metrics for Janus slow link events.

This commit is contained in:
Joachim Bauch 2025-11-13 14:20:28 +01:00
commit 1f0ed8005a
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
3 changed files with 17 additions and 0 deletions

View file

@ -65,3 +65,4 @@ The following metrics are available:
| `signaling_mcu_peerconnection_state_total` | Counter | 2.0.5 | Total number PeerConnection states | `state`, `reason` |
| `signaling_mcu_ice_state_total` | Counter | 2.0.5 | Total number of ICE connection states | `state` |
| `signaling_mcu_dtls_state_total` | Counter | 2.0.5 | Total number of DTLS connection states | `state` |
| `signaling_mcu_slow_link_total` | Counter | 2.0.5 | Total number of slow link events | `media`, `direction` |

View file

@ -747,6 +747,15 @@ func (h *JanusEventsHandler) processEvent(event JanusEvent) {
case *JanusEventWebRTCSelectedPair:
statsJanusSelectedLocalCandidateTotal.WithLabelValues(evt.Candidates.Local.Type, evt.Candidates.Local.Transport, fmt.Sprintf("ipv%d", evt.Candidates.Local.Family)).Inc()
statsJanusSelectedRemoteCandidateTotal.WithLabelValues(evt.Candidates.Remote.Type, evt.Candidates.Remote.Transport, fmt.Sprintf("ipv%d", evt.Candidates.Remote.Family)).Inc()
case *JanusEventMediaSlowLink:
var direction string
// "uplink" is Janus -> client, "downlink" is client -> Janus.
if evt.SlowLink == "uplink" {
direction = "outgoing"
} else {
direction = "incoming"
}
statsJanusSlowLinkTotal.WithLabelValues(evt.Media, direction).Inc()
case *JanusEventMediaStats:
h.mcu.UpdateBandwidth(event.HandleId, evt.Media, api.BandwidthFromBytes(uint64(evt.BytesSentLastSec)), api.BandwidthFromBytes(uint64(evt.BytesReceivedLastSec)))
}

View file

@ -122,6 +122,12 @@ var (
Name: "dtls_state_total",
Help: "Total number of DTLS connection states",
}, []string{"state"})
statsJanusSlowLinkTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "signaling",
Subsystem: "mcu",
Name: "slow_link_total",
Help: "Total number of slow link events",
}, []string{"media", "direction"})
janusMcuStats = []prometheus.Collector{
statsJanusBandwidthCurrent,
@ -130,6 +136,7 @@ var (
statsJanusPeerConnectionStateTotal,
statsJanusICEStateTotal,
statsJanusDTLSStateTotal,
statsJanusSlowLinkTotal,
}
statsConnectedProxyBackendsCurrent = prometheus.NewGaugeVec(prometheus.GaugeOpts{