feat: custom gesture & room metrics
This commit is contained in:
43
metrics/metrics.go
Normal file
43
metrics/metrics.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user