honeybadger 5.29.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/lib/honeybadger/agent.rb +36 -35
  4. data/lib/honeybadger/backend/base.rb +11 -11
  5. data/lib/honeybadger/backend/debug.rb +4 -4
  6. data/lib/honeybadger/backend/null.rb +2 -2
  7. data/lib/honeybadger/backend/server.rb +11 -11
  8. data/lib/honeybadger/backend/test.rb +2 -2
  9. data/lib/honeybadger/backend.rb +6 -6
  10. data/lib/honeybadger/backtrace.rb +27 -22
  11. data/lib/honeybadger/breadcrumbs/active_support.rb +9 -9
  12. data/lib/honeybadger/breadcrumbs/breadcrumb.rb +1 -2
  13. data/lib/honeybadger/breadcrumbs/collector.rb +4 -4
  14. data/lib/honeybadger/breadcrumbs/logging.rb +11 -14
  15. data/lib/honeybadger/breadcrumbs.rb +3 -3
  16. data/lib/honeybadger/cli/deploy.rb +7 -7
  17. data/lib/honeybadger/cli/exec.rb +41 -41
  18. data/lib/honeybadger/cli/helpers.rb +18 -18
  19. data/lib/honeybadger/cli/heroku.rb +36 -36
  20. data/lib/honeybadger/cli/install.rb +44 -44
  21. data/lib/honeybadger/cli/main.rb +107 -107
  22. data/lib/honeybadger/cli/notify.rb +13 -13
  23. data/lib/honeybadger/cli/test.rb +109 -94
  24. data/lib/honeybadger/cli.rb +3 -3
  25. data/lib/honeybadger/config/defaults.rb +218 -218
  26. data/lib/honeybadger/config/env.rb +5 -5
  27. data/lib/honeybadger/config/ruby.rb +19 -19
  28. data/lib/honeybadger/config/yaml.rb +12 -12
  29. data/lib/honeybadger/config.rb +76 -78
  30. data/lib/honeybadger/const.rb +4 -4
  31. data/lib/honeybadger/context_manager.rb +1 -2
  32. data/lib/honeybadger/conversions.rb +9 -6
  33. data/lib/honeybadger/counter.rb +4 -4
  34. data/lib/honeybadger/event.rb +3 -3
  35. data/lib/honeybadger/events_worker.rb +33 -33
  36. data/lib/honeybadger/gauge.rb +2 -2
  37. data/lib/honeybadger/histogram.rb +4 -4
  38. data/lib/honeybadger/init/hanami.rb +5 -5
  39. data/lib/honeybadger/init/rails.rb +14 -14
  40. data/lib/honeybadger/init/rake.rb +19 -21
  41. data/lib/honeybadger/init/ruby.rb +4 -4
  42. data/lib/honeybadger/init/sinatra.rb +11 -12
  43. data/lib/honeybadger/instrumentation.rb +26 -31
  44. data/lib/honeybadger/instrumentation_helper.rb +11 -12
  45. data/lib/honeybadger/karafka.rb +55 -56
  46. data/lib/honeybadger/logging.rb +22 -21
  47. data/lib/honeybadger/metric.rb +2 -2
  48. data/lib/honeybadger/metrics_worker.rb +12 -10
  49. data/lib/honeybadger/notice.rb +55 -58
  50. data/lib/honeybadger/notification_subscriber.rb +14 -14
  51. data/lib/honeybadger/plugin.rb +16 -18
  52. data/lib/honeybadger/plugins/active_job.rb +11 -9
  53. data/lib/honeybadger/plugins/autotuner.rb +5 -5
  54. data/lib/honeybadger/plugins/breadcrumbs.rb +7 -7
  55. data/lib/honeybadger/plugins/delayed_job/plugin.rb +36 -37
  56. data/lib/honeybadger/plugins/delayed_job.rb +4 -4
  57. data/lib/honeybadger/plugins/faktory.rb +9 -9
  58. data/lib/honeybadger/plugins/karafka.rb +3 -3
  59. data/lib/honeybadger/plugins/lambda.rb +9 -11
  60. data/lib/honeybadger/plugins/local_variables.rb +4 -4
  61. data/lib/honeybadger/plugins/net_http.rb +10 -10
  62. data/lib/honeybadger/plugins/passenger.rb +4 -4
  63. data/lib/honeybadger/plugins/rails.rb +13 -9
  64. data/lib/honeybadger/plugins/resque.rb +7 -7
  65. data/lib/honeybadger/plugins/shoryuken.rb +6 -6
  66. data/lib/honeybadger/plugins/sidekiq.rb +61 -57
  67. data/lib/honeybadger/plugins/solid_queue.rb +3 -3
  68. data/lib/honeybadger/plugins/sucker_punch.rb +5 -5
  69. data/lib/honeybadger/plugins/system.rb +3 -3
  70. data/lib/honeybadger/plugins/thor.rb +5 -5
  71. data/lib/honeybadger/plugins/warden.rb +4 -4
  72. data/lib/honeybadger/rack/error_notifier.rb +14 -14
  73. data/lib/honeybadger/rack/user_feedback.rb +11 -12
  74. data/lib/honeybadger/rack/user_informer.rb +6 -6
  75. data/lib/honeybadger/registry.rb +2 -2
  76. data/lib/honeybadger/registry_execution.rb +1 -1
  77. data/lib/honeybadger/ruby.rb +2 -2
  78. data/lib/honeybadger/singleton.rb +49 -48
  79. data/lib/honeybadger/tasks.rb +3 -3
  80. data/lib/honeybadger/timer.rb +1 -1
  81. data/lib/honeybadger/util/http.rb +27 -27
  82. data/lib/honeybadger/util/request_hash.rb +11 -11
  83. data/lib/honeybadger/util/request_payload.rb +2 -2
  84. data/lib/honeybadger/util/revision.rb +14 -6
  85. data/lib/honeybadger/util/sanitizer.rb +22 -22
  86. data/lib/honeybadger/util/stats.rb +6 -3
  87. data/lib/honeybadger/version.rb +1 -1
  88. data/lib/honeybadger/worker.rb +31 -29
  89. data/lib/honeybadger.rb +5 -5
  90. data/lib/puma/plugin/honeybadger.rb +12 -8
  91. metadata +3 -3
