From 48789ebec526a7c61a9b9bc3a10949fbc45711ab Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 28 Jan 2022 10:27:28 +0000 Subject: [PATCH] Don't flood Sentry with context cancelled/deadline exceeded errors (#2115) --- roomserver/internal/input/input.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/roomserver/internal/input/input.go b/roomserver/internal/input/input.go index 9601e018..e0ddd07c 100644 --- a/roomserver/internal/input/input.go +++ b/roomserver/internal/input/input.go @@ -18,6 +18,7 @@ package input import ( "context" "encoding/json" + "errors" "sync" "time" @@ -101,9 +102,11 @@ func (r *Inputer) Start() error { defer eventsInProgress.Delete(index) defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": roomID}).Dec() if err := r.processRoomEvent(context.Background(), &inputRoomEvent); err != nil { - sentry.CaptureException(err) + if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) { + sentry.CaptureException(err) + } } else { - hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event) + go hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event) } _ = msg.Ack() }) @@ -170,9 +173,11 @@ func (r *Inputer) InputRoomEvents( defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": roomID}).Dec() err := r.processRoomEvent(ctx, &inputRoomEvent) if err != nil { - sentry.CaptureException(err) + if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) { + sentry.CaptureException(err) + } } else { - hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event) + go hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event) } select { case <-ctx.Done():