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

sentry.go « sentry « config « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e43ae484a6d2d3cdb694b3bf65118dd4dccebbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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",
		})
	})
}