add session start time metric (#2377)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -43,6 +44,7 @@ var (
|
||||
promTrackSubscribedCurrent *prometheus.GaugeVec
|
||||
promTrackPublishCounter *prometheus.CounterVec
|
||||
promTrackSubscribeCounter *prometheus.CounterVec
|
||||
promSessionStartTime prometheus.HistogramVec
|
||||
)
|
||||
|
||||
func initRoomStats(nodeID string, nodeType livekit.NodeType, env string) {
|
||||
@@ -91,6 +93,13 @@ func initRoomStats(nodeID string, nodeType livekit.NodeType, env string) {
|
||||
Name: "subscribe_counter",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String(), "env": env},
|
||||
}, []string{"state", "error"})
|
||||
promSessionStartTime = *prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "session",
|
||||
Name: "start_time_ms",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String(), "env": env},
|
||||
Buckets: prometheus.ExponentialBucketsRange(100, 5000, 10),
|
||||
}, []string{"protocol_version"})
|
||||
|
||||
prometheus.MustRegister(promRoomCurrent)
|
||||
prometheus.MustRegister(promRoomDuration)
|
||||
@@ -99,6 +108,7 @@ func initRoomStats(nodeID string, nodeType livekit.NodeType, env string) {
|
||||
prometheus.MustRegister(promTrackSubscribedCurrent)
|
||||
prometheus.MustRegister(promTrackPublishCounter)
|
||||
prometheus.MustRegister(promTrackSubscribeCounter)
|
||||
prometheus.MustRegister(promSessionStartTime)
|
||||
}
|
||||
|
||||
func RoomStarted() {
|
||||
@@ -172,3 +182,7 @@ func RecordTrackSubscribeFailure(err error, isUserError bool) {
|
||||
trackSubscribeUserError.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
func RecordSessionStartTime(protocolVersion int, d time.Duration) {
|
||||
promSessionStartTime.WithLabelValues(strconv.Itoa(protocolVersion)).Observe(float64(d.Milliseconds()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user