File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package tracing
55import (
66 "net/http"
77 "os"
8+ "strconv"
89 "strings"
910
1011 "github.com/getsentry/sentry-go"
@@ -14,11 +15,23 @@ import (
1415)
1516
1617func init () {
18+ var tracesSampleRate float64 = 0.1
19+
20+ val := os .Getenv ("SENTRY_TRACES_SAMPLE_RATE" )
21+ if val == "" {
22+ var err error
23+
24+ tracesSampleRate , err = strconv .ParseFloat (val , 64 )
25+ if err != nil {
26+ log .Fatalf ("failed to parse SENTRY_TRACES_SAMPLE_RATE: %v" , err )
27+ }
28+ }
29+
1730 err := sentry .Init (sentry.ClientOptions {
1831 Dsn : os .Getenv ("SENTRY_DSN" ),
1932 Environment : os .Getenv ("ENVIRONMENT" ),
2033 EnableTracing : true ,
21- TracesSampleRate : 1.0 ,
34+ TracesSampleRate : tracesSampleRate ,
2235 BeforeSendTransaction : func (event * sentry.Event , hint * sentry.EventHint ) * sentry.Event {
2336 // Drop request body.
2437 if event .Request != nil {
You can’t perform that action at this time.
0 commit comments