Log join duration. (#4433)
* Log join duration. Also revert the "unresolved" init. Defeated the purpose of log resolver as it was resolving with those values even if not forced. Instead set it to "unresolved" if not set when forced. Join duration is not reset if resolver is reset as that happens on moving a participant and there is no new join duration in that case. * explode
This commit is contained in:
@@ -289,11 +289,13 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
return
|
||||
}
|
||||
|
||||
startedAt := time.Now()
|
||||
var (
|
||||
roomName livekit.RoomName = "unresolved"
|
||||
roomID livekit.RoomID = "unresolved"
|
||||
participantIdentity livekit.ParticipantIdentity = "unresolved"
|
||||
pID livekit.ParticipantID = "unresolved"
|
||||
roomName livekit.RoomName
|
||||
roomID livekit.RoomID
|
||||
participantIdentity livekit.ParticipantIdentity
|
||||
pID livekit.ParticipantID
|
||||
joinDuration time.Duration
|
||||
loggerResolved bool
|
||||
|
||||
pi routing.ParticipantInit
|
||||
@@ -309,6 +311,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
"roomID", roomID,
|
||||
"participant", participantIdentity,
|
||||
"participantID", pID,
|
||||
"joinDuration", joinDuration,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +320,25 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
return
|
||||
}
|
||||
|
||||
if force || (roomName != "" && roomID != "" && participantIdentity != "" && pID != "") {
|
||||
if force {
|
||||
if roomName == "" {
|
||||
roomName = "unresolved"
|
||||
}
|
||||
if roomID == "" {
|
||||
roomID = "unresolved"
|
||||
}
|
||||
if participantIdentity == "" {
|
||||
participantIdentity = "unresolved"
|
||||
}
|
||||
if pID == "" {
|
||||
pID = "unresolved"
|
||||
}
|
||||
if joinDuration == 0 {
|
||||
joinDuration = time.Since(startedAt)
|
||||
}
|
||||
}
|
||||
|
||||
if roomName != "" && roomID != "" && participantIdentity != "" && pID != "" {
|
||||
loggerResolved = true
|
||||
loggerResolver.Resolve(getLoggerFields()...)
|
||||
}
|
||||
@@ -335,6 +356,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
|
||||
roomName, pi, code, err = s.validateInternal(pLogger, r, needsJoinRequest, false)
|
||||
if err != nil {
|
||||
resolveLogger(true)
|
||||
HandleError(w, r, code, err, getLoggerFields()...)
|
||||
return
|
||||
}
|
||||
@@ -343,7 +365,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
if pi.ID != "" {
|
||||
pID = pi.ID
|
||||
}
|
||||
pLogger.Debugw("join request validated", append(getLoggerFields(), "participantInit", &pi))
|
||||
pLogger.Debugw("join request validated", append(getLoggerFields(), "participantInit", &pi)...)
|
||||
|
||||
// give it a few attempts to start session
|
||||
var cr connectionResult
|
||||
@@ -364,11 +386,13 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
if errors.As(err, &psrpcErr) {
|
||||
status = psrpcErr.ToHttp()
|
||||
}
|
||||
resolveLogger(true)
|
||||
HandleError(w, r, status, err, getLoggerFields()...)
|
||||
return
|
||||
}
|
||||
|
||||
prometheus.IncrementParticipantJoin(1)
|
||||
joinDuration = time.Since(startedAt)
|
||||
|
||||
pLogger = pLogger.WithValues("connID", cr.ConnectionID)
|
||||
if !pi.Reconnect && initialResponse.GetJoin() != nil {
|
||||
@@ -399,6 +423,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
done := make(chan struct{})
|
||||
// function exits when websocket terminates, it'll close the event reading off of request sink and response source as well
|
||||
defer func() {
|
||||
resolveLogger(true)
|
||||
pLogger.Debugw("finishing WS connection", "closedByClient", closedByClient.Load())
|
||||
cr.ResponseSource.Close()
|
||||
cr.RequestSink.Close()
|
||||
@@ -410,6 +435,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
|
||||
// upgrade only once the basics are good to go
|
||||
conn, err := s.upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
resolveLogger(true)
|
||||
HandleError(w, r, http.StatusInternalServerError, err, getLoggerFields()...)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user