gproxy: add sentry integration
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
42f9ba8efe
commit
5d26fa0403
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -23,6 +23,9 @@ func DefaultConfig() {
|
|||
Media: "./media",
|
||||
},
|
||||
LogLevel: "info",
|
||||
ErrorReporting: ErrorReportingConfig{
|
||||
Enabled: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ type Config struct {
|
|||
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"`
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package constants
|
||||
|
||||
const VERSION = "2021.4.5"
|
|
@ -28,11 +28,14 @@ type WebServer struct {
|
|||
|
||||
func NewWebServer() *WebServer {
|
||||
mainHandler := mux.NewRouter()
|
||||
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,
|
||||
|
||||
|
|
Reference in New Issue