Add sdk lable to session start time and participant join (#4885)

This commit is contained in:
cnderrauber authored and GitHub committed 2026-09-21 13:14:36 +08:00
1 parent d5c691836f
commit 885c869ffa
5 files changed
+32 -32

No files matched your search

+4 -4
View File
@@ -1480,9 +1480,9 @@ func (p *ParticipantImpl) recordRTCState(closeReason types.ParticipantCloseReaso
}
if p.IsConnectionCanceled(closeReason) {
prometheus.IncrementParticipantRtcCanceled(1, p.params.EnableWarp)
prometheus.IncrementParticipantRtcCanceled(1, p.params.EnableWarp, p.GetClientInfo().GetSdk())
} else {
prometheus.IncrementParticipantRtcFailure(1, p.params.EnableWarp)
prometheus.IncrementParticipantRtcFailure(1, p.params.EnableWarp, p.GetClientInfo().GetSdk())
}
}
@@ -2718,8 +2718,8 @@ func (p *ParticipantImpl) onPrimaryTransportInitialConnected() {
}
if !p.sessionStartRecorded.Swap(true) {
prometheus.RecordSessionStartTime(int(p.ProtocolVersion()), p.params.EnableWarp, time.Since(p.params.SessionStartTime))
prometheus.IncrementParticipantRtcSuccess(1, p.params.EnableWarp)
prometheus.RecordSessionStartTime(int(p.ProtocolVersion()), p.params.EnableWarp, p.GetClientInfo().GetSdk(), time.Since(p.params.SessionStartTime))
prometheus.IncrementParticipantRtcSuccess(1, p.params.EnableWarp, p.GetClientInfo().GetSdk())
}
p.updateState(livekit.ParticipantInfo_ACTIVE)
}
+8 -8
View File
@@ -306,7 +306,7 @@ func (r *RoomManager) StartSession(
room, err := r.getOrCreateRoom(ctx, createRoom)
if err != nil {
if pi.Identity != "" {
prometheus.IncrementParticipantRtcCanceled(1, false)
prometheus.IncrementParticipantRtcCanceled(1, false, pi.Client.GetSdk())
}
return err
}
@@ -359,7 +359,7 @@ func (r *RoomManager) StartSession(
Leave: leave,
},
})
prometheus.IncrementParticipantRtcCanceled(1, participant.IsWarpEnabled())
prometheus.IncrementParticipantRtcCanceled(1, participant.IsWarpEnabled(), participant.GetClientInfo().GetSdk())
return errors.New("could not restart closed participant")
}
@@ -383,7 +383,7 @@ func (r *RoomManager) StartSession(
pi.ReconnectReason,
); err != nil {
participant.GetLogger().Warnw("could not resume participant", err)
prometheus.IncrementParticipantRtcCanceled(1, participant.IsWarpEnabled())
prometheus.IncrementParticipantRtcCanceled(1, participant.IsWarpEnabled(), participant.GetClientInfo().GetSdk())
return err
}
r.telemetry.ParticipantResumed(ctx, room.ToProto(), participant.ToProto(), r.currentNode.NodeID(), pi.ReconnectReason)
@@ -419,7 +419,7 @@ func (r *RoomManager) StartSession(
Leave: leave,
},
})
prometheus.IncrementParticipantRtcCanceled(1, false)
prometheus.IncrementParticipantRtcCanceled(1, false, pi.Client.GetSdk())
return errors.New("could not restart participant")
}
@@ -545,7 +545,7 @@ func (r *RoomManager) StartSession(
EnableWarp: enableWarp,
})
if err != nil {
prometheus.IncrementParticipantRtcCanceled(1, enableWarp)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp, pi.Client.GetSdk())
return err
}
iceConfig := r.setIceConfig(room.Name(), participant)
@@ -561,7 +561,7 @@ func (r *RoomManager) StartSession(
if err = room.Join(participant, requestSource, &opts, iceServers); err != nil {
pLogger.Errorw("could not join room", err)
_ = participant.Close(true, types.ParticipantCloseReasonJoinFailed, false)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp, pi.Client.GetSdk())
return err
}
@@ -573,7 +573,7 @@ func (r *RoomManager) StartSession(
participantServerClosers.Close()
pLogger.Errorw("could not join register participant topic", err)
_ = participant.Close(true, types.ParticipantCloseReasonMessageBusFailed, false)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp, pi.Client.GetSdk())
return err
}
@@ -584,7 +584,7 @@ func (r *RoomManager) StartSession(
participantServerClosers.Close()
pLogger.Errorw("could not join register participant topic for rtc rest participant server", err)
_ = participant.Close(true, types.ParticipantCloseReasonMessageBusFailed, false)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp)
prometheus.IncrementParticipantRtcCanceled(1, enableWarp, pi.Client.GetSdk())
return err
}
}
+1 -1
View File
@@ -94,7 +94,7 @@ func (t *telemetryService) ParticipantJoined(
guard,
)
if !found {
prometheus.IncrementParticipantRtcConnected(1)
prometheus.IncrementParticipantRtcConnected(1, clientInfo.GetSdk())
prometheus.AddParticipant()
}
+16 -16
View File
@@ -151,7 +151,7 @@ func initPacketStats(nodeID string, nodeType livekit.NodeType) {
Subsystem: "participant_join",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, []string{"state", "warp"})
}, []string{"state", "warp", "sdk"})
promConnections = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: livekitNamespace,
Subsystem: "connection",
@@ -299,72 +299,72 @@ func RecordRTT(country string, direction Direction, trackSource livekit.TrackSou
func IncrementParticipantJoin(join uint32) {
if join > 0 {
participantSignalConnected.Add(uint64(join))
promParticipantJoin.WithLabelValues("signal_connected", "").Add(float64(join))
promParticipantJoin.WithLabelValues("signal_connected", "", "").Add(float64(join))
}
}
func IncrementParticipantJoinFail(fail uint32) {
if fail > 0 {
promParticipantJoin.WithLabelValues("signal_failed", "").Add(float64(fail))
promParticipantJoin.WithLabelValues("signal_failed", "", "").Add(float64(fail))
}
}
func IncrementParticipantJoinValidationFail(validationFail uint32) {
if validationFail > 0 {
promParticipantJoin.WithLabelValues("signal_validation_failed", "").Add(float64(validationFail))
promParticipantJoin.WithLabelValues("signal_validation_failed", "", "").Add(float64(validationFail))
}
}
func IncrementParticipantJoinUpgradeFail(upgradeFail uint32) {
if upgradeFail > 0 {
promParticipantJoin.WithLabelValues("signal_upgrade_failed", "").Add(float64(upgradeFail))
promParticipantJoin.WithLabelValues("signal_upgrade_failed", "", "").Add(float64(upgradeFail))
}
}
func IncrementParticipantJoinWriteInitialResponseFail(writeInitialResponseFail uint32) {
if writeInitialResponseFail > 0 {
promParticipantJoin.WithLabelValues("signal_write_initial_response_failed", "").Add(float64(writeInitialResponseFail))
promParticipantJoin.WithLabelValues("signal_write_initial_response_failed", "", "").Add(float64(writeInitialResponseFail))
}
}
func IncrementParticipantRtcInit(init uint32) {
if init > 0 {
participantRTCInit.Add(uint64(init))
promParticipantJoin.WithLabelValues("rtc_init", "").Add(float64(init))
promParticipantJoin.WithLabelValues("rtc_init", "", "").Add(float64(init))
}
}
func IncrementParticipantRtcConnected(connected uint32) {
func IncrementParticipantRtcConnected(connected uint32, sdk livekit.ClientInfo_SDK) {
if connected > 0 {
participantRTCConnected.Add(uint64(connected))
promParticipantJoin.WithLabelValues("rtc_connected", "").Add(float64(connected))
promParticipantJoin.WithLabelValues("rtc_connected", "", sdk.String()).Add(float64(connected))
}
}
func IncrementParticipantRtcActive(active uint32, warp bool) {
if active > 0 {
participantRTCActive.Add(uint64(active))
promParticipantJoin.WithLabelValues("rtc_active", strconv.FormatBool(warp)).Add(float64(active))
promParticipantJoin.WithLabelValues("rtc_active", strconv.FormatBool(warp), "").Add(float64(active))
}
}
func IncrementParticipantRtcCanceled(canceled uint64, warp bool) {
func IncrementParticipantRtcCanceled(canceled uint64, warp bool, sdk livekit.ClientInfo_SDK) {
if canceled > 0 {
participantRTCCanceled.Add(canceled)
promParticipantJoin.WithLabelValues("rtc_canceled", strconv.FormatBool(warp)).Add(float64(canceled))
promParticipantJoin.WithLabelValues("rtc_canceled", strconv.FormatBool(warp), sdk.String()).Add(float64(canceled))
}
}
// todo: check if need to record warp to rtcSucc/Failure
func IncrementParticipantRtcSuccess(success uint64, warp bool) {
func IncrementParticipantRtcSuccess(success uint64, warp bool, sdk livekit.ClientInfo_SDK) {
if success > 0 {
promParticipantJoin.WithLabelValues("rtc_success", strconv.FormatBool(warp)).Add(float64(success))
promParticipantJoin.WithLabelValues("rtc_success", strconv.FormatBool(warp), sdk.String()).Add(float64(success))
}
}
func IncrementParticipantRtcFailure(failure uint64, warp bool) {
func IncrementParticipantRtcFailure(failure uint64, warp bool, sdk livekit.ClientInfo_SDK) {
if failure > 0 {
promParticipantJoin.WithLabelValues("rtc_failure", strconv.FormatBool(warp)).Add(float64(failure))
promParticipantJoin.WithLabelValues("rtc_failure", strconv.FormatBool(warp), sdk.String()).Add(float64(failure))
}
}
+3 -3
View File
@@ -113,7 +113,7 @@ func initRoomStats(nodeID string, nodeType livekit.NodeType) {
Name: "start_time_ms",
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
Buckets: prometheus.ExponentialBucketsRange(100, 10000, 15),
}, []string{"protocol_version", "warp"})
}, []string{"protocol_version", "warp", "sdk"})
promSessionDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: livekitNamespace,
Subsystem: "session",
@@ -291,8 +291,8 @@ func RecordSessionJoinLatency(protocolVersion int, d time.Duration) {
promSessionJoinLatency.WithLabelValues(strconv.Itoa(protocolVersion)).Observe(float64(d.Milliseconds()))
}
func RecordSessionStartTime(protocolVersion int, warp bool, d time.Duration) {
promSessionStartTime.WithLabelValues(strconv.Itoa(protocolVersion), strconv.FormatBool(warp)).Observe(float64(d.Milliseconds()))
func RecordSessionStartTime(protocolVersion int, warp bool, sdk livekit.ClientInfo_SDK, d time.Duration) {
promSessionStartTime.WithLabelValues(strconv.Itoa(protocolVersion), strconv.FormatBool(warp), sdk.String()).Observe(float64(d.Milliseconds()))
}
func RecordSessionDuration(protocolVersion int, d time.Duration) {