@@ -1,7 +1,7 @@
1
- require 'erb'
2
- require 'forwardable'
3
- require 'honeybadger/cli/main'
4
- require 'pathname'
1
+ require "erb"
2
+ require "forwardable"
3
+ require "honeybadger/cli/main"
4
+ require "pathname"
5
5
 
6
6
  module Honeybadger
7
7
  module CLI
@@ -9,11 +9,11 @@ module Honeybadger
9
9
  extend Forwardable
10
10
 
11
11
  TEST_EXCEPTION = begin
12
- exception_name = ENV['EXCEPTION'] || 'HoneybadgerTestingException'
13
- Object.const_get(exception_name)
14
- rescue
15
- Object.const_set(exception_name, Class.new(Exception))
16
- end.new('Testing honeybadger via "honeybadger test". If you can see this, it works.')
12
+ exception_name = ENV["EXCEPTION"] || "HoneybadgerTestingException"
13
+ Object.const_get(exception_name)
14
+ rescue
15
+ Object.const_set(exception_name, Class.new(RuntimeError))
16
+ end.new('Testing honeybadger via "honeybadger test". If you can see this, it works.')
17
17
 
18
18
  class TestBackend
19
19
  def initialize(backend)
@@ -21,7 +21,7 @@ module Honeybadger
21
21
  end
22
22
 
23
23
  def self.callings
24
- @callings ||= Hash.new {|h,k| h[k] = [] }
24
+ @callings ||= Hash.new { |h, k| h[k] = [] }
25
25
  end
26
26
 
27
27
  def self.events
@@ -48,14 +48,14 @@ module Honeybadger
48
48
 
49
49
  def run
50
50
  begin
51
- require File.join(Dir.pwd, 'config', 'environment.rb')
51
+ require File.join(Dir.pwd, "config", "environment.rb")
52
52
  raise LoadError unless defined?(::Rails.application)
53
53
  say("Detected Rails #{Rails::VERSION::STRING}")
54
54
  rescue LoadError
55
- require 'honeybadger/init/ruby'
55
+ require "honeybadger/init/ruby"
56
56
  end
57
57
 
58
- if Honeybadger.config.get(:api_key).to_s =~ BLANK
58
+ if BLANK.match?(Honeybadger.config.get(:api_key).to_s)
59
59
  say("Unable to send test: Honeybadger API key is missing.", :red)
60
60
  exit(1)
61
61
  end
@@ -87,10 +87,10 @@ module Honeybadger
87
87
  end
88
88
 
89
89
  def test_exception_class
