Skip to content

Commit

Permalink
Revert commits
Browse files Browse the repository at this point in the history
  • Loading branch information
stympy committed Nov 19, 2024
1 parent 20e72d3 commit a00c6a0
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 66 deletions.
5 changes: 0 additions & 5 deletions lib/honeybadger/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ def initialize(opts = {})
# @return [String] UUID reference to the notice within Honeybadger.
# @return [false] when ignored.
def notify(exception_or_opts = nil, opts = {}, **kwargs)
if !config[:'notices.enabled']
debug { 'disabled feature=notices' }
return false
end

opts = opts.dup
opts.merge!(kwargs)

Expand Down
2 changes: 1 addition & 1 deletion lib/honeybadger/init/hanami.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Honeybadger.load_plugins!

if Hanami::VERSION >= '2.0' && Honeybadger.config[:'exceptions.enabled']
if Hanami::VERSION >= '2.0'
Hanami.app.instance_eval do
config.middleware.use Honeybadger::Rack::UserFeedback
config.middleware.use Honeybadger::Rack::UserInformer
Expand Down
8 changes: 3 additions & 5 deletions lib/honeybadger/init/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ class Railtie < ::Rails::Railtie
initializer 'honeybadger.install_middleware' do |app|
honeybadger_config = Honeybadger::Agent.instance.config

if honeybadger_config[:'exceptions.enabled']
app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
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
app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
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
2 changes: 1 addition & 1 deletion lib/honeybadger/plugins/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def context(job) # rubocop:disable Metrics/MethodLength
end

execution do
::ActiveJob::Base.set_callback(:perform, :around, &ActiveJob.method(:perform_around)) if Honeybadger.config[:'exceptions.enabled']
::ActiveJob::Base.set_callback(:perform, :around, &ActiveJob.method(:perform_around))

if config.load_plugin_insights?(:active_job)
::ActiveSupport::Notifications.subscribe(/(enqueue_at|enqueue|enqueue_retry|enqueue_all|perform|retry_stopped|discard)\.active_job/, Honeybadger::ActiveJobSubscriber.new)
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/plugins/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Honeybadger
end

execution do
return unless Honeybadger.config[:'exceptions.enabled']
require 'honeybadger/plugins/delayed_job/plugin'
::Delayed::Worker.plugins << Plugins::DelayedJob::Plugin
end
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/plugins/faktory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def call(worker, job)
requirement { defined?(::Faktory) }

execution do
return unless Honeybadger.config[:'exceptions.enabled']
::Faktory.configure_worker do |faktory|
faktory.worker_middleware do |chain|
chain.prepend Middleware
Expand Down
8 changes: 3 additions & 5 deletions lib/honeybadger/plugins/karafka.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ module Plugins
execution do
require 'honeybadger/karafka'

if Honeybadger.config[:'exceptions.enabled']
errors_listener = ::Honeybadger::Karafka::ErrorsListener.new
::Karafka.monitor.subscribe(errors_listener)
::Karafka.producer.monitor.subscribe(errors_listener) if ::Karafka.respond_to?(:producer)
end
errors_listener = ::Honeybadger::Karafka::ErrorsListener.new
::Karafka.monitor.subscribe(errors_listener)
::Karafka.producer.monitor.subscribe(errors_listener) if ::Karafka.respond_to?(:producer)

if config.load_plugin_insights?(:karafka)
::Karafka.monitor.subscribe(::Honeybadger::Karafka::InsightsListener.new)
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/plugins/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def payload_class_with_honeybadger
end

execution do
return unless Honeybadger.config[:'exceptions.enabled']
::Resque::Job.send(:include, Installer)
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/plugins/shoryuken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def notification_params(body)
requirement { defined?(::Shoryuken) }

execution do
return unless Honeybadger.config[:'exceptions.enabled']
::Shoryuken.configure_server do |config|
config.server_middleware do |chain|
chain.add Middleware
Expand Down
84 changes: 41 additions & 43 deletions lib/honeybadger/plugins/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,62 +73,60 @@ def call(worker, msg, queue, _redis)
requirement { defined?(::Sidekiq) }

execution do
if Honeybadger.config[:'exceptions.enabled']
::Sidekiq.configure_server do |sidekiq|
sidekiq.server_middleware do |chain|
chain.prepend Middleware
end
::Sidekiq.configure_server do |sidekiq|
sidekiq.server_middleware do |chain|
chain.prepend Middleware
end
end

