Skip to content

Commit

Permalink
tracing: Lower trace sample rate and make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
monstermunchkin committed Jan 8, 2025
1 parent e3ebcdb commit edeb3ec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion maintenance/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package tracing
import (
"net/http"
"os"
"strconv"
"strings"

"github.com/getsentry/sentry-go"
Expand All @@ -14,11 +15,23 @@ import (
)

func init() {
var traceSampleRate float64 = 0.1

val := os.Getenv("SENTRY_TRACE_SAMPLE_RATE")
if val == "" {
var err error

traceSampleRate, err = strconv.ParseFloat(val, 64)
if err != nil {
log.Fatalf("failed to parse SENTRY_TRACE__SAMPLE_RATE: %v", err)
}
}

err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
Environment: os.Getenv("ENVIRONMENT"),
EnableTracing: true,
TracesSampleRate: 1.0,
TracesSampleRate: traceSampleRate,
BeforeSendTransaction: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
// Drop request body.
if event.Request != nil {
Expand Down

0 comments on commit edeb3ec

Please sign in to comment.