90
- exception_name = ENV['EXCEPTION'] || 'HoneybadgerTestingException'
90
+ exception_name = ENV["EXCEPTION"] || "HoneybadgerTestingException"
91
91
  Object.const_get(exception_name)
92
92
  rescue
93
- Object.const_set(exception_name, Class.new(Exception))
93
+ Object.const_set(exception_name, Class.new(RuntimeError))
94
94
  end
95
95
 
96
96
  def run_standalone_test
@@ -104,43 +104,58 @@ module Honeybadger
104
104
  # logging the framework trace (moved to ActionDispatch::DebugExceptions),
105
105
  # which caused cluttered output while running the test task.
106
106
  defined?(::ActionDispatch::DebugExceptions) and
107
- ::ActionDispatch::DebugExceptions.class_eval { def logger(*args) ; @logger ||= Logger.new(nil) ; end }
107
+ ::ActionDispatch::DebugExceptions.class_eval {
108
+ def logger(*args)
109
+ @logger ||= Logger.new(nil)
110
+ end
111
+ }
108
112
  defined?(::ActionDispatch::ShowExceptions) and
109
- ::ActionDispatch::ShowExceptions.class_eval { def logger(*args) ; @logger ||= Logger.new(nil) ; end }
113
+ ::ActionDispatch::ShowExceptions.class_eval {
114
+ def logger(*args)
115
+ @logger ||= Logger.new(nil)
116
+ end
117
+ }
110
118
 
111
119
  # Detect and disable the better_errors gem
112
120
  if defined?(::BetterErrors::Middleware)
113
- say('Better Errors detected: temporarily disabling middleware.', :yellow)
114
- ::BetterErrors::Middleware.class_eval { def call(env) @app.call(env); end }
121
+ say("Better Errors detected: temporarily disabling middleware.", :yellow)
122
+ ::BetterErrors::Middleware.class_eval {
123
+ def call(env)
124
+ @app.call(env)
125
+ end
126
+ }
115
127
  end
116
128
 
117
129
  begin
118
- require './app/controllers/application_controller'
130
+ require "./app/controllers/application_controller"
119
131
  rescue LoadError
120
132
  nil
121
133
  end
122
134
 
123
135
  unless defined?(::ApplicationController)
124
- say('Error: No ApplicationController found.', :red)
136
+ say("Error: No ApplicationController found.", :red)
125
137
  return false
126
138
  end
127
139
 
128
- eval(<<-CONTROLLER)
129
- class Honeybadger::TestController < ApplicationController
130
- # This is to bypass any filters that may prevent access to the action.
131
- if respond_to?(:prepend_before_action)
132
- prepend_before_action :test_honeybadger
133
- else
134
- prepend_before_filter :test_honeybadger
135
- end
136
- def test_honeybadger
137
- puts "Raising '#{Honeybadger::CLI::Test::TEST_EXCEPTION.class.name}' to simulate application failure."
138
- raise Honeybadger::CLI::Test::TEST_EXCEPTION
140
+ # Define the test controller class
141
+ controller_code = <<~RUBY
142
+ class Honeybadger::TestController < ApplicationController
143
+ # This is to bypass any filters that may prevent access to the action.
144
+ if respond_to?(:prepend_before_action)
145
+ prepend_before_action :test_honeybadger
146
+ else
147
+ prepend_before_filter :test_honeybadger
148
+ end
149
+ def test_honeybadger
150
+ puts "Raising '\#{Honeybadger::CLI::Test::TEST_EXCEPTION.class.name}' to simulate application failure."
151
+ raise Honeybadger::CLI::Test::TEST_EXCEPTION
152
+ end
153
+ # Ensure we actually have an action to go to.
154
+ def verify; end
139
155
  end
140
- # Ensure we actually have an action to go to.
141
- def verify; end
142
- end
143
- CONTROLLER
156
+ RUBY
157
+
158
+ Honeybadger.module_eval(controller_code, __FILE__, __LINE__)
144
159
 
145
160
  ::Rails.application.try(:reload_routes_unless_loaded)
146
161
  ::Rails.application.routes.tap do |r|
@@ -152,9 +167,9 @@ module Honeybadger
152
167
  r.disable_clear_and_finalize = true
153
168
  r.clear!
154
169
  r.draw do
155
- match 'verify' => 'honeybadger/test#verify', :as => "verify_#{SecureRandom.hex}", :via => :get
170
+ match "verify" => "honeybadger/test#verify", :as => "verify_#{SecureRandom.hex}", :via => :get
156
171
  end
