After I set up the sentry.io integration in my rails 5.2 app the following command: rails secret returns:
I, [2018-11-23T21:50:38.855829 #25462] INFO – sentry: ** [Raven] Raven 2.7.4 ready to catch errors
450027042d9d4ff15b798b23f8a85a1cf62b2b5740906421d8613e01e2401b1dffxxxxxxxx
so it is not correct
The informational message of sentry is very nice and I want it but in this case there is a problem…
How can I run rails and somehow instruct sentry to not produce the informational message?
I could also some how disable sentry for this specific run of rails (it could be with a env variable)
To be clear you need to set it to an empty value in whatever way you configure the DSN. I dont know how you do this, as its implementation specific, but if you were using an environment variable (like Heroku does), then that’s how you’d clear it there.
I want to disable it only for generating the secret and not all the time…
I am using this (temporary) approach:
Gemfile:
unless ENV.has_key?('A_SENTRY_DISABLE') # temp fix with rails secret
gem "sentry-raven"
end
config/application.rb
unless ENV.has_key?('A_SENTRY_DISABLE') # temp fix with rails secret
Raven.configure do |config|
config.dsn = ENV['A_SENTRY_URL']
end
end
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_action :set_raven_context
private
def set_raven_context
unless ENV.has_key?('A_SENTRY_DISABLE') # temp fix with rails secret
Raven.user_context(id: session[:current_user_id]) # or anything else in session
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
end
end
end