Fix Sentry config to use Sentry.init API
Some checks failed
Some checks failed
The Sentry setup used a config.sentry.* accessor that sentry-rails has never provided, so booting with SENTRY_DSN set raised NoMethodError during environment load (e.g. db:prepare). The code only ran once a DSN was configured, which is why it surfaced in production now. Rewrites config/initializers/sentry.rb to call Sentry.init, the actual sentry-ruby API, and removes the duplicate broken block from production.rb. Verified production boots with SENTRY_DSN set (Sentry.initialized? == true) and that the no-DSN path still early-returns. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -157,17 +157,5 @@ Rails.application.configure do
|
||||
# Skip DNS rebinding protection for the default health check endpoint.
|
||||
config.host_authorization = {exclude: ->(request) { request.path == "/up" }}
|
||||
|
||||
# Sentry configuration for production
|
||||
# Only enabled if SENTRY_DSN environment variable is set
|
||||
if ENV["SENTRY_DSN"].present?
|
||||
config.sentry.enabled = true
|
||||
|
||||
# Performance monitoring: sample 20% of transactions for traces
|
||||
# Adjust based on your traffic volume and Sentry plan limits
|
||||
config.sentry.traces_sample_rate = ENV.fetch("SENTRY_TRACES_SAMPLE_RATE", 0.2).to_f
|
||||
|
||||
# Continuous profiling: disabled by default in production due to cost
|
||||
# Enable temporarily for performance investigations if needed
|
||||
config.sentry.profiles_sample_rate = ENV.fetch("SENTRY_PROFILES_SAMPLE_RATE", 0.0).to_f
|
||||
end
|
||||
# Sentry is configured in config/initializers/sentry.rb, gated on SENTRY_DSN.
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user