add session start time metric (#2377)
This commit is contained in:
@@ -97,6 +97,7 @@ type ParticipantParams struct {
|
|||||||
AudioConfig config.AudioConfig
|
AudioConfig config.AudioConfig
|
||||||
VideoConfig config.VideoConfig
|
VideoConfig config.VideoConfig
|
||||||
ProtocolVersion types.ProtocolVersion
|
ProtocolVersion types.ProtocolVersion
|
||||||
|
SessionStartTime time.Time
|
||||||
Telemetry telemetry.TelemetryService
|
Telemetry telemetry.TelemetryService
|
||||||
Trailer []byte
|
Trailer []byte
|
||||||
PLIThrottleConfig config.PLIThrottleConfig
|
PLIThrottleConfig config.PLIThrottleConfig
|
||||||
@@ -1421,6 +1422,7 @@ func (p *ParticipantImpl) onPrimaryTransportInitialConnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) onPrimaryTransportFullyEstablished() {
|
func (p *ParticipantImpl) onPrimaryTransportFullyEstablished() {
|
||||||
|
prometheus.RecordSessionStartTime(int(p.ProtocolVersion()), time.Since(p.params.SessionStartTime))
|
||||||
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -753,6 +753,7 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
|
|||||||
Config: rtcConf,
|
Config: rtcConf,
|
||||||
Sink: &routingfakes.FakeMessageSink{},
|
Sink: &routingfakes.FakeMessageSink{},
|
||||||
ProtocolVersion: opts.protocolVersion,
|
ProtocolVersion: opts.protocolVersion,
|
||||||
|
SessionStartTime: time.Now(),
|
||||||
PLIThrottleConfig: conf.RTC.PLIThrottle,
|
PLIThrottleConfig: conf.RTC.PLIThrottle,
|
||||||
Grants: grants,
|
Grants: grants,
|
||||||
PublishEnabledCodecs: enabledCodecs,
|
PublishEnabledCodecs: enabledCodecs,
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ func (r *RoomManager) StartSession(
|
|||||||
requestSource routing.MessageSource,
|
requestSource routing.MessageSource,
|
||||||
responseSink routing.MessageSink,
|
responseSink routing.MessageSink,
|
||||||
) error {
|
) error {
|
||||||
|
sessionStartTime := time.Now()
|
||||||
|
|
||||||
room, err := r.getOrCreateRoom(ctx, roomName)
|
room, err := r.getOrCreateRoom(ctx, roomName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -390,6 +392,7 @@ func (r *RoomManager) StartSession(
|
|||||||
AudioConfig: r.config.Audio,
|
AudioConfig: r.config.Audio,
|
||||||
VideoConfig: r.config.Video,
|
VideoConfig: r.config.Video,
|
||||||
ProtocolVersion: pv,
|
ProtocolVersion: pv,
|
||||||
|
SessionStartTime: sessionStartTime,
|
||||||
Telemetry: r.telemetry,
|
Telemetry: r.telemetry,
|
||||||
Trailer: room.Trailer(),
|
Trailer: room.Trailer(),
|
||||||
PLIThrottleConfig: r.config.RTC.PLIThrottle,
|
PLIThrottleConfig: r.config.RTC.PLIThrottle,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package prometheus
|
package prometheus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -43,6 +44,7 @@ var (
|
|||||||
promTrackSubscribedCurrent *prometheus.GaugeVec
|
promTrackSubscribedCurrent *prometheus.GaugeVec
|
||||||
promTrackPublishCounter *prometheus.CounterVec
|
promTrackPublishCounter *prometheus.CounterVec
|
||||||
promTrackSubscribeCounter *prometheus.CounterVec
|
promTrackSubscribeCounter *prometheus.CounterVec
|
||||||
|
promSessionStartTime prometheus.HistogramVec
|
||||||
)
|
)
|
||||||
|
|
||||||
func initRoomStats(nodeID string, nodeType livekit.NodeType, env string) {
|
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",
|
Name: "subscribe_counter",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String(), "env": env},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String(), "env": env},
|
||||||
}, []string{"state", "error"})
|
}, []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(promRoomCurrent)
|
||||||
prometheus.MustRegister(promRoomDuration)
|
prometheus.MustRegister(promRoomDuration)
|
||||||
@@ -99,6 +108,7 @@ func initRoomStats(nodeID string, nodeType livekit.NodeType, env string) {
|
|||||||
prometheus.MustRegister(promTrackSubscribedCurrent)
|
prometheus.MustRegister(promTrackSubscribedCurrent)
|
||||||
prometheus.MustRegister(promTrackPublishCounter)
|
prometheus.MustRegister(promTrackPublishCounter)
|
||||||
prometheus.MustRegister(promTrackSubscribeCounter)
|
prometheus.MustRegister(promTrackSubscribeCounter)
|
||||||
|
prometheus.MustRegister(promSessionStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RoomStarted() {
|
func RoomStarted() {
|
||||||
@@ -172,3 +182,7 @@ func RecordTrackSubscribeFailure(err error, isUserError bool) {
|
|||||||
trackSubscribeUserError.Inc()
|
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