getsentry/sentry-ruby

skip_rake_integration doesn't skip sentry messages from console

Closed this issue · 2 comments

Issue Description

Basically this issue for capture_message , maybe it worked back then when the rails console was a task.

Reproduction Steps

  • Enable skip_rake_integration
  • Send a message with Sentry.capture_message

Expected Behavior

  • It doesn't show up in Sentry

Actual Behavior

  • It shows up in Sentry

Ruby Version

3.2.3

SDK Version

5.21

Integration and Its Version

No response

Sentry Config

Sentry.init do |config|
  config.traces_sample_rate = 0
  config.sidekiq.report_after_job_retries = true
  config.skip_rake_integration = true
  config.send_default_pii = true

hey, skip_rake_integration only controls whether exceptions in your rake tasks are captured or not. An explicit Sentry.capture_message is always sent if the SDK is initialized (which is true in the rails console).

If you want to completely disable Sentry inside your console you can wrap your Sentry.init with a console check like this:

unless Rails.const_defined?('Console')
  Sentry.init do |config|
    config.dsn = "<DSN>"
    # ....
  end
end

you can refer to this stackoverflow for more details:
https://stackoverflow.com/questions/13506690/how-to-determine-if-rails-is-running-from-cli-console-or-as-server

Thank you!