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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/honeybadger/agent.rb +36 -35
- data/lib/honeybadger/backend/base.rb +11 -11
- data/lib/honeybadger/backend/debug.rb +4 -4
- data/lib/honeybadger/backend/null.rb +2 -2
- data/lib/honeybadger/backend/server.rb +11 -11
- data/lib/honeybadger/backend/test.rb +2 -2
- data/lib/honeybadger/backend.rb +6 -6
- data/lib/honeybadger/backtrace.rb +27 -22
- data/lib/honeybadger/breadcrumbs/active_support.rb +9 -9
- data/lib/honeybadger/breadcrumbs/breadcrumb.rb +1 -2
- data/lib/honeybadger/breadcrumbs/collector.rb +4 -4
- data/lib/honeybadger/breadcrumbs/logging.rb +11 -14
- data/lib/honeybadger/breadcrumbs.rb +3 -3
- data/lib/honeybadger/cli/deploy.rb +7 -7
- data/lib/honeybadger/cli/exec.rb +41 -41
- data/lib/honeybadger/cli/helpers.rb +18 -18
- data/lib/honeybadger/cli/heroku.rb +36 -36
- data/lib/honeybadger/cli/install.rb +44 -44
- data/lib/honeybadger/cli/main.rb +107 -107
- data/lib/honeybadger/cli/notify.rb +13 -13
- data/lib/honeybadger/cli/test.rb +109 -94
- data/lib/honeybadger/cli.rb +3 -3
- data/lib/honeybadger/config/defaults.rb +218 -218
- data/lib/honeybadger/config/env.rb +5 -5
- data/lib/honeybadger/config/ruby.rb +19 -19
- data/lib/honeybadger/config/yaml.rb +12 -12
- data/lib/honeybadger/config.rb +76 -78
- data/lib/honeybadger/const.rb +4 -4
- data/lib/honeybadger/context_manager.rb +1 -2
- data/lib/honeybadger/conversions.rb +9 -6
- data/lib/honeybadger/counter.rb +4 -4
- data/lib/honeybadger/event.rb +3 -3
- data/lib/honeybadger/events_worker.rb +33 -33
- data/lib/honeybadger/gauge.rb +2 -2
- data/lib/honeybadger/histogram.rb +4 -4
- data/lib/honeybadger/init/hanami.rb +5 -5
- data/lib/honeybadger/init/rails.rb +14 -14
- data/lib/honeybadger/init/rake.rb +19 -21
- data/lib/honeybadger/init/ruby.rb +4 -4
- data/lib/honeybadger/init/sinatra.rb +11 -12
- data/lib/honeybadger/instrumentation.rb +26 -31
- data/lib/honeybadger/instrumentation_helper.rb +11 -12
- data/lib/honeybadger/karafka.rb +55 -56
- data/lib/honeybadger/logging.rb +22 -21
- data/lib/honeybadger/metric.rb +2 -2
- data/lib/honeybadger/metrics_worker.rb +12 -10
- data/lib/honeybadger/notice.rb +55 -58
- data/lib/honeybadger/notification_subscriber.rb +14 -14
- data/lib/honeybadger/plugin.rb +16 -18
- data/lib/honeybadger/plugins/active_job.rb +11 -9
- data/lib/honeybadger/plugins/autotuner.rb +5 -5
- data/lib/honeybadger/plugins/breadcrumbs.rb +7 -7
- data/lib/honeybadger/plugins/delayed_job/plugin.rb +36 -37
- data/lib/honeybadger/plugins/delayed_job.rb +4 -4
- data/lib/honeybadger/plugins/faktory.rb +9 -9
- data/lib/honeybadger/plugins/karafka.rb +3 -3
- data/lib/honeybadger/plugins/lambda.rb +9 -11
- data/lib/honeybadger/plugins/local_variables.rb +4 -4
- data/lib/honeybadger/plugins/net_http.rb +10 -10
- data/lib/honeybadger/plugins/passenger.rb +4 -4
- data/lib/honeybadger/plugins/rails.rb +13 -9
- data/lib/honeybadger/plugins/resque.rb +7 -7
- data/lib/honeybadger/plugins/shoryuken.rb +6 -6
- data/lib/honeybadger/plugins/sidekiq.rb +61 -57
- data/lib/honeybadger/plugins/solid_queue.rb +3 -3
- data/lib/honeybadger/plugins/sucker_punch.rb +5 -5
- data/lib/honeybadger/plugins/system.rb +3 -3
- data/lib/honeybadger/plugins/thor.rb +5 -5
- data/lib/honeybadger/plugins/warden.rb +4 -4
- data/lib/honeybadger/rack/error_notifier.rb +14 -14
- data/lib/honeybadger/rack/user_feedback.rb +11 -12
- data/lib/honeybadger/rack/user_informer.rb +6 -6
- data/lib/honeybadger/registry.rb +2 -2
- data/lib/honeybadger/registry_execution.rb +1 -1
- data/lib/honeybadger/ruby.rb +2 -2
- data/lib/honeybadger/singleton.rb +49 -48
- data/lib/honeybadger/tasks.rb +3 -3
- data/lib/honeybadger/timer.rb +1 -1
- data/lib/honeybadger/util/http.rb +27 -27
- data/lib/honeybadger/util/request_hash.rb +11 -11
- data/lib/honeybadger/util/request_payload.rb +2 -2
- data/lib/honeybadger/util/revision.rb +14 -6
- data/lib/honeybadger/util/sanitizer.rb +22 -22
- data/lib/honeybadger/util/stats.rb +6 -3
- data/lib/honeybadger/version.rb +1 -1
- data/lib/honeybadger/worker.rb +31 -29
- data/lib/honeybadger.rb +5 -5
- data/lib/puma/plugin/honeybadger.rb +12 -8
- metadata +3 -3
data/lib/honeybadger/cli/test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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,
|
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
|
55
|
+
require "honeybadger/init/ruby"
|
56
56
|
end
|
57
57
|
|
58
|
-
if Honeybadger.config.get(:api_key).to_s
|
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[
|
90
|
+
exception_name = ENV["EXCEPTION"] || "HoneybadgerTestingException"
|
91
91
|
Object.const_get(exception_name)
|
92
92
|
rescue
|
93
|
-
Object.const_set(exception_name, Class.new(
|
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 {
|
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 {
|
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(
|
114
|
-
::BetterErrors::Middleware.class_eval {
|
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
|
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(
|
136
|
+
say("Error: No ApplicationController found.", :red)
|
125
137
|
return false
|
126
138
|
end
|
127
139
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
-
|
141
|
-
|
142
|
-
|
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
|
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#{
|
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
|
-
|
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(:
|
178
|
-
say(
|
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
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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(
|
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
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
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)[
|
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
|
-
|
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
|
-
|
261
|
+
#{notice_url}
|
247
262
|
|
248
|
-
Optional steps:
|
263
|
+
Optional steps:
|
249
264
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
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
|
-
|
260
|
-
|
261
|
-
|
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
|
data/lib/honeybadger/cli.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
$:.unshift(File.expand_path(
|
1
|
+
$:.unshift(File.expand_path("../../../vendor/cli", __FILE__))
|
2
2
|
|
3
|
-
require
|
3
|
+
require "thor"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "honeybadger/cli/main"
|
6
6
|
|
7
7
|
module Honeybadger
|
8
8
|
# @api private
|