44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/collectors"
|
|
)
|
|
|
|
type MetricsContainer struct {
|
|
Registry *prometheus.Registry
|
|
LiveConnectionsGauge prometheus.Gauge
|
|
RaiseGestureCounter *prometheus.CounterVec
|
|
SpeakerCounter *prometheus.CounterVec
|
|
}
|
|
|
|
const GestureNameLabel string = "gestureString"
|
|
|
|
func SetupMetrics() MetricsContainer {
|
|
registry := prometheus.NewRegistry()
|
|
liveConnectionsGauge := prometheus.NewGauge(prometheus.GaugeOpts{
|
|
Name: "live_connections_total",
|
|
Help: "Total amount of live SSE subscriptions to room state",
|
|
})
|
|
raiseGestureCounter := prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
Name: "raise_gesture_total",
|
|
Help: "Total amount of raised hands",
|
|
}, []string{GestureNameLabel})
|
|
speakerCounter := prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
Name: "speaker_total",
|
|
Help: "Total amount of speaker turns",
|
|
}, []string{GestureNameLabel})
|
|
|
|
registry.MustRegister(liveConnectionsGauge, raiseGestureCounter, speakerCounter,
|
|
collectors.NewGoCollector(),
|
|
collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
|
|
)
|
|
|
|
return MetricsContainer{
|
|
Registry: registry,
|
|
LiveConnectionsGauge: liveConnectionsGauge,
|
|
RaiseGestureCounter: raiseGestureCounter,
|
|
SpeakerCounter: speakerCounter,
|
|
}
|
|
}
|