honeybadger 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/lib/honeybadger.rb +0 -7
- data/lib/honeybadger/agent.rb +112 -135
- data/lib/honeybadger/backend.rb +1 -0
- data/lib/honeybadger/backend/base.rb +22 -20
- data/lib/honeybadger/backend/debug.rb +3 -3
- data/lib/honeybadger/backend/server.rb +7 -12
- data/lib/honeybadger/backend/test.rb +7 -10
- data/lib/honeybadger/backtrace.rb +9 -8
- data/lib/honeybadger/cli.rb +1 -0
- data/lib/honeybadger/cli/heroku.rb +3 -3
- data/lib/honeybadger/cli/test.rb +1 -1
- data/lib/honeybadger/config.rb +6 -19
- data/lib/honeybadger/config/defaults.rb +2 -0
- data/lib/honeybadger/const.rb +11 -3
- data/lib/honeybadger/context_manager.rb +3 -1
- data/lib/honeybadger/conversions.rb +4 -3
- data/lib/honeybadger/init/rails.rb +2 -0
- data/lib/honeybadger/init/rake.rb +2 -1
- data/lib/honeybadger/init/ruby.rb +2 -0
- data/lib/honeybadger/init/sinatra.rb +3 -0
- data/lib/honeybadger/logging.rb +5 -4
- data/lib/honeybadger/notice.rb +63 -49
- data/lib/honeybadger/plugin.rb +3 -3
- data/lib/honeybadger/plugins/rails.rb +6 -6
- data/lib/honeybadger/plugins/resque.rb +3 -3
- data/lib/honeybadger/plugins/sidekiq.rb +1 -1
- data/lib/honeybadger/rack/error_notifier.rb +2 -3
- data/lib/honeybadger/rack/user_feedback.rb +8 -2
- data/lib/honeybadger/rack/user_informer.rb +2 -2
- data/lib/honeybadger/singleton.rb +46 -11
- data/lib/honeybadger/util/request_hash.rb +2 -2
- data/lib/honeybadger/util/request_payload.rb +4 -4
- data/lib/honeybadger/util/revision.rb +2 -2
- data/lib/honeybadger/util/sanitizer.rb +2 -2
- data/lib/honeybadger/version.rb +2 -2
- data/lib/honeybadger/worker.rb +7 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a96d12ec0ab7511008ab992216c8d71538903b6a397fc5f263ac877bfee94dda
|
4
|
+
data.tar.gz: 63d8ca7feae94980da2281ab0883a61ad7b5479f7e1c60e470c3ea92b8fb48ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6a9617ee44a7869b271d7f7a4757f9f1c43a859ce0a9f3c789092ddcb67ce7f1675f1c03f7f4229895f10db9a6c6ead6d7861f1020e273588ea58b987021e89
|
7
|
+
data.tar.gz: ac5dc2626be3655eaec5f181a3207eb8b97816d44f9aba1c08f74e1c8f52999461523aca021af59e9ed0865a3e592f3f0cc6c2030a0e2e36f8928cc5042a26d1
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,16 @@ adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [3.3.0] - 2018-01-29
|
9
|
+
### Changed
|
10
|
+
- Use prepend to add Sidekiq Middleware to fix context getting cleared.
|
11
|
+
- Add `Rack::QueryParser::ParameterTypeError` and
|
12
|
+
`Rack::QueryParser::InvalidParameterError` to default ignore list.
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Use a unique route name in rails to avoid name conflicts.
|
16
|
+
- Fix `at_exit` callback being skipped in rails apps with a sinatra dependency.
|
17
|
+
|
8
18
|
## [3.2.0] - 2017-11-27
|
9
19
|
### Changed
|
10
20
|
- Objects which explicitly alias `#to_s` to `#inspect` (such as `OpenStruct`) are
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Pull requests are welcome. If you're adding a new feature, please [submit an iss
|
|
21
21
|
|
22
22
|
If you're integrating your gem/open source project with Honeybadger, please consider submitting an official plugin to our gem. [Submit an issue](https://github.com/honeybadger-io/honeybadger-ruby/issues/new) to discuss with us!
|
23
23
|
|
24
|
-
We use [
|
24
|
+
We use [YARD](https://yardoc.org/) to document our API. Classes and methods which are safe to depend on in your gems/projects are marked "Public". All other classes/methods are considered internal and may change without notice -- don't depend on them! If you need a new public API, we're happy to work with you. [Submit an issue](https://github.com/honeybadger-io/honeybadger-ruby/issues/new) to discuss.
|
25
25
|
|
26
26
|
### To contribute your code:
|
27
27
|
|
data/lib/honeybadger.rb
CHANGED
@@ -9,10 +9,3 @@ end
|
|
9
9
|
if defined?(Rake.application)
|
10
10
|
require 'honeybadger/init/rake'
|
11
11
|
end
|
12
|
-
|
13
|
-
# Sinatra is a special case. Sinatra starts the web application in an at_exit
|
14
|
-
# handler. And, since we require sinatra before requiring HB, the only way to
|
15
|
-
# setup our at_exit callback is in the sinatra build callback honeybadger/init/sinatra.rb
|
16
|
-
if !defined?(Sinatra::Base)
|
17
|
-
Honeybadger.install_at_exit_callback
|
18
|
-
end
|
data/lib/honeybadger/agent.rb
CHANGED
@@ -9,17 +9,21 @@ require 'honeybadger/logging'
|
|
9
9
|
require 'honeybadger/worker'
|
10
10
|
|
11
11
|
module Honeybadger
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# projects in large apps.
|
12
|
+
# The Honeybadger agent contains all the methods for interacting with the
|
13
|
+
# Honeybadger service. It can be used to send notifications to multiple
|
14
|
+
# projects in large apps. The global agent instance ({Agent.instance}) should
|
15
|
+
# always be accessed through the {Honeybadger} singleton.
|
16
|
+
#
|
17
|
+
# === Context
|
15
18
|
#
|
16
19
|
# Context is global by default, meaning agents created via
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# This also includes the Rack environment when using the
|
20
|
-
# middleware.
|
20
|
+
# +Honeybadger::Agent.new+ will share context (added via
|
21
|
+
# +Honeybadger.context+ or {Honeybadger::Agent#context}) with other agents.
|
22
|
+
# This also includes the Rack environment when using the
|
23
|
+
# {Honeybadger::Rack::ErrorNotifier} middleware. To localize context for a
|
24
|
+
# custom agent, use the +local_context: true+ option when initializing.
|
21
25
|
#
|
22
|
-
#
|
26
|
+
# @example
|
23
27
|
#
|
24
28
|
# # Standard usage:
|
25
29
|
# OtherBadger = Honeybadger::Agent.new
|
@@ -41,10 +45,12 @@ module Honeybadger
|
|
41
45
|
|
42
46
|
include Logging::Helper
|
43
47
|
|
48
|
+
# @api private
|
44
49
|
def self.instance
|
45
50
|
@instance
|
46
51
|
end
|
47
52
|
|
53
|
+
# @api private
|
48
54
|
def self.instance=(instance)
|
49
55
|
@instance = instance
|
50
56
|
end
|
@@ -63,30 +69,10 @@ module Honeybadger
|
|
63
69
|
init_worker
|
64
70
|
end
|
65
71
|
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
# exception_or_opts - An Exception object, or a Hash of options which is used
|
70
|
-
# to build the notice. All other types of objects will
|
71
|
-
# be converted to a String and used as the `:error_message`.
|
72
|
-
# opts - The options Hash when the first argument is an
|
73
|
-
# Exception (default: {}):
|
74
|
-
# :error_message - The String error message.
|
75
|
-
# :error_class - The String class name of the error (default: "Notice").
|
76
|
-
# :backtrace - The Array backtrace of the error (optional).
|
77
|
-
# :fingerprint - The String grouping fingerprint of the exception (optional).
|
78
|
-
# :force - Always report the exception when true, even when ignored (default: false).
|
79
|
-
# :tags - The String comma-separated list of tags (optional).
|
80
|
-
# :context - The Hash context to associate with the exception (optional).
|
81
|
-
# :controller - The String controller name (such as a Rails controller) (optional).
|
82
|
-
# :action - The String action name (such as a Rails controller action) (optional).
|
83
|
-
# :parameters - The Hash HTTP request paramaters (optional).
|
84
|
-
# :session - The Hash HTTP request session (optional).
|
85
|
-
# :url - The String HTTP request URL (optional).
|
86
|
-
# :cause - The Exception cause for this error (optional).
|
87
|
-
#
|
88
|
-
# Examples
|
72
|
+
# Sends an exception to Honeybadger. Does not report ignored exceptions by
|
73
|
+
# default.
|
89
74
|
#
|
75
|
+
# @example
|
90
76
|
# # With an exception:
|
91
77
|
# begin
|
92
78
|
# fail 'oops'
|
@@ -102,13 +88,32 @@ module Honeybadger
|
|
102
88
|
# context: {my_data: 'value'}
|
103
89
|
# }) # => '06220c5a-b471-41e5-baeb-de247da45a56'
|
104
90
|
#
|
105
|
-
#
|
106
|
-
#
|
91
|
+
# @param [Exception, Hash, Object] exception_or_opts An Exception object,
|
92
|
+
# or a Hash of options which is used to build the notice. All other types
|
93
|
+
# of objects will be converted to a String and used as the :error_message.
|
94
|
+
# @param [Hash] opts The options Hash when the first argument is an Exception.
|
95
|
+
#
|
96
|
+
# @option opts [String] :error_message The error message.
|
97
|
+
# @option opts [String] :error_class ('Notice') The class name of the error.
|
98
|
+
# @option opts [Array] :backtrace The backtrace of the error (optional).
|
99
|
+
# @option opts [String] :fingerprint The grouping fingerprint of the exception (optional).
|
100
|
+
# @option opts [Boolean] :force (false) Always report the exception when true, even when ignored (optional).
|
101
|
+
# @option opts [String] :tags The comma-separated list of tags (optional).
|
102
|
+
# @option opts [Hash] :context The context to associate with the exception (optional).
|
103
|
+
# @option opts [String] :controller The controller name (such as a Rails controller) (optional).
|
104
|
+
# @option opts [String] :action The action name (such as a Rails controller action) (optional).
|
105
|
+
# @option opts [Hash] :parameters The HTTP request paramaters (optional).
|
106
|
+
# @option opts [Hash] :session The HTTP request session (optional).
|
107
|
+
# @option opts [String] :url The HTTP request URL (optional).
|
108
|
+
# @option opts [Exception] :cause The cause for this error (optional).
|
109
|
+
#
|
110
|
+
# @return [String] UUID reference to the notice within Honeybadger.
|
111
|
+
# @return [false] when ignored.
|
107
112
|
def notify(exception_or_opts, opts = {})
|
108
113
|
return false if config.disabled?
|
109
114
|
|
110
115
|
if exception_or_opts.is_a?(Exception)
|
111
|
-
opts
|
116
|
+
opts[:exception] = exception_or_opts
|
112
117
|
elsif exception_or_opts.respond_to?(:to_hash)
|
113
118
|
opts.merge!(exception_or_opts.to_hash)
|
114
119
|
else
|
@@ -143,16 +148,15 @@ module Honeybadger
|
|
143
148
|
notice.id
|
144
149
|
end
|
145
150
|
|
146
|
-
#
|
147
|
-
#
|
148
|
-
# id - The unique check in id (e.g. '1MqIo1') or the check in url.
|
149
|
-
#
|
150
|
-
# Examples
|
151
|
+
# Perform a synchronous check_in.
|
151
152
|
#
|
153
|
+
# @example
|
152
154
|
# Honeybadger.check_in('1MqIo1')
|
153
155
|
#
|
154
|
-
#
|
155
|
-
#
|
156
|
+
# @param [String] id The unique check in id (e.g. '1MqIo1') or the check in url.
|
157
|
+
#
|
158
|
+
# @return [Boolean] true if the check in was successful and false
|
159
|
+
# otherwise.
|
156
160
|
def check_in(id)
|
157
161
|
# this is to allow check ins even if a url is passed
|
158
162
|
check_in_id = id.to_s.strip.gsub(/\/$/, '').split('/').last
|
@@ -160,21 +164,9 @@ module Honeybadger
|
|
160
164
|
response.success?
|
161
165
|
end
|
162
166
|
|
163
|
-
#
|
164
|
-
#
|
165
|
-
# context - A Hash of data which will be sent to Honeybadger when an error
|
166
|
-
# occurs. If the object responds to #to_honeybadger_context, the return
|
167
|
-
# value of that method will be used (explicit conversion). Can
|
168
|
-
# include any key/value, but a few keys have a special meaning in
|
169
|
-
# Honeybadger (default: nil):
|
170
|
-
# :user_id - The String user ID used by Honeybadger to aggregate
|
171
|
-
# user data across occurrences on the error page (optional).
|
172
|
-
# :user_email - The String user email address (optional).
|
173
|
-
# :tags - The String comma-separated list of tags. When present,
|
174
|
-
# tags will be applied to errors with this context (optional).
|
175
|
-
#
|
176
|
-
# Examples
|
167
|
+
# Save global context for the current request.
|
177
168
|
#
|
169
|
+
# @example
|
178
170
|
# Honeybadger.context({my_data: 'my value'})
|
179
171
|
#
|
180
172
|
# # Inside a Rails controller:
|
@@ -195,39 +187,47 @@ module Honeybadger
|
|
195
187
|
# # Clearing global context:
|
196
188
|
# Honeybadger.context.clear!
|
197
189
|
#
|
198
|
-
#
|
190
|
+
# @param [Hash] context A Hash of data which will be sent to Honeybadger
|
191
|
+
# when an error occurs. If the object responds to +#to_honeybadger_context+,
|
192
|
+
# the return value of that method will be used (explicit conversion). Can
|
193
|
+
# include any key/value, but a few keys have a special meaning in
|
194
|
+
# Honeybadger.
|
195
|
+
#
|
196
|
+
# @option context [String] :user_id The user ID used by Honeybadger
|
197
|
+
# to aggregate user data across occurrences on the error page (optional).
|
198
|
+
# @option context [String] :user_email The user email address (optional).
|
199
|
+
# @option context [String] :tags The comma-separated list of tags.
|
200
|
+
# When present, tags will be applied to errors with this context
|
201
|
+
# (optional).
|
202
|
+
#
|
203
|
+
# @return [self] so that method calls can be chained.
|
199
204
|
def context(context = nil)
|
200
205
|
context_manager.set_context(context) unless context.nil?
|
201
206
|
self
|
202
207
|
end
|
203
208
|
|
204
|
-
#
|
205
|
-
|
209
|
+
# @api private
|
210
|
+
# Used to clear context via `#context.clear!`.
|
211
|
+
def clear! # :nodoc:
|
206
212
|
context_manager.clear!
|
207
213
|
end
|
208
214
|
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
# Examples
|
215
|
+
# Get global context for the current request.
|
213
216
|
#
|
217
|
+
# @example
|
214
218
|
# Honeybadger.context({my_data: 'my value'})
|
215
|
-
# Honeybadger.get_context #
|
219
|
+
# Honeybadger.get_context # => {my_data: 'my value'}
|
216
220
|
#
|
217
|
-
#
|
221
|
+
# @return [Hash, nil]
|
218
222
|
def get_context
|
219
223
|
context_manager.get_context
|
220
224
|
end
|
221
225
|
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
# block - The optional block to execute (exceptions will propagate after data
|
227
|
-
# is flushed).
|
228
|
-
#
|
229
|
-
# Examples
|
226
|
+
# Flushes all data from workers before returning. This is most useful in
|
227
|
+
# tests when using the test backend, where normally the asynchronous nature
|
228
|
+
# of this library could create race conditions.
|
230
229
|
#
|
230
|
+
# @example
|
231
231
|
# # Without a block:
|
232
232
|
# it "sends a notification to Honeybadger" do
|
233
233
|
# expect {
|
@@ -247,8 +247,11 @@ module Honeybadger
|
|
247
247
|
# }.to change(Honeybadger::Backend::Test.notifications[:notices], :size).by(49)
|
248
248
|
# end
|
249
249
|
#
|
250
|
-
#
|
251
|
-
#
|
250
|
+
# @yield An optional block to execute (exceptions will propagate after
|
251
|
+
# data is flushed).
|
252
|
+
#
|
253
|
+
# @return [Object, Boolean] value of block if block is given, otherwise true
|
254
|
+
# on success or false if Honeybadger isn't running.
|
252
255
|
def flush
|
253
256
|
return true unless block_given?
|
254
257
|
yield
|
@@ -256,44 +259,35 @@ module Honeybadger
|
|
256
259
|
worker.flush
|
257
260
|
end
|
258
261
|
|
259
|
-
#
|
260
|
-
#
|
261
|
-
# Examples
|
262
|
+
# Stops the Honeybadger service.
|
262
263
|
#
|
264
|
+
# @example
|
263
265
|
# Honeybadger.stop # => nil
|
264
|
-
#
|
265
|
-
# Returns nothing
|
266
266
|
def stop(force = false)
|
267
267
|
worker.send(force ? :shutdown! : :shutdown)
|
268
268
|
true
|
269
269
|
end
|
270
270
|
|
271
|
+
# @api private
|
271
272
|
attr_reader :config
|
272
273
|
|
273
|
-
#
|
274
|
-
#
|
275
|
-
# block - The configuration block.
|
276
|
-
#
|
277
|
-
# Examples
|
274
|
+
# Configure the Honeybadger agent via Ruby.
|
278
275
|
#
|
276
|
+
# @example
|
279
277
|
# Honeybadger.configure do |config|
|
280
278
|
# config.api_key = 'project api key'
|
281
279
|
# config.exceptions.ignore += [CustomError]
|
282
280
|
# end
|
283
281
|
#
|
284
|
-
#
|
285
|
-
#
|
282
|
+
# @!method configure
|
283
|
+
# @yield [Config::Ruby] configuration object.
|
286
284
|
def_delegator :config, :configure
|
287
285
|
|
288
|
-
#
|
289
|
-
#
|
290
|
-
# See public API documentation for Honeybadger::Notice for available attributes.
|
291
|
-
#
|
292
|
-
# block - A block returning TrueClass true (to ignore) or FalseClass false
|
293
|
-
# (to send).
|
286
|
+
# Callback to ignore exceptions.
|
294
287
|
#
|
295
|
-
#
|
288
|
+
# See public API documentation for {Honeybadger::Notice} for available attributes.
|
296
289
|
#
|
290
|
+
# @example
|
297
291
|
# # Ignoring based on error message:
|
298
292
|
# Honeybadger.exception_filter do |notice|
|
299
293
|
# notice[:error_message] =~ /sensitive data/
|
@@ -304,61 +298,40 @@ module Honeybadger
|
|
304
298
|
# notice[:exception].class < MyError
|
305
299
|
# end
|
306
300
|
#
|
307
|
-
#
|
301
|
+
# @!method exception_filter
|
302
|
+
# @yieldreturn [Boolean] true (to ignore) or false (to send).
|
308
303
|
def_delegator :config, :exception_filter
|
309
304
|
|
310
|
-
#
|
311
|
-
#
|
312
|
-
#
|
305
|
+
# Callback to add a custom grouping strategy for exceptions. The return
|
306
|
+
# value is hashed and sent to Honeybadger. Errors with the same fingerprint
|
307
|
+
# will be grouped.
|
313
308
|
#
|
314
|
-
# See public API documentation for Honeybadger::Notice for available attributes.
|
315
|
-
#
|
316
|
-
# block - A block returning any Object responding to #to_s.
|
317
|
-
#
|
318
|
-
# Examples
|
309
|
+
# See public API documentation for {Honeybadger::Notice} for available attributes.
|
319
310
|
#
|
311
|
+
# @example
|
320
312
|
# Honeybadger.exception_fingerprint do |notice|
|
321
313
|
# [notice[:error_class], notice[:component], notice[:backtrace].to_s].join(':')
|
322
314
|
# end
|
323
315
|
#
|
324
|
-
#
|
316
|
+
# @!method exception_fingerprint
|
317
|
+
# @yieldreturn [#to_s] The fingerprint of the error.
|
325
318
|
def_delegator :config, :exception_fingerprint
|
326
319
|
|
327
|
-
#
|
320
|
+
# Callback to filter backtrace lines. One use for this is to make
|
328
321
|
# additional [PROJECT_ROOT] or [GEM_ROOT] substitutions, which are used by
|
329
322
|
# Honeybadger when grouping errors and displaying application traces.
|
330
323
|
#
|
331
|
-
#
|
332
|
-
#
|
333
|
-
#
|
334
|
-
#
|
335
|
-
# Examples
|
336
|
-
#
|
337
|
-
# Honeybadger.backtrace_filter do |line|
|
338
|
-
# line.gsub(/^\/my\/unknown\/bundle\/path/, "[GEM_ROOT]")
|
339
|
-
# end
|
324
|
+
# @example
|
325
|
+
# Honeybadger.backtrace_filter do |line|
|
326
|
+
# line.gsub(/^\/my\/unknown\/bundle\/path/, "[GEM_ROOT]")
|
327
|
+
# end
|
340
328
|
#
|
341
|
-
#
|
329
|
+
# @!method backtrace_filter
|
330
|
+
# @yieldparam [String] line The backtrace line to modify.
|
331
|
+
# @yieldreturn [String] The new (modified) backtrace line.
|
342
332
|
def_delegator :config, :backtrace_filter
|
343
333
|
|
344
|
-
#
|
345
|
-
# with errors.
|
346
|
-
#
|
347
|
-
# rack_env - The Hash Rack environment.
|
348
|
-
# block - A block to call. Errors reported from within the block will
|
349
|
-
# include request data.
|
350
|
-
#
|
351
|
-
# Examples
|
352
|
-
#
|
353
|
-
# Honeybadger.with_rack_env(env) do
|
354
|
-
# begin
|
355
|
-
# # Risky operation
|
356
|
-
# rescue => e
|
357
|
-
# Honeybadger.notify(e)
|
358
|
-
# end
|
359
|
-
# end
|
360
|
-
#
|
361
|
-
# Returns the return value of block.
|
334
|
+
# @api private
|
362
335
|
def with_rack_env(rack_env, &block)
|
363
336
|
context_manager.set_rack_env(rack_env)
|
364
337
|
yield
|
@@ -366,13 +339,17 @@ module Honeybadger
|
|
366
339
|
context_manager.set_rack_env(nil)
|
367
340
|
end
|
368
341
|
|
369
|
-
#
|
342
|
+
# @api private
|
370
343
|
attr_reader :worker
|
371
344
|
|
372
|
-
#
|
345
|
+
# @api private
|
346
|
+
# @!method init!(...)
|
347
|
+
# @see Config#init!
|
373
348
|
def_delegators :config, :init!
|
374
349
|
|
375
|
-
#
|
350
|
+
# @api private
|
351
|
+
# @!method backend
|
352
|
+
# @see Config#backend
|
376
353
|
def_delegators :config, :backend
|
377
354
|
|
378
355
|
private
|