mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 05:12:26 +03:00
Update sentry reporting (#3305)
This hopefully reduces the garbage we currently produce. (Using [GlitchTip](https://glitchtip.com/) on my personal instance, this seems to look better)
This commit is contained in:
parent
8e4dc6b4ae
commit
d58daf9665
5 changed files with 16 additions and 7 deletions
|
@ -108,12 +108,14 @@ type worker struct {
|
|||
r *Inputer
|
||||
roomID string
|
||||
subscription *nats.Subscription
|
||||
sentryHub *sentry.Hub
|
||||
}
|
||||
|
||||
func (r *Inputer) startWorkerForRoom(roomID string) {
|
||||
v, loaded := r.workers.LoadOrStore(roomID, &worker{
|
||||
r: r,
|
||||
roomID: roomID,
|
||||
r: r,
|
||||
roomID: roomID,
|
||||
sentryHub: sentry.CurrentHub().Clone(),
|
||||
})
|
||||
w := v.(*worker)
|
||||
w.Lock()
|
||||
|
@ -265,9 +267,9 @@ func (w *worker) _next() {
|
|||
// Look up what the next event is that's waiting to be processed.
|
||||
ctx, cancel := context.WithTimeout(w.r.ProcessContext.Context(), time.Minute)
|
||||
defer cancel()
|
||||
if scope := sentry.CurrentHub().Scope(); scope != nil {
|
||||
w.sentryHub.ConfigureScope(func(scope *sentry.Scope) {
|
||||
scope.SetTag("room_id", w.roomID)
|
||||
}
|
||||
})
|
||||
msgs, err := w.subscription.Fetch(1, nats.Context(ctx))
|
||||
switch err {
|
||||
case nil:
|
||||
|
@ -323,9 +325,9 @@ func (w *worker) _next() {
|
|||
return
|
||||
}
|
||||
|
||||
if scope := sentry.CurrentHub().Scope(); scope != nil {
|
||||
w.sentryHub.ConfigureScope(func(scope *sentry.Scope) {
|
||||
scope.SetTag("event_id", inputRoomEvent.Event.EventID())
|
||||
}
|
||||
})
|
||||
|
||||
// Process the room event. If something goes wrong then we'll tell
|
||||
// NATS to terminate the message. We'll store the error result as
|
||||
|
@ -347,7 +349,7 @@ func (w *worker) _next() {
|
|||
}).Warn("Roomserver rejected event")
|
||||
default:
|
||||
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
|
||||
sentry.CaptureException(err)
|
||||
w.sentryHub.CaptureException(err)
|
||||
}
|
||||
logrus.WithError(err).WithFields(logrus.Fields{
|
||||
"room_id": w.roomID,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue