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:internal/constants/constants.go]
[bumpversion:file:outpost/pkg/version.go]
[bumpversion:file:web/src/constants.ts]

View File

@ -1,10 +1,14 @@
package main
import (
"fmt"
"sync"
"time"
"github.com/getsentry/sentry-go"
log "github.com/sirupsen/logrus"
"goauthentik.io/internal/config"
"goauthentik.io/internal/constants"
"goauthentik.io/internal/gounicorn"
"goauthentik.io/internal/web"
)
@ -16,6 +20,18 @@ func main() {
config.LoadConfig("./local.env.yml")
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")
wg := sync.WaitGroup{}
wg.Add(2)

View File

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

View File

@ -1,10 +1,11 @@
package config
type Config struct {
Debug bool `yaml:"debug"`
Web WebConfig `yaml:"web"`
Paths PathsConfig `yaml:"paths"`
LogLevel string `yaml:"log_level"`
Debug bool `yaml:"debug"`
Web WebConfig `yaml:"web"`
Paths PathsConfig `yaml:"paths"`
LogLevel string `yaml:"log_level"`
ErrorReporting ErrorReportingConfig `yaml:"error_reporting"`
}
type WebConfig struct {
@ -15,3 +16,9 @@ type WebConfig struct {
type PathsConfig struct {
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 {
mainHandler := mux.NewRouter()
mainHandler.Use(recoveryMiddleware())
if config.G.ErrorReporting.Enabled {
mainHandler.Use(recoveryMiddleware())
}
mainHandler.Use(handlers.ProxyHeaders)
mainHandler.Use(handlers.CompressHandler)
logginRouter := mainHandler.NewRoute().Subrouter()
logginRouter.Use(loggingMiddleware)
ws := &WebServer{
LegacyProxy: true,