Sentry integration

This commit is contained in:
2020-10-13 10:35:41 +02:00
parent 38ac4422dd
commit 41748363d1
5 changed files with 185 additions and 1 deletions

View File

@ -12,10 +12,12 @@ import (
)
type Config struct {
Debug bool `yaml:"debug"`
HTTP HTTPConfig `yaml:"http"`
SMTP SMTPConfig `yaml:"smtp"`
Hydra HydraConfig `yaml:"hydra"`
Session SessionConfig `yaml:"session"`
Sentry SentryConfig `yaml:"sentry"`
}
// NewFromFile retrieves the configuration from the given file
@ -73,6 +75,14 @@ type SessionConfig struct {
RememberMeDuration int `yaml:"rememberMeDuration" env:"HYDRA_SESSION_REMEMBER_ME_DURATION"`
}
type SentryConfig struct {
DSN string `yaml:"dsn" env:"SENTRY_DSN"`
// Server events sampling rate, see https://docs.sentry.io/platforms/go/configuration/options/
ServerSampleRate float64 `yaml:"serverSampleRate" env:"SENTRY_SERVER_SAMPLE_RATE"`
ServerFlushTimeout time.Duration `yaml:"serverFlushTimeout" env:"SENTRY_SERVER_FLUSH_TIMEOUT"`
Environment string `yaml:"environment" env:"SENTRY_ENVIRONMENT"`
}
func NewDumpDefault() *Config {
config := NewDefault()
return config
@ -80,6 +90,7 @@ func NewDumpDefault() *Config {
func NewDefault() *Config {
return &Config{
Debug: false,
HTTP: HTTPConfig{
Address: ":3000",
CookieAuthenticationKey: "",
@ -109,6 +120,12 @@ func NewDefault() *Config {
DefaultDuration: int((time.Hour * 1).Seconds()), // 1 hour
RememberMeDuration: int((time.Hour * 24 * 30).Seconds()), // 30 days
},
Sentry: SentryConfig{
DSN: "",
ServerSampleRate: 1,
ServerFlushTimeout: 2 * time.Second,
Environment: "",
},
}
}