honeybadger 5.23.0 → 5.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c39590cf4156c12f42b0f04fbc2f27f76c3583c48fdfc01b30885c0b60e47511
4
- data.tar.gz: 7b92557df489fe548d5653e9e7c5ea5bac1c87720fc7797821a0758829b00534
3
+ metadata.gz: b68a6aaaacbd4d0dacf73e81dac6927cc89bd1446b91be6d5a51456f3c7b7723
4
+ data.tar.gz: c8d46e503b7a562a63b01776f8b14aa98dccd5d81fc7ea02b98bd2ccff23ec7f
5
5
  SHA512:
6
- metadata.gz: aaced28451f474f8e3d53d7e56d97f8a94a8d307da0e15a0e097f065421089486faa04ad8f72d61d2be1d2f04424583aa93c3531bc3d91afc90e1b2700fb1f95
7
- data.tar.gz: 1c33cc13477a77cd405fce3b84ad3fabea8a84203aaa170f20374c901d402edec6fc5e240c676a41f89be91255b0f60b769f7e3a34380f2f9106b4e0655fb937
6
+ metadata.gz: 4bff878d0ea80ad0fc34f9265e7815dc2c9bf922e4f5bb59381a4822b549725fdcce413206c0f48495e56bb283ccdf3f23d4a485541b51fd843563d83f397103
7
+ data.tar.gz: 2bf7ff80ed9af1137ba412b51d29e0ae5dc7151f103c2a804dc3edf86f27e756f69c307d1d79d7f084f82c643b76b9049587873a06bfa722a041d425251ba8f6
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.25.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.24.0...v5.25.0) (2024-11-26)
5
+
6
+
7
+ ### Features
8
+
9
+ * set context during rails error report ([#649](https://github.com/honeybadger-io/honeybadger-ruby/issues/649)) ([dee37e1](https://github.com/honeybadger-io/honeybadger-ruby/commit/dee37e157b0913e24a5d368e3d2cbe733f87214e))
10
+
11
+ ## [5.24.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.23.0...v5.24.0) (2024-11-21)
12
+
13
+
14
+ ### Features
15
+
16
+ * skip middleware, plugins, and exception reporting when exceptions are disabled ([#646](https://github.com/honeybadger-io/honeybadger-ruby/issues/646)) ([6c4d7d5](https://github.com/honeybadger-io/honeybadger-ruby/commit/6c4d7d53f7356717894269b5fc9095621c9e8014))
17
+
4
18
  ## [5.23.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.22.0...v5.23.0) (2024-11-19)
5
19
 
6
20
 
@@ -125,6 +125,11 @@ module Honeybadger
125
125
  # @return [String] UUID reference to the notice within Honeybadger.
126
126
  # @return [false] when ignored.
127
127
  def notify(exception_or_opts = nil, opts = {}, **kwargs)
128
+ if !config[:'exceptions.enabled']
129
+ debug { 'disabled feature=notices' }
130
+ return false
131
+ end
132
+
128
133
  opts = opts.dup
129
134
  opts.merge!(kwargs)
130
135
 
@@ -8,7 +8,7 @@ Honeybadger.init!({
8
8
 
9
9
  Honeybadger.load_plugins!
10
10
 
11
- if Hanami::VERSION >= '2.0'
11
+ if Hanami::VERSION >= '2.0' && Honeybadger.config[:'exceptions.enabled']
12
12
  Hanami.app.instance_eval do
13
13
  config.middleware.use Honeybadger::Rack::UserFeedback
14
14
  config.middleware.use Honeybadger::Rack::UserInformer
@@ -14,9 +14,11 @@ module Honeybadger
14
14
  initializer 'honeybadger.install_middleware' do |app|
15
15
  honeybadger_config = Honeybadger::Agent.instance.config
16
16
 
17
- app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
18
- app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer) if honeybadger_config[:'user_informer.enabled']
19
- app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback) if honeybadger_config[:'feedback.enabled']
17
+ if honeybadger_config[:'exceptions.enabled']
18
+ app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
19
+ app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer) if honeybadger_config[:'user_informer.enabled']
20
+ app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback) if honeybadger_config[:'feedback.enabled']
21
+ end
20
22
  end
21
23
 
22
24
  config.before_initialize do
@@ -51,7 +51,7 @@ module Honeybadger
51
51
  end
52
52
 
53
53
  execution do
54
- ::ActiveJob::Base.set_callback(:perform, :around, &ActiveJob.method(:perform_around))
54
+ ::ActiveJob::Base.set_callback(:perform, :around, &ActiveJob.method(:perform_around)) if Honeybadger.config[:'exceptions.enabled']
55
55
 
56
56
  if config.load_plugin_insights?(:active_job)
57
57
  ::ActiveSupport::Notifications.subscribe(/(enqueue_at|enqueue|enqueue_retry|enqueue_all|perform|retry_stopped|discard)\.active_job/, Honeybadger::ActiveJobSubscriber.new)
@@ -15,6 +15,7 @@ module Honeybadger
15
15
  end
16
16
 
17
17
  execution do
18
+ return unless Honeybadger.config[:'exceptions.enabled']
18
19
  require 'honeybadger/plugins/delayed_job/plugin'
19
20
  ::Delayed::Worker.plugins << Plugins::DelayedJob::Plugin
20
21
  end
@@ -15,6 +15,7 @@ module Honeybadger
15
15
  requirement { defined?(::Faktory) }
16
16
 
17
17
  execution do
18
+ return unless Honeybadger.config[:'exceptions.enabled']
18
19
  ::Faktory.configure_worker do |faktory|
19
20
  faktory.worker_middleware do |chain|
20
21
  chain.prepend Middleware
@@ -8,9 +8,11 @@ module Honeybadger
8
8
  execution do
9
9
  require 'honeybadger/karafka'
10
10
 
11
- errors_listener = ::Honeybadger::Karafka::ErrorsListener.new
12
- ::Karafka.monitor.subscribe(errors_listener)
13
- ::Karafka.producer.monitor.subscribe(errors_listener) if ::Karafka.respond_to?(:producer)
11
+ if Honeybadger.config[:'exceptions.enabled']
12
+ errors_listener = ::Honeybadger::Karafka::ErrorsListener.new
13
+ ::Karafka.monitor.subscribe(errors_listener)
14
+ ::Karafka.producer.monitor.subscribe(errors_listener) if ::Karafka.respond_to?(:producer)
15
+ end
14
16
 
15
17
  if config.load_plugin_insights?(:karafka)
16
18
  ::Karafka.monitor.subscribe(::Honeybadger::Karafka::InsightsListener.new)
@@ -32,6 +32,8 @@ module Honeybadger
32
32
 
33
33
  class ErrorSubscriber
34
34
  def self.report(exception, handled:, severity:, context: {}, source: nil)
35
+ Honeybadger.context(context)
36
+
35
37
  # We only report handled errors (`Rails.error.handle`)
36
38
  # Unhandled errors will be caught by our integrations (eg middleware),
37
39
  # which have richer context than the Rails error reporter
@@ -41,7 +43,7 @@ module Honeybadger
41
43
 
42
44
  tags = ["severity:#{severity}", "handled:#{handled}"]
43
45
  tags << "source:#{source}" if source
44
- Honeybadger.notify(exception, context: context, tags: tags)
46
+ Honeybadger.notify(exception, tags: tags)
45
47
  end
46
48
 
47
49
  def self.source_ignored?(source)
@@ -64,7 +66,7 @@ module Honeybadger
64
66
  ::ActionDispatch::ShowExceptions.prepend(ExceptionsCatcher)
65
67
  end
66
68
 
67
- if defined?(::ActiveSupport::ErrorReporter) # Rails 7
69
+ if Honeybadger.config[:'exceptions.enabled'] && defined?(::ActiveSupport::ErrorReporter) # Rails 7
68
70
  ::Rails.error.subscribe(ErrorSubscriber)
69
71
  end
70
72
  end
@@ -64,6 +64,7 @@ module Honeybadger
64
64
  end
65
65
 
66
66
  execution do
67
+ return unless Honeybadger.config[:'exceptions.enabled']
67
68
  ::Resque::Job.send(:include, Installer)
68
69
  end
69
70
  end
@@ -40,6 +40,7 @@ module Honeybadger
40
40
  requirement { defined?(::Shoryuken) }
41
41
 
42
42
  execution do
43
+ return unless Honeybadger.config[:'exceptions.enabled']
43
44
  ::Shoryuken.configure_server do |config|
44
45
  config.server_middleware do |chain|
45
46
  chain.add Middleware
@@ -73,60 +73,62 @@ module Honeybadger
73
73
  requirement { defined?(::Sidekiq) }
74
74
 
75
75
  execution do
76
- ::Sidekiq.configure_server do |sidekiq|
77
- sidekiq.server_middleware do |chain|
78
- chain.prepend Middleware
76
+ if Honeybadger.config[:'exceptions.enabled']
77
+ ::Sidekiq.configure_server do |sidekiq|
78
+ sidekiq.server_middleware do |chain|
79
+ chain.prepend Middleware
80
+ end
79
81
  end
80
- end
81
82
 
82
- if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
83
- ::Sidekiq.configure_server do |sidekiq|
83
+ if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
84
+ ::Sidekiq.configure_server do |sidekiq|
84
85
 
85
- sidekiq_default_configuration = (::Sidekiq::VERSION > '7') ?
86
- ::Sidekiq.default_configuration : Class.new
86
+ sidekiq_default_configuration = (::Sidekiq::VERSION > '7') ?
87
+ ::Sidekiq.default_configuration : Class.new
87
88
 
88
- sidekiq.error_handlers << lambda { |ex, sidekiq_params, sidekiq_config = sidekiq_default_configuration|
89
- params = sidekiq_params.dup
90
- if defined?(::Sidekiq::Config)
91
- if params[:_config].is_a?(::Sidekiq::Config) # Sidekiq > 6 and < 7.1.5
92
- params[:_config] = params[:_config].instance_variable_get(:@options)
93
- else # Sidekiq >= 7.1.5
94
- params[:_config] = sidekiq_config.instance_variable_get(:@options)
89
+ sidekiq.error_handlers << lambda { |ex, sidekiq_params, sidekiq_config = sidekiq_default_configuration|
90
+ params = sidekiq_params.dup
91
+ if defined?(::Sidekiq::Config)
92
+ if params[:_config].is_a?(::Sidekiq::Config) # Sidekiq > 6 and < 7.1.5
93
+ params[:_config] = params[:_config].instance_variable_get(:@options)
94
+ else # Sidekiq >= 7.1.5
95
+ params[:_config] = sidekiq_config.instance_variable_get(:@options)
96
+ end
95
97
  end
96
- end
97
98
 
98
- job = params[:job] || params
99
+ job = params[:job] || params
99
100
 
100
- job_retry = job['retry'.freeze]
101
+ job_retry = job['retry'.freeze]
101
102
 
102
- if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
103
- # We calculate the job attempts to determine the need to
104
- # skip. Sidekiq's first job execution will have nil for the
105
- # 'retry_count' job key. The first retry will have 0 set for
106
- # the 'retry_count' key, incrementing on each execution
107
- # afterwards.
108
- retry_count = job['retry_count'.freeze]
109
- attempt = retry_count ? retry_count + 1 : 0
103
+ if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
104
+ # We calculate the job attempts to determine the need to
105
+ # skip. Sidekiq's first job execution will have nil for the
106
+ # 'retry_count' job key. The first retry will have 0 set for
107
+ # the 'retry_count' key, incrementing on each execution
108
+ # afterwards.
109
+ retry_count = job['retry_count'.freeze]
110
+ attempt = retry_count ? retry_count + 1 : 0
110
111
 
111
- max_retries = (::Sidekiq::VERSION > '7') ?
112
- ::Sidekiq.default_configuration[:max_retries] : sidekiq.options[:max_retries]
113
- # Ensure we account for modified max_retries setting
114
- default_max_retry_attempts = defined?(::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS) ? ::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS : 25
115
- retry_limit = job_retry == true ? (max_retries || default_max_retry_attempts) : job_retry.to_i
112
+ max_retries = (::Sidekiq::VERSION > '7') ?
113
+ ::Sidekiq.default_configuration[:max_retries] : sidekiq.options[:max_retries]
114
+ # Ensure we account for modified max_retries setting
115
+ default_max_retry_attempts = defined?(::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS) ? ::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS : 25
116
+ retry_limit = job_retry == true ? (max_retries || default_max_retry_attempts) : job_retry.to_i
116
117
 
117
- limit = [retry_limit, threshold].min
118
+ limit = [retry_limit, threshold].min
118
119
 
119
- return if attempt < limit
120
- end
120
+ return if attempt < limit
121
+ end
121
122
 
122
- opts = { parameters: params }
123
- if config[:'sidekiq.use_component']
124
- opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
125
- opts[:action] = 'perform' if opts[:component]
126
- end
123
+ opts = { parameters: params }
124
+ if config[:'sidekiq.use_component']
125
+ opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
126
+ opts[:action] = 'perform' if opts[:component]
127
+ end
127
128
 
128
- Honeybadger.notify(ex, opts)
129
- }
129
+ Honeybadger.notify(ex, opts)
130
+ }
131
+ end
130
132
  end
131
133
  end
132
134
 
@@ -6,6 +6,7 @@ module Honeybadger
6
6
  requirement { defined?(::SuckerPunch) }
7
7
 
8
8
  execution do
9
+ return unless Honeybadger.config[:'exceptions.enabled']
9
10
  if SuckerPunch.respond_to?(:exception_handler=) # >= v2
10
11
  SuckerPunch.exception_handler = ->(ex, klass, args) { Honeybadger.notify(ex, { :component => klass, :parameters => args }) }
11
12
  else
@@ -25,6 +25,7 @@ module Honeybadger
25
25
  requirement { defined?(::Thor.no_commands) }
26
26
 
27
27
  execution do
28
+ return unless Honeybadger.config[:'exceptions.enabled']
28
29
  ::Thor.send(:include, Thor)
29
30
  end
30
31
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.23.0'.freeze
3
+ VERSION = '5.25.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.23.0
4
+ version: 5.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-19 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger