mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
b024cda4e5
* initial sentry variables and secrets * feat: sentry monitoring * fix typo * feat(sentry version): sentry capability * fix(sentry include): included sentry import 4 zitadel * usage flag for sentry * improve sentry flag * merge main * fix sentry config * add sentry dsn to secret env vars * fix test * log sentry start * add sentry grpc interceptor and recover * add sentry http interceptor to asset api * fix interceptor order * try improve sentry recover * fix i18n interception * panic Co-authored-by: Livio Amstutz <livio.a@gmail.com>
27 lines
715 B
Go
27 lines
715 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/getsentry/sentry-go"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"github.com/caos/zitadel/internal/api/grpc/errors"
|
|
)
|
|
|
|
func SentryHandler() grpc.UnaryServerInterceptor {
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
return sendErrToSentry(ctx, req, handler)
|
|
}
|
|
}
|
|
|
|
func sendErrToSentry(ctx context.Context, req interface{}, handler grpc.UnaryHandler) (interface{}, error) {
|
|
resp, err := handler(ctx, req)
|
|
code, _, _, _ := errors.ExtractCaosError(err)
|
|
if code == codes.Unknown || code == codes.Internal {
|
|
sentry.CaptureException(err)
|
|
}
|
|
return resp, err
|
|
}
|