Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/sentry/sentry.go')
-rw-r--r--internal/config/sentry/sentry.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/config/sentry/sentry.go b/internal/config/sentry/sentry.go
new file mode 100644
index 000000000..4e43ae484
--- /dev/null
+++ b/internal/config/sentry/sentry.go
@@ -0,0 +1,44 @@
+package sentry
+
+import (
+ "fmt"
+
+ raven "github.com/getsentry/raven-go"
+ log "github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitaly/internal/middleware/panichandler"
+)
+
+// Config contains configuration for sentry
+type Config struct {
+ DSN string `toml:"sentry_dsn"`
+ Environment string `toml:"sentry_environment"`
+}
+
+// ConfigureSentry configures the sentry DSN
+func ConfigureSentry(version string, sentryConf Config) {
+ if sentryConf.DSN == "" {
+ return
+ }
+
+ log.Debug("Using sentry logging")
+ raven.SetDSN(sentryConf.DSN)
+ if version != "" {
+ raven.SetRelease("v" + version)
+ }
+
+ if sentryConf.Environment != "" {
+ raven.SetEnvironment(sentryConf.Environment)
+ }
+
+ panichandler.InstallPanicHandler(func(grpcMethod string, _err interface{}) {
+ err, ok := _err.(error)
+ if !ok {
+ err = fmt.Errorf("%v", _err)
+ }
+
+ raven.CaptureError(err, map[string]string{
+ "grpcMethod": grpcMethod,
+ "panic": "1",
+ })
+ })
+}