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

Allow to manually enable rake integration #633

Open
krists opened this issue Sep 3, 2020 · 1 comment
Open

Allow to manually enable rake integration #633

krists opened this issue Sep 3, 2020 · 1 comment
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature

Comments

@krists
Copy link

krists commented Sep 3, 2020

Hello!

I'm having troubles getting bugsnag to work in my Rails app together with APM tools (like AppSignal) that still uses alias method chains to hook into rake or other gems or frameworks. https://blog.newrelic.com/engineering/ruby-agent-module-prepend-alias-method-chains/ is a good article that explains the issue in detail.

I think it should be possible to get these tools working together with careful require order - require and initialize appsignal code first and then do the same with bugsnag.

These would be the steps:

  • Disable automatic require in Gemfile via:
    gem 'appsignal', require: false
    gem 'bugsnag', require: false
  • Require appsignal first and then load bugsnag with disabled autoconfig:
    # config/application.rb
    
    require "appsignal" # Let appsignal load all integrations and register rails initializers
    
    ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = "1"
    require "bugsnag"
    Bugsnag.load_integration(:rails)
    Bugsnag.load_integration(:resque)
  • Load bugsnag's rake integration only after appsignal has finished patching rake.
    # config/application.rb
    
    initializer "bugsnag.load_rake_integration", after: "appsignal.configure_rails_initialization" do
      Bugsnag.load_integration(:rake)
    end

Unfortunately the last step is not possible in current version on bugsnag (6.17.0) as rake integration it is treated differently from others like resque, sidekiq or mongo.

Instead of being required with load_integration method call (https://github.com/bugsnag/bugsnag-ruby/blob/v6.17.0/lib/bugsnag.rb#L215-L222) it is required in Rails rake_tasks block (https://github.com/bugsnag/bugsnag-ruby/blob/v6.17.0/lib/bugsnag/integrations/railtie.rb#L18).

When running a rake task mentioned rake_tasks block is executed much sooner than initializers and that causes Rake::Task class to receive bugsnag's prepend module call before appsignal's alias method chain and that leads to stack level to deep exception mentioned in #577.

Please consider changing rake integration require logic to be more similar to others and users have more control when it is required.

@johnkiely1
Copy link
Member

Hi @krists

Thanks, we will look into making these changes when priorities allow.

@johnkiely1 johnkiely1 added backlog We hope to fix this feature/bug in the future feature request Request for a new feature labels Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants