Feat: Sample Sentries in the Engine (#1209)

* feat: sample sentries in the engine

* set sample rate via env var

* fix: propagate sample rate through config

* fix: bind env
This commit is contained in:
Matt Kaye
2025-01-23 17:41:41 -05:00
committed by GitHub
parent 52664d66fd
commit fc9ff0eb05
3 changed files with 8 additions and 0 deletions
+1
View File
@@ -334,6 +334,7 @@ func createControllerLayer(dc *database.Layer, cf *server.ServerConfigFile, vers
alerter, err = sentry.NewSentryAlerter(&sentry.SentryAlerterOpts{
DSN: cf.Alerting.Sentry.DSN,
Environment: cf.Alerting.Sentry.Environment,
SampleRate: cf.Alerting.Sentry.SampleRate,
})
if err != nil {
+4
View File
@@ -218,6 +218,9 @@ type SentryConfigFile struct {
// Environment is the environment that the instance is running in
Environment string `mapstructure:"environment" json:"environment,omitempty" default:"development"`
// Sample rate is the rate at which to sample events. Default is 1.0 to sample all events.
SampleRate float64 `mapstructure:"sampleRate" json:"sampleRate,omitempty" default:"1.0"`
}
type AnalyticsConfigFile struct {
@@ -555,6 +558,7 @@ func BindAllEnv(v *viper.Viper) {
_ = v.BindEnv("alerting.sentry.enabled", "SERVER_ALERTING_SENTRY_ENABLED")
_ = v.BindEnv("alerting.sentry.dsn", "SERVER_ALERTING_SENTRY_DSN")
_ = v.BindEnv("alerting.sentry.environment", "SERVER_ALERTING_SENTRY_ENVIRONMENT")
_ = v.BindEnv("alerting.sentry.sampleRate", "SERVER_ALERTING_SENTRY_SAMPLE_RATE")
// analytics options
_ = v.BindEnv("analytics.posthog.enabled", "SERVER_ANALYTICS_POSTHOG_ENABLED")
+3
View File
@@ -18,6 +18,7 @@ func noIntegrations(ints []sentry.Integration) []sentry.Integration {
type SentryAlerterOpts struct {
DSN string
Environment string
SampleRate float64
}
func NewSentryAlerter(opts *SentryAlerterOpts) (*SentryAlerter, error) {
@@ -26,7 +27,9 @@ func NewSentryAlerter(opts *SentryAlerterOpts) (*SentryAlerter, error) {
AttachStacktrace: true,
Integrations: noIntegrations,
Environment: opts.Environment,
SampleRate: opts.SampleRate,
})
if err != nil {
return nil, err
}