diff --git a/maintenance/tracing/tracing.go b/maintenance/tracing/tracing.go index 09326711..ea4ed5e6 100755 --- a/maintenance/tracing/tracing.go +++ b/maintenance/tracing/tracing.go @@ -5,6 +5,7 @@ package tracing import ( "net/http" "os" + "strconv" "strings" "github.com/getsentry/sentry-go" @@ -14,11 +15,23 @@ import ( ) func init() { + var tracesSampleRate float64 = 0.1 + + val := strings.TrimSpace(os.Getenv("SENTRY_TRACES_SAMPLE_RATE")) + if val != "" { + var err error + + tracesSampleRate, err = strconv.ParseFloat(val, 64) + if err != nil { + log.Fatalf("failed to parse SENTRY_TRACES_SAMPLE_RATE: %v", err) + } + } + err := sentry.Init(sentry.ClientOptions{ Dsn: os.Getenv("SENTRY_DSN"), Environment: os.Getenv("ENVIRONMENT"), EnableTracing: true, - TracesSampleRate: 1.0, + TracesSampleRate: tracesSampleRate, BeforeSendTransaction: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { // Drop request body. if event.Request != nil {