mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-27 06:38:44 +02:00
Store connected viewers in Prometheus and serve this amount
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user