Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not check for rails console #574

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

roelbondoc
Copy link
Member

@roelbondoc roelbondoc commented Jun 28, 2024

Some Rails applications may have Rails::Console defined (possibly through gems). This would inadvertantly disable Insights in production. The issue with this is that this will enable Insights in legitimate consoles, so we'll need to document how to disable it via ENV variables perhaps.

Disable Insights when starting a Rails console:

HONEYBADGER_INSIGHTS_ENABLED=false bin/rails console

Before submitting a pull request, please make sure the following is done:

  1. If you've fixed a bug or added code that should be tested, add tests!
  2. Run rake spec in the repository root.
  3. Use a pull request title that conforms to conventional commits.

Some Rails applications may have Rails::Console defined (possibly
through gems). This would inadvertantly disable Insights in
production. The issue with this is that this will enable Insights in
legitimate consoles, so we'll need to document how to disable it via ENV
variables perhaps.
@roelbondoc roelbondoc requested a review from a team June 28, 2024 22:21
@@ -71,16 +71,18 @@ def self.source_ignored?(source)
end

Plugin.register :rails do
requirement { config.load_plugin_insights?(:rails_metrics) && defined?(::Rails.application) && ::Rails.application }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been :rails and not :rails_metrics, but this is more of a naming thing and wouldn't have broken anything.

::ActiveSupport::Notifications.subscribe("sql.active_record", Honeybadger::ActiveRecordSubscriber.new)
::ActiveSupport::Notifications.subscribe("process.action_mailer", Honeybadger::ActionMailerSubscriber.new)
::ActiveSupport::Notifications.subscribe(/(service_upload|service_download)\.active_storage/, Honeybadger::ActiveStorageSubscriber.new)
if config.load_plugin_insights?(:rails)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup: making the check here instead

@@ -277,7 +277,6 @@ def load_plugin?(name)
end

def insights_enabled?
return false if defined?(::Rails.application) && ::Rails.const_defined?("Console")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::Rails.const_defined?("Console") was always a bit finnicky to me to determine if we are in a console or not. I'm opting to just remove it for now until there is a better way to detect it automatically.

@stympy stympy requested a review from joshuap July 1, 2024 12:18
Copy link
Member

@joshuap joshuap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stympy stympy merged commit ba74af8 into master Jul 1, 2024
42 checks passed
@stympy stympy deleted the fix-insights-for-some-rails-apps branch July 1, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants