Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing: Lower trace sample rate and make it configurable #394

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 {
Expand Down
Loading