Don't flood Sentry with context cancelled/deadline exceeded errors (#2115)

This commit is contained in:
Neil Alexander 2022-01-28 10:27:28 +00:00 committed by GitHub
parent 2f72688e9a
commit 48789ebec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,7 @@ package input
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"sync" "sync"
"time" "time"
@ -101,9 +102,11 @@ func (r *Inputer) Start() error {
defer eventsInProgress.Delete(index) defer eventsInProgress.Delete(index)
defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": roomID}).Dec() defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": roomID}).Dec()
if err := r.processRoomEvent(context.Background(), &inputRoomEvent); err != nil { if err := r.processRoomEvent(context.Background(), &inputRoomEvent); err != nil {
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
sentry.CaptureException(err) sentry.CaptureException(err)
}
} else { } else {
hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event) go hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event)
} }
_ = msg.Ack() _ = msg.Ack()
}) })
@ -170,9 +173,11 @@ func (r *Inputer) InputRoomEvents(
defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": roomID}).Dec() defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": roomID}).Dec()
err := r.processRoomEvent(ctx, &inputRoomEvent) err := r.processRoomEvent(ctx, &inputRoomEvent)
if err != nil { if err != nil {
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
sentry.CaptureException(err) sentry.CaptureException(err)
}
} else { } else {
hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event) go hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event)
} }
select { select {
case <-ctx.Done(): case <-ctx.Done():