mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-19 05:21:09 +00:00
metrics: expose state of WebRTC sessions (#2662)
This commit is contained in:
parent
f82c6e3654
commit
cb04d28f6e
@ -1487,7 +1487,7 @@ srt_conns_bytes_received{id="[id]",state="[state]"} 1234
|
||||
srt_conns_bytes_sent{id="[id]",state="[state]"} 187
|
||||
|
||||
# metrics of every WebRTC session
|
||||
webrtc_sessions{id="[id]"} 1
|
||||
webrtc_sessions{id="[id]",state="[state]"} 1
|
||||
webrtc_sessions_bytes_received{id="[id]",state="[state]"} 1234
|
||||
webrtc_sessions_bytes_sent{id="[id]",state="[state]"} 187
|
||||
```
|
||||
|
@ -221,7 +221,7 @@ func (m *metrics) onMetrics(ctx *gin.Context) {
|
||||
data, err := m.webRTCManager.apiSessionsList()
|
||||
if err == nil && len(data.Items) != 0 {
|
||||
for _, i := range data.Items {
|
||||
tags := "{id=\"" + i.ID.String() + "\"}"
|
||||
tags := "{id=\"" + i.ID.String() + "\",state=\"" + string(i.State) + "\"}"
|
||||
out += metric("webrtc_sessions", tags, 1)
|
||||
out += metric("webrtc_sessions_bytes_received", tags, int64(i.BytesReceived))
|
||||
out += metric("webrtc_sessions_bytes_sent", tags, int64(i.BytesSent))
|
||||
|
@ -220,11 +220,11 @@ webrtc_sessions_bytes_sent 0
|
||||
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} [0-9]+`+"\n"+
|
||||
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} [0-9]+`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
||||
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} [0-9]+`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
||||
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} [0-9]+`+"\n"+
|
||||
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
||||
`rtsp_conns\{id=".*?"\} 1`+"\n"+
|
||||
`rtsp_conns_bytes_received\{id=".*?"\} [0-9]+`+"\n"+
|
||||
`rtsp_conns_bytes_sent\{id=".*?"\} [0-9]+`+"\n"+
|
||||
@ -243,9 +243,9 @@ webrtc_sessions_bytes_sent 0
|
||||
`srt_conns\{id=".*?",state="publish"\} 1`+"\n"+
|
||||
`srt_conns_bytes_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||
`srt_conns_bytes_sent\{id=".*?",state="publish"\} 0`+"\n"+
|
||||
`webrtc_sessions\{id=".*?"\} 1`+"\n"+
|
||||
`webrtc_sessions_bytes_received\{id=".*?"\} [0-9]+`+"\n"+
|
||||
`webrtc_sessions_bytes_sent\{id=".*?"\} [0-9]+`+"\n"+
|
||||
`webrtc_sessions\{id=".*?",state="publish"\} 1`+"\n"+
|
||||
`webrtc_sessions_bytes_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||
`webrtc_sessions_bytes_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||
"$",
|
||||
string(bo))
|
||||
|
||||
|
@ -119,7 +119,7 @@ var testMediaH264 = &description.Media{
|
||||
}},
|
||||
}
|
||||
|
||||
func TestRTSPSource(t *testing.T) {
|
||||
func TestSource(t *testing.T) {
|
||||
for _, source := range []string{
|
||||
"udp",
|
||||
"tcp",
|
||||
|
Loading…
Reference in New Issue
Block a user