Improve Sentry reporting

This commit is contained in:
Neil Alexander 2022-09-05 17:25:11 +01:00
parent ecee5f10f4
commit cd22ba22b0
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 17 additions and 0 deletions

View file

@ -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