fix: add sentry in ui, http and projection handlers (#1977)

* fix: add sentry in ui, http and projection handlers

* fix test
This commit is contained in:
Livio Amstutz
2021-07-06 13:36:35 +02:00
committed by GitHub
parent 9277928ef7
commit 0e472a347f
78 changed files with 339 additions and 11 deletions

View File

@@ -2,9 +2,12 @@ package query
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v1"
"time"
"github.com/getsentry/sentry-go"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/eventstore/v1/models"
@@ -27,9 +30,19 @@ type Handler interface {
AggregateTypes() []models.AggregateType
CurrentSequence() (uint64, error)
Eventstore() v1.Eventstore
Subscription() *v1.Subscription
}
func ReduceEvent(handler Handler, event *models.Event) {
defer func() {
err := recover()
if err != nil {
sentry.CurrentHub().Recover(err)
handler.Subscription().Unsubscribe()
}
}()
currentSequence, err := handler.CurrentSequence()
if err != nil {
logging.Log("HANDL-BmpkC").WithError(err).Warn("unable to get current sequence")

View File

@@ -2,6 +2,9 @@ package spooler
import (
"context"
"github.com/getsentry/sentry-go"
"github.com/caos/zitadel/internal/eventstore/v1"
"strconv"
"sync"
@@ -64,7 +67,14 @@ func requeueTask(task *spooledHandler, queue chan<- *spooledHandler) {
func (s *spooledHandler) load(workerID string) {
errs := make(chan error)
defer close(errs)
defer func() {
close(errs)
err := recover()
if err != nil {
sentry.CurrentHub().Recover(err)
}
}()
ctx, cancel := context.WithCancel(context.Background())
go s.awaitError(cancel, errs, workerID)
hasLocked := s.lock(ctx, errs, workerID)

View File

@@ -42,6 +42,10 @@ func (h *testHandler) ViewModel() string {
return h.viewModel
}
func (h *testHandler) Subscription() *v1.Subscription {
return nil
}
func (h *testHandler) EventQuery() (*models.SearchQuery, error) {
if h.queryError != nil {
return nil, h.queryError