diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-09-05 17:25:11 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-09-05 17:25:11 +0100 |
commit | cd22ba22b01fe5197bf8e4630c8414dd413225af (patch) | |
tree | a40edd43c5e1d6b80eb517abdf611e930ab6b61f /roomserver | |
parent | ecee5f10f49487f0b6628fea065914ea3e685a79 (diff) |
Improve Sentry reporting
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/internal/input/input.go | 6 | ||||
-rw-r--r-- | roomserver/internal/input/input_latest_events.go | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/roomserver/internal/input/input.go b/roomserver/internal/input/input.go index 429cc4bd..a8a3e024 100644 --- a/roomserver/internal/input/input.go +++ b/roomserver/internal/input/input.go @@ -188,6 +188,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 { + scope.SetTag("room_id", w.roomID) + } msgs, err := w.subscription.Fetch(1, nats.Context(ctx)) switch err { case nil: @@ -239,6 +242,9 @@ func (w *worker) _next() { return } + if scope := sentry.CurrentHub().Scope(); scope != nil { + scope.SetTag("event_id", inputRoomEvent.Event.EventID()) + } roomserverInputBackpressure.With(prometheus.Labels{"room_id": w.roomID}).Inc() defer roomserverInputBackpressure.With(prometheus.Labels{"room_id": w.roomID}).Dec() diff --git a/roomserver/internal/input/input_latest_events.go b/roomserver/internal/input/input_latest_events.go index 7a4105ab..7e42db1b 100644 --- a/roomserver/internal/input/input_latest_events.go +++ b/roomserver/internal/input/input_latest_events.go @@ -20,6 +20,7 @@ import ( "context" "fmt" + "github.com/getsentry/sentry-go" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/opentracing/opentracing-go" @@ -284,6 +285,15 @@ func (u *latestEventsUpdater) latestState() error { "old_latest": u.oldLatest.EventIDs(), "new_latest": u.latest.EventIDs(), }).Warnf("State reset detected (removing %d events)", removed) + sentry.WithScope(func(scope *sentry.Scope) { + scope.SetLevel("warning") + scope.SetTag("event_id", u.event.EventID()) + scope.SetTag("old_state_nid", fmt.Sprintf("%d", u.oldStateNID)) + scope.SetTag("new_state_nid", fmt.Sprintf("%d", u.newStateNID)) + scope.SetTag("old_latest", u.oldLatest.EventIDs()) + scope.SetTag("new_latest", u.latest.EventIDs()) + sentry.CaptureMessage("State reset detected") + }) } // Also work out the state before the event removes and the event |