if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
::Sidekiq.configure_server do |sidekiq|
if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
::Sidekiq.configure_server do |sidekiq|

sidekiq_default_configuration = (::Sidekiq::VERSION > '7') ?
::Sidekiq.default_configuration : Class.new
sidekiq_default_configuration = (::Sidekiq::VERSION > '7') ?
::Sidekiq.default_configuration : Class.new

sidekiq.error_handlers << lambda { |ex, sidekiq_params, sidekiq_config = sidekiq_default_configuration|
params = sidekiq_params.dup
if defined?(::Sidekiq::Config)
if params[:_config].is_a?(::Sidekiq::Config) # Sidekiq > 6 and < 7.1.5
params[:_config] = params[:_config].instance_variable_get(:@options)
else # Sidekiq >= 7.1.5
params[:_config] = sidekiq_config.instance_variable_get(:@options)
end
sidekiq.error_handlers << lambda { |ex, sidekiq_params, sidekiq_config = sidekiq_default_configuration|
params = sidekiq_params.dup
if defined?(::Sidekiq::Config)
if params[:_config].is_a?(::Sidekiq::Config) # Sidekiq > 6 and < 7.1.5
params[:_config] = params[:_config].instance_variable_get(:@options)
else # Sidekiq >= 7.1.5
params[:_config] = sidekiq_config.instance_variable_get(:@options)
end
end

job = params[:job] || params
job = params[:job] || params

job_retry = job['retry'.freeze]
job_retry = job['retry'.freeze]

if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
# We calculate the job attempts to determine the need to
# skip. Sidekiq's first job execution will have nil for the
# 'retry_count' job key. The first retry will have 0 set for
# the 'retry_count' key, incrementing on each execution
# afterwards.
retry_count = job['retry_count'.freeze]
attempt = retry_count ? retry_count + 1 : 0
if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
# We calculate the job attempts to determine the need to
# skip. Sidekiq's first job execution will have nil for the
# 'retry_count' job key. The first retry will have 0 set for
# the 'retry_count' key, incrementing on each execution
# afterwards.
retry_count = job['retry_count'.freeze]
attempt = retry_count ? retry_count + 1 : 0

max_retries = (::Sidekiq::VERSION > '7') ?
::Sidekiq.default_configuration[:max_retries] : sidekiq.options[:max_retries]
# Ensure we account for modified max_retries setting
default_max_retry_attempts = defined?(::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS) ? ::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS : 25
retry_limit = job_retry == true ? (max_retries || default_max_retry_attempts) : job_retry.to_i
max_retries = (::Sidekiq::VERSION > '7') ?
::Sidekiq.default_configuration[:max_retries] : sidekiq.options[:max_retries]
# Ensure we account for modified max_retries setting
default_max_retry_attempts = defined?(::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS) ? ::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS : 25
retry_limit = job_retry == true ? (max_retries || default_max_retry_attempts) : job_retry.to_i

limit = [retry_limit, threshold].min
limit = [retry_limit, threshold].min

return if attempt < limit
end
return if attempt < limit
end

opts = { parameters: params }
if config[:'sidekiq.use_component']
opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
opts[:action] = 'perform' if opts[:component]
end
opts = { parameters: params }
if config[:'sidekiq.use_component']
opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
opts[:action] = 'perform' if opts[:component]
end

Honeybadger.notify(ex, opts)
}
end
Honeybadger.notify(ex, opts)
}
end
end

Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/plugins/sucker_punch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Honeybadger
requirement { defined?(::SuckerPunch) }

execution do
return unless Honeybadger.config[:'exceptions.enabled']
if SuckerPunch.respond_to?(:exception_handler=) # >= v2
SuckerPunch.exception_handler = ->(ex, klass, args) { Honeybadger.notify(ex, { :component => klass, :parameters => args }) }
else
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/plugins/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def invoke_command_with_honeybadger(*args)
requirement { defined?(::Thor.no_commands) }

execution do
return unless Honeybadger.config[:'exceptions.enabled']
::Thor.send(:include, Thor)
end
end
Expand Down

0 comments on commit a00c6a0

Please sign in to comment.