feat: sentry integration (#1944)

* 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>
This commit is contained in:
Christian Jakob
2021-07-05 10:58:58 +02:00
committed by GitHub
parent beb1c1604a
commit b024cda4e5
16 changed files with 218 additions and 11 deletions

View File

@@ -3,8 +3,12 @@ package main
import (
"context"
"flag"
"os"
"strconv"
"time"
"github.com/caos/logging"
"github.com/getsentry/sentry-go"
admin_es "github.com/caos/zitadel/internal/admin/repository/eventsourcing"
"github.com/caos/zitadel/internal/api"
@@ -89,6 +93,24 @@ const (
)
func main() {
enableSentry, _ := strconv.ParseBool(os.Getenv("SENTRY_USAGE"))
if enableSentry {
err := sentry.Init(sentry.ClientOptions{})
if err != nil {
logging.Log("MAIN-Gnzjw").WithError(err).Fatal("sentry init failed")
}
sentry.CaptureMessage("sentry started")
logging.Log("MAIN-adgf3").Info("sentry started")
defer func() {
err := recover()
if err != nil {
sentry.CurrentHub().Recover(err)
sentry.Flush(2 * time.Second)
panic(err)
}
}()
}
flag.Var(configPaths, "config-files", "paths to the config files")
flag.Var(setupPaths, "setup-files", "paths to the setup files")
flag.Parse()