Fix Sentry sample rate calculation.

This commit is contained in:
Catherine
2025-09-30 02:09:38 +00:00
parent f63940b459
commit 5f3ec8464f
2 changed files with 14 additions and 5 deletions
+12 -3
View File
@@ -59,10 +59,19 @@ func InitObservability() {
options.Environment = environment
options.EnableLogs = enableLogs
options.EnableTracing = enableTracing
if environment == "development" {
switch environment {
case "development", "staging":
options.TracesSampleRate = 1.0
} else {
options.TracesSampleRate = 60.0
case "production":
options.TracesSampler = func(ctx sentry.SamplingContext) float64 {
if method, ok := ctx.Span.Data["http.request.method"].(string); ok {
switch method {
case "PUT", "DELETE", "POST":
return 1.0
}
}
return 0.05
}
}
if err := sentry.Init(options); err != nil {
log.Fatalf("sentry: %s\n", err)