1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-27 19:12:07 +02:00

Store connected viewers in Prometheus and serve this amount

This commit is contained in:
Yohann D'ANELLO
2020-09-29 18:03:28 +02:00
parent c49b5eeb2b
commit 2005f3ece1
6 changed files with 31 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
dto "github.com/prometheus/client_model/go"
)
// Options holds web package configuration
@ -26,8 +27,23 @@ var (
Name: "ghostream_web_sessions_total",
Help: "The total amount of WebRTC sessions exchanged",
})
// WebRTCConnectedSessions is the total amount of WebRTC session exchange
WebRTCConnectedSessions = promauto.NewGauge(prometheus.GaugeOpts{
Name: "ghostream_webrtc_connected_sessions",
Help: "The current amount of opened WebRTC sessions",
})
)
func GetGaugeValue(metric prometheus.Gauge) float64 {
var m = &dto.Metric{}
if err := metric.Write(m); err != nil {
log.Fatal(err)
return 0
}
return m.Gauge.GetValue()
}
// Serve monitoring server that expose prometheus metrics
func Serve(cfg *Options) {
mux := http.NewServeMux()