157
- ::Rails.application.routes_reloader.paths.each{ |path| load(path) }
172
+ ::Rails.application.routes_reloader.paths.each { |path| load(path) }
158
173
  ::ActiveSupport.on_load(:action_controller) { r.finalize! }
159
174
  ensure
160
175
  r.disable_clear_and_finalize = d
@@ -162,7 +177,7 @@ module Honeybadger
162
177
  end
163
178
 
164
179
  ssl = defined?(::Rails.configuration.force_ssl) && ::Rails.configuration.force_ssl
165
- env = ::Rack::MockRequest.env_for("http#{ ssl ? 's' : nil }://www.example.com/verify", 'REMOTE_ADDR' => '127.0.0.1', 'HTTP_HOST' => 'localhost')
180
+ env = ::Rack::MockRequest.env_for("http#{ssl ? "s" : nil}://www.example.com/verify", "REMOTE_ADDR" => "127.0.0.1", "HTTP_HOST" => "localhost")
166
181
 
167
182
  ::Rails.application.call(env)
168
183
  end
@@ -170,28 +185,28 @@ module Honeybadger
170
185
  def verify_test
171
186
  Honeybadger.flush
172
187
 
173
- if calling = TestBackend.callings[:notices].find {|c| c[0].exception.eql?(TEST_EXCEPTION) }
174
- notice, response = *calling
188
+ if (calling = TestBackend.callings[:notices].find { |c| c[0].exception.eql?(TEST_EXCEPTION) })
189
+ _, response = *calling
175
190
 
176
191
  if !response.success?
177
- host = Honeybadger.config.get(:'connection.host')
178
- say(<<-MSG, :red)
179
- !! --- Honeybadger test failed ------------------------------------------------ !!
192
+ host = Honeybadger.config.get(:"connection.host")
193
+ say(<<~MSG, :red)
194
+ !! --- Honeybadger test failed ------------------------------------------------ !!
180
195
 
181
- The error notifier is installed, but we encountered an error:
196
+ The error notifier is installed, but we encountered an error:
182
197
 
183
- #{response.error_message}
198
+ #{response.error_message}
184
199
 
185
- To fix this issue, please try the following:
200
+ To fix this issue, please try the following:
186
201
 
187
- - Make sure the gem is configured properly.
188
- - Retry executing this command a few times.
189
- - Make sure you can connect to #{host} (`curl https://#{host}/v1/notices`).
190
- - Email support@honeybadger.io for help. Include as much debug info as you
191
- can for a faster resolution!
202
+ - Make sure the gem is configured properly.
203
+ - Retry executing this command a few times.
204
+ - Make sure you can connect to #{host} (`curl https://#{host}/v1/notices`).
205
+ - Email support@honeybadger.io for help. Include as much debug info as you
206
+ can for a faster resolution!
192
207
 
193
- !! --- End -------------------------------------------------------------------- !!
194
- MSG
208
+ !! --- End -------------------------------------------------------------------- !!
209
+ MSG
195
210
  exit(1)
196
211
  end
197
212
 
@@ -200,27 +215,27 @@ MSG
200
215
  exit(0)
201
216
  end
202
217
 
203
- say(<<-MSG, :red)
204
- !! --- Honeybadger test failed ------------------------------------------------ !!
218
+ say(<<~MSG, :red)
219
+ !! --- Honeybadger test failed ------------------------------------------------ !!
205
220
 
206
- Error: The test exception was not reported; the application may not be
207
- configured properly.
221
+ Error: The test exception was not reported; the application may not be
222
+ configured properly.
208
223
 
209
- This is usually caused by one of the following issues:
224
+ This is usually caused by one of the following issues:
210
225
 
211
- - There was a problem loading your application. Check your logs to see if a
212
- different exception is being raised.
213
- - The exception is being rescued before it reaches our Rack middleware. If
214
- you're using `rescue` or `rescue_from` you may need to notify Honeybadger
215
- manually: `Honeybadger.notify(exception)`.
216
- - The honeybadger gem is misconfigured. Check the settings in your
217
- honeybadger.yml file.
218
- MSG
226
+ - There was a problem loading your application. Check your logs to see if a
227
+ different exception is being raised.
228
+ - The exception is being rescued before it reaches our Rack middleware. If
229
+ you're using `rescue` or `rescue_from` you may need to notify Honeybadger
230
+ manually: `Honeybadger.notify(exception)`.
231
+ - The honeybadger gem is misconfigured. Check the settings in your
232
+ honeybadger.yml file.
233
+ MSG
219
234
 
