From 1e2da70122e26204423880aab05531ccf5ed7618 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 19 Feb 2024 10:19:55 +0530 Subject: [PATCH] Filter out context canceled errors from logging (#2492) * Filter out context canceled errors from logging * move a few more warns to debug --- pkg/rtc/participant.go | 6 +++--- pkg/service/utils.go | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 87201780a..247fd454d 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -1864,7 +1864,7 @@ func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) *li } if !isPending && track == nil { - p.pubLogger.Warnw("could not locate track", nil, "trackID", trackID) + p.pubLogger.Debugw("could not locate track", "trackID", trackID) } return trackInfo @@ -2379,7 +2379,7 @@ func (p *ParticipantImpl) onAnyTransportNegotiationFailed() { func (p *ParticipantImpl) UpdateSubscribedQuality(nodeID livekit.NodeID, trackID livekit.TrackID, maxQualities []types.SubscribedCodecQuality) error { track := p.GetPublishedTrack(trackID) if track == nil { - p.pubLogger.Warnw("could not find track", nil, "trackID", trackID) + p.pubLogger.Debugw("could not find track", "trackID", trackID) return errors.New("could not find published track") } @@ -2390,7 +2390,7 @@ func (p *ParticipantImpl) UpdateSubscribedQuality(nodeID livekit.NodeID, trackID func (p *ParticipantImpl) UpdateMediaLoss(nodeID livekit.NodeID, trackID livekit.TrackID, fractionalLoss uint32) error { track := p.GetPublishedTrack(trackID) if track == nil { - p.pubLogger.Warnw("could not find track", nil, "trackID", trackID) + p.pubLogger.Debugw("could not find track", "trackID", trackID) return errors.New("could not find published track") } diff --git a/pkg/service/utils.go b/pkg/service/utils.go index 2d1bafd4e..7ce0e7bc4 100644 --- a/pkg/service/utils.go +++ b/pkg/service/utils.go @@ -15,6 +15,8 @@ package service import ( + "context" + "errors" "net" "net/http" "regexp" @@ -27,7 +29,9 @@ func handleError(w http.ResponseWriter, r *http.Request, status int, err error, if r != nil && r.URL != nil { keysAndValues = append(keysAndValues, "method", r.Method, "path", r.URL.Path) } - logger.GetLogger().WithCallDepth(1).Warnw("error handling request", err, keysAndValues...) + if !errors.Is(err, context.Canceled) { + logger.GetLogger().WithCallDepth(1).Warnw("error handling request", err, keysAndValues...) + } w.WriteHeader(status) _, _ = w.Write([]byte(err.Error())) }