Skip to content

Commit 6e1ea87

Browse files
tracing: Lower trace sample rate and make it configurable
1 parent e3ebcdb commit 6e1ea87

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

maintenance/tracing/tracing.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package tracing
55
import (
66
"net/http"
77
"os"
8+
"strconv"
89
"strings"
910

1011
"github.com/getsentry/sentry-go"
@@ -14,11 +15,23 @@ import (
1415
)
1516

1617
func 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 {

0 commit comments

Comments
 (0)