Fix Sentry sample rate calculation.

This commit is contained in:
Catherine
2025-09-30 01:37:26 +00:00
parent f63940b459
commit 5f3ec8464f
2 changed files with 14 additions and 5 deletions

View File

@@ -49,7 +49,7 @@ soft_limit = 250
[[services.http_checks]]
protocol = "http"
method = "get"
path = "/"
path = "/health"
headers = { Health-Check = "🩺", Host = "localhost" }
grace_period = "5s"
interval = "2s"
@@ -76,7 +76,7 @@ soft_limit = 250
[[services.http_checks]]
protocol = "https"
method = "get"
path = "/"
path = "/health"
headers = { Health-Check = "🩺", Host = "localhost" }
grace_period = "5s"
interval = "2s"

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)