gproxy: add sentry integration

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-04 14:28:48 +02:00
parent 42f9ba8efe
commit 5d26fa0403
6 changed files with 39 additions and 5 deletions

View file

@ -33,6 +33,8 @@ values =
[bumpversion:file:authentik/__init__.py] [bumpversion:file:authentik/__init__.py]
[bumpversion:file:internal/constants/constants.go]
[bumpversion:file:outpost/pkg/version.go] [bumpversion:file:outpost/pkg/version.go]
[bumpversion:file:web/src/constants.ts] [bumpversion:file:web/src/constants.ts]

View file

@ -1,10 +1,14 @@
package main package main
import ( import (
"fmt"
"sync" "sync"
"time"
"github.com/getsentry/sentry-go"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"goauthentik.io/internal/config" "goauthentik.io/internal/config"
"goauthentik.io/internal/constants"
"goauthentik.io/internal/gounicorn" "goauthentik.io/internal/gounicorn"
"goauthentik.io/internal/web" "goauthentik.io/internal/web"
) )
@ -16,6 +20,18 @@ func main() {
config.LoadConfig("./local.env.yml") config.LoadConfig("./local.env.yml")
config.ConfigureLogger() config.ConfigureLogger()
if config.G.ErrorReporting.Enabled {
sentry.Init(sentry.ClientOptions{
Dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
AttachStacktrace: true,
TracesSampleRate: 0.6,
Release: fmt.Sprintf("authentik@%s", constants.VERSION),
Environment: config.G.ErrorReporting.Environment,
})
defer sentry.Flush(time.Second * 5)
defer sentry.Recover()
}
rl := log.WithField("logger", "authentik.g") rl := log.WithField("logger", "authentik.g")
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
wg.Add(2) wg.Add(2)

View file

@ -23,6 +23,9 @@ func DefaultConfig() {
Media: "./media", Media: "./media",
}, },
LogLevel: "info", LogLevel: "info",
ErrorReporting: ErrorReportingConfig{
Enabled: false,
},
} }
} }

View file

@ -1,10 +1,11 @@
package config package config
type Config struct { type Config struct {
Debug bool `yaml:"debug"` Debug bool `yaml:"debug"`
Web WebConfig `yaml:"web"` Web WebConfig `yaml:"web"`
Paths PathsConfig `yaml:"paths"` Paths PathsConfig `yaml:"paths"`
LogLevel string `yaml:"log_level"` LogLevel string `yaml:"log_level"`
ErrorReporting ErrorReportingConfig `yaml:"error_reporting"`
} }
type WebConfig struct { type WebConfig struct {
@ -15,3 +16,9 @@ type WebConfig struct {
type PathsConfig struct { type PathsConfig struct {
Media string `yaml:"media"` Media string `yaml:"media"`
} }
type ErrorReportingConfig struct {
Enabled bool `yaml:"enabled"`
Environment string `yaml:"environment"`
SendPII bool `yaml:"send_pii"`
}

View file

@ -0,0 +1,3 @@
package constants
const VERSION = "2021.4.5"

View file

@ -28,11 +28,14 @@ type WebServer struct {
func NewWebServer() *WebServer { func NewWebServer() *WebServer {
mainHandler := mux.NewRouter() mainHandler := mux.NewRouter()
mainHandler.Use(recoveryMiddleware()) if config.G.ErrorReporting.Enabled {
mainHandler.Use(recoveryMiddleware())
}
mainHandler.Use(handlers.ProxyHeaders) mainHandler.Use(handlers.ProxyHeaders)
mainHandler.Use(handlers.CompressHandler) mainHandler.Use(handlers.CompressHandler)
logginRouter := mainHandler.NewRoute().Subrouter() logginRouter := mainHandler.NewRoute().Subrouter()
logginRouter.Use(loggingMiddleware) logginRouter.Use(loggingMiddleware)
ws := &WebServer{ ws := &WebServer{
LegacyProxy: true, LegacyProxy: true,