220
235
  notices = TestBackend.callings[:notices].map(&:first)
221
236
  unless notices.empty?
222
237
  say("\nThe following errors were reported:", :red)
223
- notices.each {|n| say("\n - #{n.error_class}: #{n.error_message}", :red) }
238
+ notices.each { |n| say("\n - #{n.error_class}: #{n.error_message}", :red) }
224
239
  end
225
240
 
226
241
  say("\nSee https://docs.honeybadger.io/gem-troubleshooting for more troubleshooting help.\n\n", :red)
@@ -230,48 +245,48 @@ MSG
230
245
  end
231
246
 
232
247
  def generate_success_message(response)
233
- notice_id = JSON.parse(response.body)['id']
248
+ notice_id = JSON.parse(response.body)["id"]
234
249
  notice_url = "https://app.honeybadger.io/notice/#{notice_id}"
235
250
 
236
251
  unless options[:install]
237
252
  return "⚡ Success: #{notice_url}"
238
253
  end
239
254
 
240
- <<-MSG
241
- ⚡ --- Honeybadger is installed! -----------------------------------------------
255
+ <<~MSG
256
+ ⚡ --- Honeybadger is installed! -----------------------------------------------
242
257
 
243
- Good news: You're one deploy away from seeing all of your exceptions in
244
- Honeybadger. For now, we've generated a test exception for you:
258
+ Good news: You're one deploy away from seeing all of your exceptions in
259
+ Honeybadger. For now, we've generated a test exception for you:
245
260
 
246
- #{notice_url}
261
+ #{notice_url}
247
262
 
248
- Optional steps:
263
+ Optional steps:
249
264
 
250
- - Show a feedback form on your error page:
251
- https://docs.honeybadger.io/gem-feedback
252
- - Show a UUID or link to Honeybadger on your error page:
253
- https://docs.honeybadger.io/gem-informer
254
- - Track deployments (if you're using Capistrano, we already did this):
255
- https://docs.honeybadger.io/gem-deploys
265
+ - Show a feedback form on your error page:
266
+ https://docs.honeybadger.io/gem-feedback
267
+ - Show a UUID or link to Honeybadger on your error page:
268
+ https://docs.honeybadger.io/gem-informer
269
+ - Track deployments (if you're using Capistrano, we already did this):
270
+ https://docs.honeybadger.io/gem-deploys
256
271
 
257
- If you ever need help:
272
+ If you ever need help:
258
273
 
259
- - Read the gem troubleshooting guide: https://docs.honeybadger.io/gem-troubleshooting
260
- - Check out our documentation: https://docs.honeybadger.io/
261
- - Email the founders: support@honeybadger.io
274
+ - Read the gem troubleshooting guide: https://docs.honeybadger.io/gem-troubleshooting
275
+ - Check out our documentation: https://docs.honeybadger.io/
276
+ - Email the founders: support@honeybadger.io
262
277
 
263
- Most people don't realize that Honeybadger is a small, bootstrapped company. We
264
- really couldn't do this without you. Thank you for allowing us to do what we
265
- love: making developers awesome.
278
+ Most people don't realize that Honeybadger is a small, bootstrapped company. We
279
+ really couldn't do this without you. Thank you for allowing us to do what we
280
+ love: making developers awesome.
266
281
 
267
- Happy 'badgering!
282
+ Happy 'badgering!
268
283
 
269
- Sincerely,
270
- The Honeybadger Crew
271
- https://www.honeybadger.io/about/
284
+ Sincerely,
285
+ The Honeybadger Crew
286
+ https://www.honeybadger.io/about/
272
287
 
273
- ⚡ --- End --------------------------------------------------------------------
274
- MSG
288
+ ⚡ --- End --------------------------------------------------------------------
289
+ MSG
275
290
  end
276
291
  end
277
292
  end
@@ -1,8 +1,8 @@
1
- $:.unshift(File.expand_path('../../../vendor/cli', __FILE__))
1
+ $:.unshift(File.expand_path("../../../vendor/cli", __FILE__))
2
2
 
3
- require 'thor'
3
+ require "thor"
4
4
 
5
- require 'honeybadger/cli/main'
5
+ require "honeybadger/cli/main"
6
6
 
7
7
  module Honeybadger
8
8
  # @api private