mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-22 18:19:17 -05:00
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:
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user