honeybadger 5.0.2 → 5.2.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 +718 -701
- 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 -488
- 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 -46
- 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 +55 -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 -333
- 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 +416 -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/hanami.rb +19 -0
- data/lib/honeybadger/init/rails.rb +38 -38
- data/lib/honeybadger/init/rake.rb +66 -66
- data/lib/honeybadger/init/ruby.rb +11 -11
- data/lib/honeybadger/init/sinatra.rb +57 -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 -63
- 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 +13 -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 +11 -5
@@ -1,92 +1,92 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'rack/request'
|
3
|
-
|
4
|
-
require 'honeybadger/ruby'
|
5
|
-
|
6
|
-
module Honeybadger
|
7
|
-
module Rack
|
8
|
-
# Middleware for Rack applications. Any errors raised by the upstream
|
9
|
-
# application will be delivered to Honeybadger and re-raised.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# require 'honeybadger/rack/error_notifier'
|
13
|
-
#
|
14
|
-
# app = Rack::Builder.app do
|
15
|
-
# run lambda { |env| raise "Rack down" }
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# use Honeybadger::Rack::ErrorNotifier
|
19
|
-
#
|
20
|
-
# run app
|
21
|
-
class ErrorNotifier
|
22
|
-
extend Forwardable
|
23
|
-
|
24
|
-
def initialize(app, agent = nil)
|
25
|
-
@app = app
|
26
|
-
@agent = agent.kind_of?(Agent) && agent
|
27
|
-
end
|
28
|
-
|
29
|
-
def call(env)
|
30
|
-
agent.with_rack_env(env) do
|
31
|
-
begin
|
32
|
-
env['honeybadger.config'] = config
|
33
|
-
response = @app.call(env)
|
34
|
-
rescue Exception => raised
|
35
|
-
env['honeybadger.error_id'] = notify_honeybadger(raised, env)
|
36
|
-
raise
|
37
|
-
end
|
38
|
-
|
39
|
-
framework_exception = framework_exception(env)
|
40
|
-
if framework_exception
|
41
|
-
env['honeybadger.error_id'] = notify_honeybadger(framework_exception, env)
|
42
|
-
end
|
43
|
-
|
44
|
-
response
|
45
|
-
end
|
46
|
-
ensure
|
47
|
-
agent.clear!
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def_delegator :agent, :config
|
53
|
-
def_delegator :config, :logger
|
54
|
-
|
55
|
-
def agent
|
56
|
-
@agent || Honeybadger::Agent.instance
|
57
|
-
end
|
58
|
-
|
59
|
-
def ignored_user_agent?(env)
|
60
|
-
true if config[:'exceptions.ignored_user_agents'].
|
61
|
-
flatten.
|
62
|
-
any? { |ua| ua === env['HTTP_USER_AGENT'] }
|
63
|
-
end
|
64
|
-
|
65
|
-
def notify_honeybadger(exception, env)
|
66
|
-
return if ignored_user_agent?(env)
|
67
|
-
|
68
|
-
if config[:'breadcrumbs.enabled']
|
69
|
-
# Drop the last breadcrumb only if the message contains the error class name
|
70
|
-
agent.breadcrumbs.drop_previous_breadcrumb_if do |bc|
|
71
|
-
bc.category == "log" && bc.message.include?(exception.class.to_s)
|
72
|
-
end
|
73
|
-
|
74
|
-
agent.add_breadcrumb(
|
75
|
-
exception.class,
|
76
|
-
metadata: {
|
77
|
-
message: exception.message
|
78
|
-
},
|
79
|
-
category: "error"
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
agent.notify(exception)
|
84
|
-
end
|
85
|
-
|
86
|
-
def framework_exception(env)
|
87
|
-
env['action_dispatch.exception'] || env['rack.exception'] ||
|
88
|
-
env['sinatra.error'] || env['honeybadger.exception']
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
1
|
+
require 'forwardable'
|
2
|
+
require 'rack/request'
|
3
|
+
|
4
|
+
require 'honeybadger/ruby'
|
5
|
+
|
6
|
+
module Honeybadger
|
7
|
+
module Rack
|
8
|
+
# Middleware for Rack applications. Any errors raised by the upstream
|
9
|
+
# application will be delivered to Honeybadger and re-raised.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# require 'honeybadger/rack/error_notifier'
|
13
|
+
#
|
14
|
+
# app = Rack::Builder.app do
|
15
|
+
# run lambda { |env| raise "Rack down" }
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# use Honeybadger::Rack::ErrorNotifier
|
19
|
+
#
|
20
|
+
# run app
|
21
|
+
class ErrorNotifier
|
22
|
+
extend Forwardable
|
23
|
+
|
24
|
+
def initialize(app, agent = nil)
|
25
|
+
@app = app
|
26
|
+
@agent = agent.kind_of?(Agent) && agent
|
27
|
+
end
|
28
|
+
|
29
|
+
def call(env)
|
30
|
+
agent.with_rack_env(env) do
|
31
|
+
begin
|
32
|
+
env['honeybadger.config'] = config
|
33
|
+
response = @app.call(env)
|
34
|
+
rescue Exception => raised
|
35
|
+
env['honeybadger.error_id'] = notify_honeybadger(raised, env)
|
36
|
+
raise
|
37
|
+
end
|
38
|
+
|
39
|
+
framework_exception = framework_exception(env)
|
40
|
+
if framework_exception
|
41
|
+
env['honeybadger.error_id'] = notify_honeybadger(framework_exception, env)
|
42
|
+
end
|
43
|
+
|
44
|
+
response
|
45
|
+
end
|
46
|
+
ensure
|
47
|
+
agent.clear!
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def_delegator :agent, :config
|
53
|
+
def_delegator :config, :logger
|
54
|
+
|
55
|
+
def agent
|
56
|
+
@agent || Honeybadger::Agent.instance
|
57
|
+
end
|
58
|
+
|
59
|
+
def ignored_user_agent?(env)
|
60
|
+
true if config[:'exceptions.ignored_user_agents'].
|
61
|
+
flatten.
|
62
|
+
any? { |ua| ua === env['HTTP_USER_AGENT'] }
|
63
|
+
end
|
64
|
+
|
65
|
+
def notify_honeybadger(exception, env)
|
66
|
+
return if ignored_user_agent?(env)
|
67
|
+
|
68
|
+
if config[:'breadcrumbs.enabled']
|
69
|
+
# Drop the last breadcrumb only if the message contains the error class name
|
70
|
+
agent.breadcrumbs.drop_previous_breadcrumb_if do |bc|
|
71
|
+
bc.category == "log" && bc.message.include?(exception.class.to_s)
|
72
|
+
end
|
73
|
+
|
74
|
+
agent.add_breadcrumb(
|
75
|
+
exception.class,
|
76
|
+
metadata: {
|
77
|
+
message: exception.message
|
78
|
+
},
|
79
|
+
category: "error"
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
agent.notify(exception)
|
84
|
+
end
|
85
|
+
|
86
|
+
def framework_exception(env)
|
87
|
+
env['action_dispatch.exception'] || env['rack.exception'] ||
|
88
|
+
env['sinatra.error'] || env['honeybadger.exception']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -1,88 +1,88 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'uri'
|
3
|
-
require 'forwardable'
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'i18n'
|
7
|
-
rescue LoadError
|
8
|
-
module Honeybadger
|
9
|
-
module I18n
|
10
|
-
def self.t(key, options={})
|
11
|
-
options[:default]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module Honeybadger
|
18
|
-
module Rack
|
19
|
-
# Middleware for Rack applications. Adds a feedback form to the Rack
|
20
|
-
# response when an error has occurred.
|
21
|
-
class UserFeedback
|
22
|
-
extend Forwardable
|
23
|
-
|
24
|
-
def initialize(app, agent = nil)
|
25
|
-
@app = app
|
26
|
-
@agent = agent.kind_of?(Agent) && agent
|
27
|
-
end
|
28
|
-
|
29
|
-
def call(env)
|
30
|
-
return @app.call(env) unless config[:'feedback.enabled']
|
31
|
-
status, headers, body = @app.call(env)
|
32
|
-
if env['honeybadger.error_id'] && form = render_form(env['honeybadger.error_id'])
|
33
|
-
new_body = []
|
34
|
-
body.each do |chunk|
|
35
|
-
new_body << chunk.gsub("<!-- HONEYBADGER FEEDBACK -->", form)
|
36
|
-
end
|
37
|
-
body.close if body.respond_to?(:close)
|
38
|
-
headers['Content-Length'] = new_body.reduce(0) { |a,e| a += e.bytesize }.to_s
|
39
|
-
body = new_body
|
40
|
-
end
|
41
|
-
[status, headers, body]
|
42
|
-
end
|
43
|
-
|
44
|
-
# @private
|
45
|
-
# @todo Make this method and others actually private.
|
46
|
-
def action
|
47
|
-
URI.parse("#{config.connection_protocol}://#{config[:'connection.host']}:#{config.connection_port}/v1/feedback/").to_s
|
48
|
-
rescue URI::InvalidURIError
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
|
52
|
-
# @private
|
53
|
-
def render_form(error_id, action = action())
|
54
|
-
return unless action
|
55
|
-
ERB.new(@template ||= File.read(template_file)).result(binding)
|
56
|
-
end
|
57
|
-
|
58
|
-
# @private
|
59
|
-
def custom_template_file
|
60
|
-
@custom_template_file ||= File.join(config[:root], 'lib', 'honeybadger', 'templates', 'feedback_form.erb')
|
61
|
-
end
|
62
|
-
|
63
|
-
# @private
|
64
|
-
def custom_template_file?
|
65
|
-
custom_template_file && File.exist?(custom_template_file)
|
66
|
-
end
|
67
|
-
|
68
|
-
# @private
|
69
|
-
def template_file
|
70
|
-
if custom_template_file?
|
71
|
-
custom_template_file
|
72
|
-
else
|
73
|
-
File.expand_path('../../templates/feedback_form.erb', __FILE__)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def_delegator :agent, :config
|
80
|
-
def_delegator :config, :logger
|
81
|
-
|
82
|
-
def agent
|
83
|
-
@agent || Honeybadger::Agent.instance
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
1
|
+
require 'erb'
|
2
|
+
require 'uri'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'i18n'
|
7
|
+
rescue LoadError
|
8
|
+
module Honeybadger
|
9
|
+
module I18n
|
10
|
+
def self.t(key, options={})
|
11
|
+
options[:default]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Honeybadger
|
18
|
+
module Rack
|
19
|
+
# Middleware for Rack applications. Adds a feedback form to the Rack
|
20
|
+
# response when an error has occurred.
|
21
|
+
class UserFeedback
|
22
|
+
extend Forwardable
|
23
|
+
|
24
|
+
def initialize(app, agent = nil)
|
25
|
+
@app = app
|
26
|
+
@agent = agent.kind_of?(Agent) && agent
|
27
|
+
end
|
28
|
+
|
29
|
+
def call(env)
|
30
|
+
return @app.call(env) unless config[:'feedback.enabled']
|
31
|
+
status, headers, body = @app.call(env)
|
32
|
+
if env['honeybadger.error_id'] && form = render_form(env['honeybadger.error_id'])
|
33
|
+
new_body = []
|
34
|
+
body.each do |chunk|
|
35
|
+
new_body << chunk.gsub("<!-- HONEYBADGER FEEDBACK -->", form)
|
36
|
+
end
|
37
|
+
body.close if body.respond_to?(:close)
|
38
|
+
headers['Content-Length'] = new_body.reduce(0) { |a,e| a += e.bytesize }.to_s
|
39
|
+
body = new_body
|
40
|
+
end
|
41
|
+
[status, headers, body]
|
42
|
+
end
|
43
|
+
|
44
|
+
# @private
|
45
|
+
# @todo Make this method and others actually private.
|
46
|
+
def action
|
47
|
+
URI.parse("#{config.connection_protocol}://#{config[:'connection.host']}:#{config.connection_port}/v1/feedback/").to_s
|
48
|
+
rescue URI::InvalidURIError
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
# @private
|
53
|
+
def render_form(error_id, action = action())
|
54
|
+
return unless action
|
55
|
+
ERB.new(@template ||= File.read(template_file)).result(binding)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @private
|
59
|
+
def custom_template_file
|
60
|
+
@custom_template_file ||= File.join(config[:root], 'lib', 'honeybadger', 'templates', 'feedback_form.erb')
|
61
|
+
end
|
62
|
+
|
63
|
+
# @private
|
64
|
+
def custom_template_file?
|
65
|
+
custom_template_file && File.exist?(custom_template_file)
|
66
|
+
end
|
67
|
+
|
68
|
+
# @private
|
69
|
+
def template_file
|
70
|
+
if custom_template_file?
|
71
|
+
custom_template_file
|
72
|
+
else
|
73
|
+
File.expand_path('../../templates/feedback_form.erb', __FILE__)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def_delegator :agent, :config
|
80
|
+
def_delegator :config, :logger
|
81
|
+
|
82
|
+
def agent
|
83
|
+
@agent || Honeybadger::Agent.instance
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module Honeybadger
|
4
|
-
module Rack
|
5
|
-
# Middleware for Rack applications. Adds an error ID to the Rack response
|
6
|
-
# when an error has occurred.
|
7
|
-
class UserInformer
|
8
|
-
extend Forwardable
|
9
|
-
|
10
|
-
def initialize(app, agent = nil)
|
11
|
-
@app = app
|
12
|
-
@agent = agent.kind_of?(Agent) && agent
|
13
|
-
end
|
14
|
-
|
15
|
-
def replacement(with)
|
16
|
-
config[:'user_informer.info'].gsub(/\{\{\s*error_id\s*\}\}/, with.to_s)
|
17
|
-
end
|
18
|
-
|
19
|
-
def call(env)
|
20
|
-
return @app.call(env) unless config[:'user_informer.enabled']
|
21
|
-
status, headers, body = @app.call(env)
|
22
|
-
if env['honeybadger.error_id']
|
23
|
-
new_body = []
|
24
|
-
replace = replacement(env['honeybadger.error_id'])
|
25
|
-
body.each do |chunk|
|
26
|
-
new_body << chunk.gsub("<!-- HONEYBADGER ERROR -->", replace)
|
27
|
-
end
|
28
|
-
body.close if body.respond_to?(:close)
|
29
|
-
headers['Content-Length'] = new_body.reduce(0) { |a,e| a += e.bytesize }.to_s
|
30
|
-
body = new_body
|
31
|
-
end
|
32
|
-
[status, headers, body]
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def_delegator :agent, :config
|
38
|
-
def_delegator :config, :logger
|
39
|
-
|
40
|
-
def agent
|
41
|
-
@agent || Honeybadger::Agent.instance
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
module Rack
|
5
|
+
# Middleware for Rack applications. Adds an error ID to the Rack response
|
6
|
+
# when an error has occurred.
|
7
|
+
class UserInformer
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
def initialize(app, agent = nil)
|
11
|
+
@app = app
|
12
|
+
@agent = agent.kind_of?(Agent) && agent
|
13
|
+
end
|
14
|
+
|
15
|
+
def replacement(with)
|
16
|
+
config[:'user_informer.info'].gsub(/\{\{\s*error_id\s*\}\}/, with.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
return @app.call(env) unless config[:'user_informer.enabled']
|
21
|
+
status, headers, body = @app.call(env)
|
22
|
+
if env['honeybadger.error_id']
|
23
|
+
new_body = []
|
24
|
+
replace = replacement(env['honeybadger.error_id'])
|
25
|
+
body.each do |chunk|
|
26
|
+
new_body << chunk.gsub("<!-- HONEYBADGER ERROR -->", replace)
|
27
|
+
end
|
28
|
+
body.close if body.respond_to?(:close)
|
29
|
+
headers['Content-Length'] = new_body.reduce(0) { |a,e| a += e.bytesize }.to_s
|
30
|
+
body = new_body
|
31
|
+
end
|
32
|
+
[status, headers, body]
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def_delegator :agent, :config
|
38
|
+
def_delegator :config, :logger
|
39
|
+
|
40
|
+
def agent
|
41
|
+
@agent || Honeybadger::Agent.instance
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/honeybadger/ruby.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'honeybadger/const'
|
2
|
-
require 'honeybadger/singleton'
|
1
|
+
require 'honeybadger/const'
|
2
|
+
require 'honeybadger/singleton'
|
@@ -1,103 +1,103 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'honeybadger/agent'
|
3
|
-
|
4
|
-
# Honeybadger's public API is made up of two parts: the {Honeybadger} singleton
|
5
|
-
# module, and the {Agent} class. The singleton module delegates its methods to
|
6
|
-
# a global agent instance, {Agent#instance}; this allows methods to be accessed
|
7
|
-
# directly, for example when calling +Honeybadger.notify+:
|
8
|
-
#
|
9
|
-
# begin
|
10
|
-
# raise 'testing an error report'
|
11
|
-
# rescue => err
|
12
|
-
# Honeybadger.notify(err)
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# Custom agents may also be created by users who want to report to multiple
|
16
|
-
# Honeybadger projects in the same app (or have fine-grained control over
|
17
|
-
# configuration), however most users will use the global agent.
|
18
|
-
#
|
19
|
-
# @see Honeybadger::Agent
|
20
|
-
module Honeybadger
|
21
|
-
extend Forwardable
|
22
|
-
extend self
|
23
|
-
|
24
|
-
# @!macro [attach] def_delegator
|
25
|
-
# @!method $2(...)
|
26
|
-
# Forwards to {$1}.
|
27
|
-
# @see Agent#$2
|
28
|
-
def_delegator :'Honeybadger::Agent.instance', :check_in
|
29
|
-
def_delegator :'Honeybadger::Agent.instance', :context
|
30
|
-
def_delegator :'Honeybadger::Agent.instance', :configure
|
31
|
-
def_delegator :'Honeybadger::Agent.instance', :get_context
|
32
|
-
def_delegator :'Honeybadger::Agent.instance', :flush
|
33
|
-
def_delegator :'Honeybadger::Agent.instance', :stop
|
34
|
-
def_delegator :'Honeybadger::Agent.instance', :exception_filter
|
35
|
-
def_delegator :'Honeybadger::Agent.instance', :exception_fingerprint
|
36
|
-
def_delegator :'Honeybadger::Agent.instance', :backtrace_filter
|
37
|
-
def_delegator :'Honeybadger::Agent.instance', :add_breadcrumb
|
38
|
-
def_delegator :'Honeybadger::Agent.instance', :breadcrumbs
|
39
|
-
def_delegator :'Honeybadger::Agent.instance', :clear!
|
40
|
-
def_delegator :'Honeybadger::Agent.instance', :track_deployment
|
41
|
-
|
42
|
-
# @!macro [attach] def_delegator
|
43
|
-
# @!method $2(...)
|
44
|
-
# @api private
|
45
|
-
# Forwards to {$1}.
|
46
|
-
# @see Agent#$2
|
47
|
-
def_delegator :'Honeybadger::Agent.instance', :config
|
48
|
-
def_delegator :'Honeybadger::Agent.instance', :init!
|
49
|
-
def_delegator :'Honeybadger::Agent.instance', :with_rack_env
|
50
|
-
|
51
|
-
# @!method notify(...)
|
52
|
-
# Forwards to {Agent.instance}.
|
53
|
-
# @see Agent#notify
|
54
|
-
def notify(exception_or_opts, opts = {})
|
55
|
-
# Note this is defined directly (instead of via forwardable) so that
|
56
|
-
# generated stack traces work as expected.
|
57
|
-
Agent.instance.notify(exception_or_opts, opts)
|
58
|
-
end
|
59
|
-
|
60
|
-
# @api private
|
61
|
-
def load_plugins!
|
62
|
-
Dir[File.expand_path('../plugins/*.rb', __FILE__)].each do |plugin|
|
63
|
-
require plugin
|
64
|
-
end
|
65
|
-
Plugin.load!(self.config)
|
66
|
-
end
|
67
|
-
|
68
|
-
# @api private
|
69
|
-
def install_at_exit_callback
|
70
|
-
at_exit do
|
71
|
-
if $! && !ignored_exception?($!) && Honeybadger.config[:'exceptions.notify_at_exit']
|
72
|
-
Honeybadger.notify($!, component: 'at_exit', sync: true)
|
73
|
-
end
|
74
|
-
|
75
|
-
Honeybadger.stop if Honeybadger.config[:'send_data_at_exit']
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# @deprecated
|
80
|
-
def start(config = {})
|
81
|
-
raise NoMethodError, <<-WARNING
|
82
|
-
`Honeybadger.start` is no longer necessary and has been removed.
|
83
|
-
|
84
|
-
Use `Honeybadger.configure` to explicitly configure the agent from Ruby moving forward:
|
85
|
-
|
86
|
-
Honeybadger.configure do |config|
|
87
|
-
config.api_key = 'project api key'
|
88
|
-
config.exceptions.ignore += [CustomError]
|
89
|
-
end
|
90
|
-
WARNING
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
# @api private
|
95
|
-
def ignored_exception?(exception)
|
96
|
-
exception.is_a?(SystemExit) ||
|
97
|
-
( exception.is_a?(SignalException) &&
|
98
|
-
( (exception.respond_to?(:signm) && exception.signm == "SIGTERM") ||
|
99
|
-
# jruby has a missing #signm implementation
|
100
|
-
["TERM", "SIGTERM"].include?(exception.to_s) )
|
101
|
-
)
|
102
|
-
end
|
103
|
-
end
|
1
|
+
require 'forwardable'
|
2
|
+
require 'honeybadger/agent'
|
3
|
+
|
4
|
+
# Honeybadger's public API is made up of two parts: the {Honeybadger} singleton
|
5
|
+
# module, and the {Agent} class. The singleton module delegates its methods to
|
6
|
+
# a global agent instance, {Agent#instance}; this allows methods to be accessed
|
7
|
+
# directly, for example when calling +Honeybadger.notify+:
|
8
|
+
#
|
9
|
+
# begin
|
10
|
+
# raise 'testing an error report'
|
11
|
+
# rescue => err
|
12
|
+
# Honeybadger.notify(err)
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# Custom agents may also be created by users who want to report to multiple
|
16
|
+
# Honeybadger projects in the same app (or have fine-grained control over
|
17
|
+
# configuration), however most users will use the global agent.
|
18
|
+
#
|
19
|
+
# @see Honeybadger::Agent
|
20
|
+
module Honeybadger
|
21
|
+
extend Forwardable
|
22
|
+
extend self
|
23
|
+
|
24
|
+
# @!macro [attach] def_delegator
|
25
|
+
# @!method $2(...)
|
26
|
+
# Forwards to {$1}.
|
27
|
+
# @see Agent#$2
|
28
|
+
def_delegator :'Honeybadger::Agent.instance', :check_in
|
29
|
+
def_delegator :'Honeybadger::Agent.instance', :context
|
30
|
+
def_delegator :'Honeybadger::Agent.instance', :configure
|
31
|
+
def_delegator :'Honeybadger::Agent.instance', :get_context
|
32
|
+
def_delegator :'Honeybadger::Agent.instance', :flush
|
33
|
+
def_delegator :'Honeybadger::Agent.instance', :stop
|
34
|
+
def_delegator :'Honeybadger::Agent.instance', :exception_filter
|
35
|
+
def_delegator :'Honeybadger::Agent.instance', :exception_fingerprint
|
36
|
+
def_delegator :'Honeybadger::Agent.instance', :backtrace_filter
|
37
|
+
def_delegator :'Honeybadger::Agent.instance', :add_breadcrumb
|
38
|
+
def_delegator :'Honeybadger::Agent.instance', :breadcrumbs
|
39
|
+
def_delegator :'Honeybadger::Agent.instance', :clear!
|
40
|
+
def_delegator :'Honeybadger::Agent.instance', :track_deployment
|
41
|
+
|
42
|
+
# @!macro [attach] def_delegator
|
43
|
+
# @!method $2(...)
|
44
|
+
# @api private
|
45
|
+
# Forwards to {$1}.
|
46
|
+
# @see Agent#$2
|
47
|
+
def_delegator :'Honeybadger::Agent.instance', :config
|
48
|
+
def_delegator :'Honeybadger::Agent.instance', :init!
|
49
|
+
def_delegator :'Honeybadger::Agent.instance', :with_rack_env
|
50
|
+
|
51
|
+
# @!method notify(...)
|
52
|
+
# Forwards to {Agent.instance}.
|
53
|
+
# @see Agent#notify
|
54
|
+
def notify(exception_or_opts, opts = {})
|
55
|
+
# Note this is defined directly (instead of via forwardable) so that
|
56
|
+
# generated stack traces work as expected.
|
57
|
+
Agent.instance.notify(exception_or_opts, opts)
|
58
|
+
end
|
59
|
+
|
60
|
+
# @api private
|
61
|
+
def load_plugins!
|
62
|
+
Dir[File.expand_path('../plugins/*.rb', __FILE__)].each do |plugin|
|
63
|
+
require plugin
|
64
|
+
end
|
65
|
+
Plugin.load!(self.config)
|
66
|
+
end
|
67
|
+
|
68
|
+
# @api private
|
69
|
+
def install_at_exit_callback
|
70
|
+
at_exit do
|
71
|
+
if $! && !ignored_exception?($!) && Honeybadger.config[:'exceptions.notify_at_exit']
|
72
|
+
Honeybadger.notify($!, component: 'at_exit', sync: true)
|
73
|
+
end
|
74
|
+
|
75
|
+
Honeybadger.stop if Honeybadger.config[:'send_data_at_exit']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# @deprecated
|
80
|
+
def start(config = {})
|
81
|
+
raise NoMethodError, <<-WARNING
|
82
|
+
`Honeybadger.start` is no longer necessary and has been removed.
|
83
|
+
|
84
|
+
Use `Honeybadger.configure` to explicitly configure the agent from Ruby moving forward:
|
85
|
+
|
86
|
+
Honeybadger.configure do |config|
|
87
|
+
config.api_key = 'project api key'
|
88
|
+
config.exceptions.ignore += [CustomError]
|
89
|
+
end
|
90
|
+
WARNING
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
# @api private
|
95
|
+
def ignored_exception?(exception)
|
96
|
+
exception.is_a?(SystemExit) ||
|
97
|
+
( exception.is_a?(SignalException) &&
|
98
|
+
( (exception.respond_to?(:signm) && exception.signm == "SIGTERM") ||
|
99
|
+
# jruby has a missing #signm implementation
|
100
|
+
["TERM", "SIGTERM"].include?(exception.to_s) )
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|