Logging: Log frontend errors (#28073)
* basic frontend Sentry integration * backend endpoint to capture sentry events * WIP! * log user email for frontend logs * remove debug logging * lint fixes * Fix type exports & property names Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * additional struct naming fix * rename log endpoint, config section & interface * add sentry sample rate to config * refac to use EchoSrv * log user id * backend tests * tests for SentryEchoBackend * sentry echo backend tests * CustomEndpointTransport tests * Update pkg/api/frontend_logging_test.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update conf/defaults.ini Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/api/frontend_logging_test.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * don't export unnecesasrily * update go.sum * get rid of Convey in tests, use stdlib * add sentry config to sample.ini * cleanup to set orig logging handler in test * Apply suggestions from code review Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * PR feedback changes * lock sentry version Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -322,6 +322,9 @@ type Cfg struct {
|
||||
AlertingAnnotationCleanupSetting AnnotationCleanupSettings
|
||||
DashboardAnnotationCleanupSettings AnnotationCleanupSettings
|
||||
APIAnnotationCleanupSettings AnnotationCleanupSettings
|
||||
|
||||
// Sentry config
|
||||
Sentry Sentry
|
||||
}
|
||||
|
||||
// IsExpressionsEnabled returns whether the expressions feature is enabled.
|
||||
@@ -846,6 +849,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
}
|
||||
|
||||
cfg.readDateFormats()
|
||||
cfg.readSentryConfig()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package setting
|
||||
|
||||
type Sentry struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
DSN string `json:"dsn"`
|
||||
CustomEndpoint string `json:"customEndpoint"`
|
||||
SampleRate float64 `json:"sampleRate"`
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readSentryConfig() {
|
||||
raw := cfg.Raw.Section("log.frontend")
|
||||
cfg.Sentry = Sentry{
|
||||
Enabled: raw.Key("enabled").MustBool(true),
|
||||
DSN: raw.Key("sentry_dsn").String(),
|
||||
CustomEndpoint: raw.Key("custom_endpoint").String(),
|
||||
SampleRate: raw.Key("sample_rate").MustFloat64(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user