From 5f3ec8464f4310070b5b51d0a57eca7fae77b6c0 Mon Sep 17 00:00:00 2001 From: Catherine Date: Tue, 30 Sep 2025 01:37:26 +0000 Subject: [PATCH] Fix Sentry sample rate calculation. --- fly.toml | 4 ++-- src/observe.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fly.toml b/fly.toml index 282d946..07c1a3b 100644 --- a/fly.toml +++ b/fly.toml @@ -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" diff --git a/src/observe.go b/src/observe.go index 7d713ab..ff885f0 100644 --- a/src/observe.go +++ b/src/observe.go @@ -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)