honeybadger 4.12.2 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +713 -673
- data/LICENSE +19 -19
- data/README.md +57 -57
- data/TROUBLESHOOTING.md +3 -3
- data/bin/honeybadger +5 -5
- data/lib/honeybadger/agent.rb +488 -481
- data/lib/honeybadger/backend/base.rb +116 -116
- data/lib/honeybadger/backend/debug.rb +22 -22
- data/lib/honeybadger/backend/null.rb +29 -29
- data/lib/honeybadger/backend/server.rb +62 -62
- data/lib/honeybadger/backend/test.rb +46 -45
- data/lib/honeybadger/backend.rb +27 -27
- data/lib/honeybadger/backtrace.rb +181 -181
- data/lib/honeybadger/breadcrumbs/active_support.rb +119 -119
- data/lib/honeybadger/breadcrumbs/breadcrumb.rb +53 -53
- data/lib/honeybadger/breadcrumbs/collector.rb +82 -82
- data/lib/honeybadger/breadcrumbs/logging.rb +51 -51
- data/lib/honeybadger/breadcrumbs/ring_buffer.rb +44 -44
- data/lib/honeybadger/breadcrumbs.rb +8 -8
- data/lib/honeybadger/cli/deploy.rb +43 -43
- data/lib/honeybadger/cli/exec.rb +143 -143
- data/lib/honeybadger/cli/helpers.rb +28 -28
- data/lib/honeybadger/cli/heroku.rb +129 -129
- data/lib/honeybadger/cli/install.rb +101 -101
- data/lib/honeybadger/cli/main.rb +237 -237
- data/lib/honeybadger/cli/notify.rb +67 -67
- data/lib/honeybadger/cli/test.rb +267 -267
- data/lib/honeybadger/cli.rb +14 -14
- data/lib/honeybadger/config/defaults.rb +336 -327
- data/lib/honeybadger/config/env.rb +42 -42
- data/lib/honeybadger/config/ruby.rb +146 -146
- data/lib/honeybadger/config/yaml.rb +76 -76
- data/lib/honeybadger/config.rb +413 -413
- data/lib/honeybadger/const.rb +20 -20
- data/lib/honeybadger/context_manager.rb +55 -55
- data/lib/honeybadger/conversions.rb +16 -16
- data/lib/honeybadger/init/rails.rb +38 -35
- data/lib/honeybadger/init/rake.rb +66 -66
- data/lib/honeybadger/init/ruby.rb +11 -11
- data/lib/honeybadger/init/sinatra.rb +51 -51
- data/lib/honeybadger/logging.rb +177 -177
- data/lib/honeybadger/notice.rb +579 -568
- data/lib/honeybadger/plugin.rb +210 -210
- data/lib/honeybadger/plugins/breadcrumbs.rb +111 -111
- data/lib/honeybadger/plugins/delayed_job/plugin.rb +56 -56
- data/lib/honeybadger/plugins/delayed_job.rb +22 -22
- data/lib/honeybadger/plugins/faktory.rb +52 -52
- data/lib/honeybadger/plugins/lambda.rb +71 -71
- data/lib/honeybadger/plugins/local_variables.rb +44 -44
- data/lib/honeybadger/plugins/passenger.rb +23 -23
- data/lib/honeybadger/plugins/rails.rb +72 -48
- data/lib/honeybadger/plugins/resque.rb +72 -72
- data/lib/honeybadger/plugins/shoryuken.rb +52 -52
- data/lib/honeybadger/plugins/sidekiq.rb +71 -62
- data/lib/honeybadger/plugins/sucker_punch.rb +18 -18
- data/lib/honeybadger/plugins/thor.rb +32 -32
- data/lib/honeybadger/plugins/warden.rb +19 -19
- data/lib/honeybadger/rack/error_notifier.rb +92 -92
- data/lib/honeybadger/rack/user_feedback.rb +88 -88
- data/lib/honeybadger/rack/user_informer.rb +45 -45
- data/lib/honeybadger/ruby.rb +2 -2
- data/lib/honeybadger/singleton.rb +103 -103
- data/lib/honeybadger/tasks.rb +22 -22
- data/lib/honeybadger/templates/feedback_form.erb +84 -84
- data/lib/honeybadger/util/http.rb +92 -92
- data/lib/honeybadger/util/lambda.rb +32 -32
- data/lib/honeybadger/util/request_hash.rb +73 -73
- data/lib/honeybadger/util/request_payload.rb +41 -41
- data/lib/honeybadger/util/revision.rb +39 -39
- data/lib/honeybadger/util/sanitizer.rb +214 -214
- data/lib/honeybadger/util/sql.rb +34 -34
- data/lib/honeybadger/util/stats.rb +50 -50
- data/lib/honeybadger/version.rb +4 -4
- data/lib/honeybadger/worker.rb +253 -253
- data/lib/honeybadger.rb +11 -11
- data/resources/ca-bundle.crt +3376 -3376
- data/vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb +5 -5
- data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +89 -89
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano/legacy.rb +47 -47
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -2
- data/vendor/cli/inifile.rb +628 -628
- data/vendor/cli/thor/actions/create_file.rb +103 -103
- data/vendor/cli/thor/actions/create_link.rb +59 -59
- data/vendor/cli/thor/actions/directory.rb +118 -118
- data/vendor/cli/thor/actions/empty_directory.rb +135 -135
- data/vendor/cli/thor/actions/file_manipulation.rb +316 -316
- data/vendor/cli/thor/actions/inject_into_file.rb +107 -107
- data/vendor/cli/thor/actions.rb +319 -319
- data/vendor/cli/thor/base.rb +656 -656
- data/vendor/cli/thor/command.rb +133 -133
- data/vendor/cli/thor/core_ext/hash_with_indifferent_access.rb +77 -77
- data/vendor/cli/thor/core_ext/io_binary_read.rb +10 -10
- data/vendor/cli/thor/core_ext/ordered_hash.rb +98 -98
- data/vendor/cli/thor/error.rb +32 -32
- data/vendor/cli/thor/group.rb +281 -281
- data/vendor/cli/thor/invocation.rb +178 -178
- data/vendor/cli/thor/line_editor/basic.rb +35 -35
- data/vendor/cli/thor/line_editor/readline.rb +88 -88
- data/vendor/cli/thor/line_editor.rb +17 -17
- data/vendor/cli/thor/parser/argument.rb +73 -73
- data/vendor/cli/thor/parser/arguments.rb +175 -175
- data/vendor/cli/thor/parser/option.rb +125 -125
- data/vendor/cli/thor/parser/options.rb +218 -218
- data/vendor/cli/thor/parser.rb +4 -4
- data/vendor/cli/thor/rake_compat.rb +71 -71
- data/vendor/cli/thor/runner.rb +322 -322
- data/vendor/cli/thor/shell/basic.rb +421 -421
- data/vendor/cli/thor/shell/color.rb +149 -149
- data/vendor/cli/thor/shell/html.rb +126 -126
- data/vendor/cli/thor/shell.rb +81 -81
- data/vendor/cli/thor/util.rb +267 -267
- data/vendor/cli/thor/version.rb +3 -3
- data/vendor/cli/thor.rb +484 -484
- metadata +10 -5
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'delayed_job'
|
2
|
-
require 'honeybadger/ruby'
|
3
|
-
|
4
|
-
module Honeybadger
|
5
|
-
module Plugins
|
6
|
-
module DelayedJob
|
7
|
-
class Plugin < ::Delayed::Plugin
|
8
|
-
callbacks do |lifecycle|
|
9
|
-
lifecycle.around(:invoke_job) do |job, &block|
|
10
|
-
begin
|
11
|
-
|
12
|
-
begin
|
13
|
-
if job.payload_object.class.name == 'ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper'
|
14
|
-
#buildin support for Rails 4.2 ActiveJob
|
15
|
-
component = job.payload_object.job_data['job_class']
|
16
|
-
action = 'perform'
|
17
|
-
else
|
18
|
-
#buildin support for Delayed::PerformableMethod
|
19
|
-
component = job.payload_object.object.is_a?(Class) ? job.payload_object.object.name : job.payload_object.object.class.name
|
20
|
-
action = job.payload_object.method_name.to_s
|
21
|
-
end
|
22
|
-
rescue #fallback to support all other classes
|
23
|
-
component = job.payload_object.class.name
|
24
|
-
action = 'perform'
|
25
|
-
end
|
26
|
-
|
27
|
-
::Honeybadger.context(
|
28
|
-
:component => component,
|
29
|
-
:action => action,
|
30
|
-
:job_id => job.id,
|
31
|
-
:handler => job.handler,
|
32
|
-
:last_error => job.last_error,
|
33
|
-
:attempts => job.attempts,
|
34
|
-
:queue => job.queue
|
35
|
-
)
|
36
|
-
|
37
|
-
block.call(job)
|
38
|
-
rescue Exception => error
|
39
|
-
::Honeybadger.notify(
|
40
|
-
:component => component,
|
41
|
-
:action => action,
|
42
|
-
:error_class => error.class.name,
|
43
|
-
:error_message => "#{ error.class.name }: #{ error.message }",
|
44
|
-
:backtrace => error.backtrace,
|
45
|
-
:exception => error
|
46
|
-
) if job.attempts.to_i >= ::Honeybadger.config[:'delayed_job.attempt_threshold'].to_i
|
47
|
-
raise error
|
48
|
-
ensure
|
49
|
-
::Honeybadger.clear!
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
1
|
+
require 'delayed_job'
|
2
|
+
require 'honeybadger/ruby'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
module Plugins
|
6
|
+
module DelayedJob
|
7
|
+
class Plugin < ::Delayed::Plugin
|
8
|
+
callbacks do |lifecycle|
|
9
|
+
lifecycle.around(:invoke_job) do |job, &block|
|
10
|
+
begin
|
11
|
+
|
12
|
+
begin
|
13
|
+
if job.payload_object.class.name == 'ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper'
|
14
|
+
#buildin support for Rails 4.2 ActiveJob
|
15
|
+
component = job.payload_object.job_data['job_class']
|
16
|
+
action = 'perform'
|
17
|
+
else
|
18
|
+
#buildin support for Delayed::PerformableMethod
|
19
|
+
component = job.payload_object.object.is_a?(Class) ? job.payload_object.object.name : job.payload_object.object.class.name
|
20
|
+
action = job.payload_object.method_name.to_s
|
21
|
+
end
|
22
|
+
rescue #fallback to support all other classes
|
23
|
+
component = job.payload_object.class.name
|
24
|
+
action = 'perform'
|
25
|
+
end
|
26
|
+
|
27
|
+
::Honeybadger.context(
|
28
|
+
:component => component,
|
29
|
+
:action => action,
|
30
|
+
:job_id => job.id,
|
31
|
+
:handler => job.handler,
|
32
|
+
:last_error => job.last_error,
|
33
|
+
:attempts => job.attempts,
|
34
|
+
:queue => job.queue
|
35
|
+
)
|
36
|
+
|
37
|
+
block.call(job)
|
38
|
+
rescue Exception => error
|
39
|
+
::Honeybadger.notify(
|
40
|
+
:component => component,
|
41
|
+
:action => action,
|
42
|
+
:error_class => error.class.name,
|
43
|
+
:error_message => "#{ error.class.name }: #{ error.message }",
|
44
|
+
:backtrace => error.backtrace,
|
45
|
+
:exception => error
|
46
|
+
) if job.attempts.to_i >= ::Honeybadger.config[:'delayed_job.attempt_threshold'].to_i
|
47
|
+
raise error
|
48
|
+
ensure
|
49
|
+
::Honeybadger.clear!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require 'honeybadger/plugin'
|
2
|
-
|
3
|
-
module Honeybadger
|
4
|
-
Plugin.register do
|
5
|
-
requirement { defined?(::Delayed::Plugin) }
|
6
|
-
requirement { defined?(::Delayed::Worker.plugins) }
|
7
|
-
requirement do
|
8
|
-
if delayed_job_honeybadger = defined?(::Delayed::Plugins::Honeybadger)
|
9
|
-
logger.warn("Support for Delayed Job has been moved " \
|
10
|
-
"to the honeybadger gem. Please remove " \
|
11
|
-
"delayed_job_honeybadger from your " \
|
12
|
-
"Gemfile.")
|
13
|
-
end
|
14
|
-
!delayed_job_honeybadger
|
15
|
-
end
|
16
|
-
|
17
|
-
execution do
|
18
|
-
require 'honeybadger/plugins/delayed_job/plugin'
|
19
|
-
::Delayed::Worker.plugins << Plugins::DelayedJob::Plugin
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
require 'honeybadger/plugin'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
Plugin.register do
|
5
|
+
requirement { defined?(::Delayed::Plugin) }
|
6
|
+
requirement { defined?(::Delayed::Worker.plugins) }
|
7
|
+
requirement do
|
8
|
+
if delayed_job_honeybadger = defined?(::Delayed::Plugins::Honeybadger)
|
9
|
+
logger.warn("Support for Delayed Job has been moved " \
|
10
|
+
"to the honeybadger gem. Please remove " \
|
11
|
+
"delayed_job_honeybadger from your " \
|
12
|
+
"Gemfile.")
|
13
|
+
end
|
14
|
+
!delayed_job_honeybadger
|
15
|
+
end
|
16
|
+
|
17
|
+
execution do
|
18
|
+
require 'honeybadger/plugins/delayed_job/plugin'
|
19
|
+
::Delayed::Worker.plugins << Plugins::DelayedJob::Plugin
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,52 +1,52 @@
|
|
1
|
-
require 'honeybadger/plugin'
|
2
|
-
require 'honeybadger/ruby'
|
3
|
-
|
4
|
-
module Honeybadger
|
5
|
-
module Plugins
|
6
|
-
module Faktory
|
7
|
-
class Middleware
|
8
|
-
def call(worker, job)
|
9
|
-
Honeybadger.clear!
|
10
|
-
yield
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Plugin.register do
|
15
|
-
requirement { defined?(::Faktory) }
|
16
|
-
|
17
|
-
execution do
|
18
|
-
::Faktory.configure_worker do |faktory|
|
19
|
-
faktory.worker_middleware do |chain|
|
20
|
-
chain.prepend Middleware
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
::Faktory.configure_worker do |faktory|
|
25
|
-
faktory.error_handlers << lambda do |ex, params|
|
26
|
-
opts = {parameters: params}
|
27
|
-
|
28
|
-
if job = params[:job]
|
29
|
-
if (threshold = config[:'faktory.attempt_threshold'].to_i) > 0
|
30
|
-
# If job.failure is nil, it is the first attempt. The first
|
31
|
-
# retry has a job.failure.retry_count of 0, which would be
|
32
|
-
# the second attempt in our case.
|
33
|
-
retry_count = job.dig('failure', 'retry_count')
|
34
|
-
attempt = retry_count ? retry_count + 1 : 0
|
35
|
-
|
36
|
-
limit = [job['retry'].to_i, threshold].min
|
37
|
-
|
38
|
-
return if attempt < limit
|
39
|
-
end
|
40
|
-
|
41
|
-
opts[:component] = job['jobtype']
|
42
|
-
opts[:action] = 'perform'
|
43
|
-
end
|
44
|
-
|
45
|
-
Honeybadger.notify(ex, opts)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
1
|
+
require 'honeybadger/plugin'
|
2
|
+
require 'honeybadger/ruby'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
module Plugins
|
6
|
+
module Faktory
|
7
|
+
class Middleware
|
8
|
+
def call(worker, job)
|
9
|
+
Honeybadger.clear!
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Plugin.register do
|
15
|
+
requirement { defined?(::Faktory) }
|
16
|
+
|
17
|
+
execution do
|
18
|
+
::Faktory.configure_worker do |faktory|
|
19
|
+
faktory.worker_middleware do |chain|
|
20
|
+
chain.prepend Middleware
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
::Faktory.configure_worker do |faktory|
|
25
|
+
faktory.error_handlers << lambda do |ex, params|
|
26
|
+
opts = {parameters: params}
|
27
|
+
|
28
|
+
if job = params[:job]
|
29
|
+
if (threshold = config[:'faktory.attempt_threshold'].to_i) > 0
|
30
|
+
# If job.failure is nil, it is the first attempt. The first
|
31
|
+
# retry has a job.failure.retry_count of 0, which would be
|
32
|
+
# the second attempt in our case.
|
33
|
+
retry_count = job.dig('failure', 'retry_count')
|
34
|
+
attempt = retry_count ? retry_count + 1 : 0
|
35
|
+
|
36
|
+
limit = [job['retry'].to_i, threshold].min
|
37
|
+
|
38
|
+
return if attempt < limit
|
39
|
+
end
|
40
|
+
|
41
|
+
opts[:component] = job['jobtype']
|
42
|
+
opts[:action] = 'perform'
|
43
|
+
end
|
44
|
+
|
45
|
+
Honeybadger.notify(ex, opts)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,71 +1,71 @@
|
|
1
|
-
require 'honeybadger/plugin'
|
2
|
-
require 'honeybadger/util/lambda'
|
3
|
-
|
4
|
-
module Honeybadger
|
5
|
-
module Plugins
|
6
|
-
module LambdaExtension
|
7
|
-
# Wrap Lambda handlers so exceptions can be automatically captured
|
8
|
-
#
|
9
|
-
# Usage:
|
10
|
-
#
|
11
|
-
# # Automatically included in the top-level main object
|
12
|
-
# hb_wrap_handler :my_handler_1, :my_handler_2
|
13
|
-
#
|
14
|
-
# def my_handler_1(event:, context:)
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# class MyLambdaApp
|
18
|
-
# extend ::Honeybadger::Plugins::LambdaExtension
|
19
|
-
#
|
20
|
-
# hb_wrap_handler :my_handler_1, :my_handler_2
|
21
|
-
#
|
22
|
-
# def self.my_handler_1(event:, context:)
|
23
|
-
# end
|
24
|
-
# end
|
25
|
-
def hb_wrap_handler(*handler_names)
|
26
|
-
mod = Module.new do
|
27
|
-
handler_names.each do |handler|
|
28
|
-
define_method(handler) do |event:, context:|
|
29
|
-
begin
|
30
|
-
Honeybadger.context(aws_request_id: context.aws_request_id) if context.respond_to?(:aws_request_id)
|
31
|
-
|
32
|
-
super(event: event, context: context)
|
33
|
-
rescue => e
|
34
|
-
Honeybadger.notify(e)
|
35
|
-
raise
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
self.singleton_class.prepend(mod)
|
42
|
-
Kernel.singleton_class.prepend(mod) if self == TOPLEVEL_BINDING.eval("self")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# @api private
|
47
|
-
Plugin.register :lambda do
|
48
|
-
requirement { Util::Lambda.lambda_execution? }
|
49
|
-
|
50
|
-
execution do
|
51
|
-
config[:sync] = true
|
52
|
-
config[:'exceptions.notify_at_exit'] = false
|
53
|
-
|
54
|
-
main = TOPLEVEL_BINDING.eval("self")
|
55
|
-
main.extend(LambdaExtension)
|
56
|
-
|
57
|
-
(config[:before_notify] ||= []) << lambda do |notice|
|
58
|
-
data = Util::Lambda.normalized_data
|
59
|
-
|
60
|
-
notice.component = data["function"]
|
61
|
-
notice.action = data["handler"]
|
62
|
-
notice.details["Lambda Details"] = data
|
63
|
-
|
64
|
-
if (trace_id = Util::Lambda.trace_id)
|
65
|
-
notice.context[:lambda_trace_id] = trace_id
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
1
|
+
require 'honeybadger/plugin'
|
2
|
+
require 'honeybadger/util/lambda'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
module Plugins
|
6
|
+
module LambdaExtension
|
7
|
+
# Wrap Lambda handlers so exceptions can be automatically captured
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
#
|
11
|
+
# # Automatically included in the top-level main object
|
12
|
+
# hb_wrap_handler :my_handler_1, :my_handler_2
|
13
|
+
#
|
14
|
+
# def my_handler_1(event:, context:)
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# class MyLambdaApp
|
18
|
+
# extend ::Honeybadger::Plugins::LambdaExtension
|
19
|
+
#
|
20
|
+
# hb_wrap_handler :my_handler_1, :my_handler_2
|
21
|
+
#
|
22
|
+
# def self.my_handler_1(event:, context:)
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
def hb_wrap_handler(*handler_names)
|
26
|
+
mod = Module.new do
|
27
|
+
handler_names.each do |handler|
|
28
|
+
define_method(handler) do |event:, context:|
|
29
|
+
begin
|
30
|
+
Honeybadger.context(aws_request_id: context.aws_request_id) if context.respond_to?(:aws_request_id)
|
31
|
+
|
32
|
+
super(event: event, context: context)
|
33
|
+
rescue => e
|
34
|
+
Honeybadger.notify(e)
|
35
|
+
raise
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
self.singleton_class.prepend(mod)
|
42
|
+
Kernel.singleton_class.prepend(mod) if self == TOPLEVEL_BINDING.eval("self")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# @api private
|
47
|
+
Plugin.register :lambda do
|
48
|
+
requirement { Util::Lambda.lambda_execution? }
|
49
|
+
|
50
|
+
execution do
|
51
|
+
config[:sync] = true
|
52
|
+
config[:'exceptions.notify_at_exit'] = false
|
53
|
+
|
54
|
+
main = TOPLEVEL_BINDING.eval("self")
|
55
|
+
main.extend(LambdaExtension)
|
56
|
+
|
57
|
+
(config[:before_notify] ||= []) << lambda do |notice|
|
58
|
+
data = Util::Lambda.normalized_data
|
59
|
+
|
60
|
+
notice.component = data["function"]
|
61
|
+
notice.action = data["handler"]
|
62
|
+
notice.details["Lambda Details"] = data
|
63
|
+
|
64
|
+
if (trace_id = Util::Lambda.trace_id)
|
65
|
+
notice.context[:lambda_trace_id] = trace_id
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'honeybadger/plugin'
|
2
|
-
require 'honeybadger/backtrace'
|
3
|
-
|
4
|
-
module Honeybadger
|
5
|
-
module Plugins
|
6
|
-
module LocalVariables
|
7
|
-
module ExceptionExtension
|
8
|
-
def self.included(base)
|
9
|
-
base.send(:alias_method, :set_backtrace_without_honeybadger, :set_backtrace)
|
10
|
-
base.send(:alias_method, :set_backtrace, :set_backtrace_with_honeybadger)
|
11
|
-
end
|
12
|
-
|
13
|
-
def set_backtrace_with_honeybadger(*args, &block)
|
14
|
-
if caller.none? { |loc| loc.match(::Honeybadger::Backtrace::Line::INPUT_FORMAT) && Regexp.last_match(1) == __FILE__ }
|
15
|
-
@__honeybadger_bindings_stack = binding.callers.drop(1)
|
16
|
-
end
|
17
|
-
|
18
|
-
set_backtrace_without_honeybadger(*args, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def __honeybadger_bindings_stack
|
22
|
-
@__honeybadger_bindings_stack || []
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
Plugin.register do
|
27
|
-
requirement { config[:'exceptions.local_variables'] }
|
28
|
-
requirement { defined?(::BindingOfCaller) }
|
29
|
-
requirement do
|
30
|
-
if res = defined?(::BetterErrors)
|
31
|
-
logger.warn("The local variables feature is incompatible with the " \
|
32
|
-
"better_errors gem; to remove this warning, set " \
|
33
|
-
"exceptions.local_variables to false for environments " \
|
34
|
-
"which load better_errors.")
|
35
|
-
end
|
36
|
-
!res
|
37
|
-
end
|
38
|
-
requirement { !::Exception.included_modules.include?(ExceptionExtension) }
|
39
|
-
|
40
|
-
execution { ::Exception.send(:include, ExceptionExtension) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require 'honeybadger/plugin'
|
2
|
+
require 'honeybadger/backtrace'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
module Plugins
|
6
|
+
module LocalVariables
|
7
|
+
module ExceptionExtension
|
8
|
+
def self.included(base)
|
9
|
+
base.send(:alias_method, :set_backtrace_without_honeybadger, :set_backtrace)
|
10
|
+
base.send(:alias_method, :set_backtrace, :set_backtrace_with_honeybadger)
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_backtrace_with_honeybadger(*args, &block)
|
14
|
+
if caller.none? { |loc| loc.match(::Honeybadger::Backtrace::Line::INPUT_FORMAT) && Regexp.last_match(1) == __FILE__ }
|
15
|
+
@__honeybadger_bindings_stack = binding.callers.drop(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
set_backtrace_without_honeybadger(*args, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def __honeybadger_bindings_stack
|
22
|
+
@__honeybadger_bindings_stack || []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Plugin.register do
|
27
|
+
requirement { config[:'exceptions.local_variables'] }
|
28
|
+
requirement { defined?(::BindingOfCaller) }
|
29
|
+
requirement do
|
30
|
+
if res = defined?(::BetterErrors)
|
31
|
+
logger.warn("The local variables feature is incompatible with the " \
|
32
|
+
"better_errors gem; to remove this warning, set " \
|
33
|
+
"exceptions.local_variables to false for environments " \
|
34
|
+
"which load better_errors.")
|
35
|
+
end
|
36
|
+
!res
|
37
|
+
end
|
38
|
+
requirement { !::Exception.included_modules.include?(ExceptionExtension) }
|
39
|
+
|
40
|
+
execution { ::Exception.send(:include, ExceptionExtension) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require 'honeybadger/plugin'
|
2
|
-
require 'honeybadger/agent'
|
3
|
-
|
4
|
-
module Honeybadger
|
5
|
-
module Plugins
|
6
|
-
module Passenger
|
7
|
-
Plugin.register do
|
8
|
-
requirement { defined?(::PhusionPassenger.on_event) }
|
9
|
-
|
10
|
-
execution do
|
11
|
-
::PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
12
|
-
logger.debug('Starting passenger worker process')
|
13
|
-
end
|
14
|
-
|
15
|
-
::PhusionPassenger.on_event(:stopping_worker_process) do
|
16
|
-
logger.debug('Stopping passenger worker process')
|
17
|
-
Honeybadger.stop
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require 'honeybadger/plugin'
|
2
|
+
require 'honeybadger/agent'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
module Plugins
|
6
|
+
module Passenger
|
7
|
+
Plugin.register do
|
8
|
+
requirement { defined?(::PhusionPassenger.on_event) }
|
9
|
+
|
10
|
+
execution do
|
11
|
+
::PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
12
|
+
logger.debug('Starting passenger worker process')
|
13
|
+
end
|
14
|
+
|
15
|
+
::PhusionPassenger.on_event(:stopping_worker_process) do
|
16
|
+
logger.debug('Stopping passenger worker process')
|
17
|
+
Honeybadger.stop
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,48 +1,72 @@
|
|
1
|
-
require 'honeybadger/plugin'
|
2
|
-
|
3
|
-
module Honeybadger
|
4
|
-
module Plugins
|
5
|
-
module Rails
|
6
|
-
module ExceptionsCatcher
|
7
|
-
# Adds additional Honeybadger info to Request env when an
|
8
|
-
# exception is rendered in Rails' middleware.
|
9
|
-
#
|
10
|
-
# @param [Hash, ActionDispatch::Request] arg The Rack env +Hash+ in
|
11
|
-
# Rails 3.0-4.2. After Rails 5 +arg+ is an +ActionDispatch::Request+.
|
12
|
-
# @param [Exception] exception The error which was rescued.
|
13
|
-
#
|
14
|
-
# @return The super value of the middleware's +#render_exception()+
|
15
|
-
# method.
|
16
|
-
def render_exception(arg, exception)
|
17
|
-
if arg.kind_of?(::ActionDispatch::Request)
|
18
|
-
request = arg
|
19
|
-
env = request.env
|
20
|
-
else
|
21
|
-
request = ::Rack::Request.new(arg)
|
22
|
-
env = arg
|
23
|
-
end
|
24
|
-
|
25
|
-
env['honeybadger.exception'] = exception
|
26
|
-
env['honeybadger.request.url'] = request.url rescue nil
|
27
|
-
|
28
|
-
super(arg, exception)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
1
|
+
require 'honeybadger/plugin'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
module Plugins
|
5
|
+
module Rails
|
6
|
+
module ExceptionsCatcher
|
7
|
+
# Adds additional Honeybadger info to Request env when an
|
8
|
+
# exception is rendered in Rails' middleware.
|
9
|
+
#
|
10
|
+
# @param [Hash, ActionDispatch::Request] arg The Rack env +Hash+ in
|
11
|
+
# Rails 3.0-4.2. After Rails 5 +arg+ is an +ActionDispatch::Request+.
|
12
|
+
# @param [Exception] exception The error which was rescued.
|
13
|
+
#
|
14
|
+
# @return The super value of the middleware's +#render_exception()+
|
15
|
+
# method.
|
16
|
+
def render_exception(arg, exception, *args)
|
17
|
+
if arg.kind_of?(::ActionDispatch::Request)
|
18
|
+
request = arg
|
19
|
+
env = request.env
|
20
|
+
else
|
21
|
+
request = ::Rack::Request.new(arg)
|
22
|
+
env = arg
|
23
|
+
end
|
24
|
+
|
25
|
+
env['honeybadger.exception'] = exception
|
26
|
+
env['honeybadger.request.url'] = request.url rescue nil
|
27
|
+
|
28
|
+
super(arg, exception, *args)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ErrorSubscriber
|
33
|
+
def self.report(exception, handled:, severity:, context: {}, source: nil)
|
34
|
+
# We only report unhandled errors (`Rails.error.handle`)
|
35
|
+
# Unhandled errors will be caught by our integrations (eg middleware), which have richer context
|
36
|
+
return unless handled
|
37
|
+
|
38
|
+
return if source_ignored?(source)
|
39
|
+
|
40
|
+
tags = ["severity:#{severity}", "handled:#{handled}"]
|
41
|
+
tags << "source:#{source}" if source
|
42
|
+
Honeybadger.notify(exception, context: context, tags: tags)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.source_ignored?(source)
|
46
|
+
source && ::Honeybadger.config[:'rails.subscriber_ignore_sources'].any? do |ignored_source|
|
47
|
+
ignored_source.is_a?(Regexp) ? ignored_source.match?(source) : (ignored_source == source)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Plugin.register :rails_exceptions_catcher do
|
53
|
+
requirement { defined?(::Rails.application) && ::Rails.application }
|
54
|
+
|
55
|
+
execution do
|
56
|
+
require 'rack/request'
|
57
|
+
if defined?(::ActionDispatch::DebugExceptions)
|
58
|
+
# Rails 3.2.x+
|
59
|
+
::ActionDispatch::DebugExceptions.prepend(ExceptionsCatcher)
|
60
|
+
elsif defined?(::ActionDispatch::ShowExceptions)
|
61
|
+
# Rails 3.0.x and 3.1.x
|
62
|
+
::ActionDispatch::ShowExceptions.prepend(ExceptionsCatcher)
|
63
|
+
end
|
64
|
+
|
65
|
+
if defined?(::ActiveSupport::ErrorReporter) # Rails 7
|
66
|
+
::Rails.error.subscribe(ErrorSubscriber)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|