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

perf: don't insert middleware at all if they've been disabled #549

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/honeybadger/init/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class Railtie < ::Rails::Railtie
end

initializer 'honeybadger.install_middleware' do |app|
honeybadger_config = Honeybadger::Agent.instance.config

app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer)
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback)
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer) if honeybadger_config[:'user_informer.enabled']
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback) if honeybadger_config[:'feedback.enabled']
end

config.before_initialize do
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/rack/user_feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def initialize(app, agent = nil)
end

def call(env)
return @app.call(env) unless config[:'feedback.enabled']
status, headers, body = @app.call(env)
if env['honeybadger.error_id'] && form = render_form(env['honeybadger.error_id'])
new_body = []
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/rack/user_informer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def replacement(with)
end

def call(env)
return @app.call(env) unless config[:'user_informer.enabled']
status, headers, body = @app.call(env)
if env['honeybadger.error_id']
new_body = []
Expand Down