honeybadger 5.0.0 → 5.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2a2ce33f6ebc41718667b59e4c9aafa07ff171b7ebaa01ec6f0dda61ee5f35b
4
- data.tar.gz: 3c84dc54194ffaaf5c5623048de44d6a9c22e64684c877b16c725836a63f5017
3
+ metadata.gz: 5a2c2c0edaf0bade862e18a686e2f58270e0b11e93a6db396a77a8d7f1e301bd
4
+ data.tar.gz: 16b138e134ad212fa887473ff9d97a11467bd6d08f20cff001e71d926c562cd3
5
5
  SHA512:
6
- metadata.gz: 4733b0ed3b93686aa2441d0e24e07535de45130da9145bf53efae6b0e3a6ccb86b322f72fcaea1cc307a6714f3a1d9c3ac106492b6d95ddabda861df940cbae6
7
- data.tar.gz: b7aed73d5785b846faa2186a8d6f6549a43c8fdc33a42f3b52db93c4e3ba7cc6b2c4768e31ad5904fd94add2659d73361bf17de1278c025c67a82ffc1143f0b1
6
+ metadata.gz: fc0893711e71d35abd15d4ac3c2f40eb6ec21ac46702235287b82c229294c6375e4a8c767cf20dcaa1db4c6f86016385741387d8e7cc6eece65f73655889c5c4
7
+ data.tar.gz: 184d5df4dc67c18d03aa5bcbd5aaaca53b528dc33e9337675c18035c0600e1cfbcdb4b93c484a81ba8b98cda3b6458c2e6b831f1239dc19bb0b35e5c35ebc26c
data/CHANGELOG.md CHANGED
@@ -5,6 +5,39 @@ adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [5.2.1] - 2023-03-14
9
+ ### Fixed
10
+ - Remove ANSI escape codes from detailed error message in Ruby 3.2 (#473)
11
+
12
+ ## [5.2.0] - 2023-02-28
13
+ ### Added
14
+ - First-class support for Hanami (#470)
15
+ - Auto-add Sinatra optional middleware (#471). This is fine, as they don't do anything without the magic strings (and they can be disabled via config, anyway).
16
+
17
+ ## [5.1.0] - 2023-01-31
18
+ ### Added
19
+ - Support for `Exception#detailed_message` on Ruby 3.2 (#459)
20
+ - Added `notice.parsed_backtrace` method, meant to make custom fingerprints easier (#454)
21
+ - Support for Sidekiq 7 (#458)
22
+
23
+ ### Changed
24
+ - On Rails 7, The Honeybadger gem now prioritises the more detailed integrations' native error handlers instead of `Rails.error`, to avoid loss of context (#460)
25
+
26
+ ### Fixed
27
+ - Stopped the Rails middleware from crashing due to changes on Rails 7.1 (#464)
28
+
29
+ ## [5.0.2] - 2022-11-04
30
+ ### Fixed
31
+ - `Honeybadger.check_in` would raise an exception when used with the test backend (#449)
32
+
33
+ ## [5.0.1] - 2022-10-27
34
+ ### Fixed
35
+ - Ignore `Sidekiq::JobRetry` skip exception. Since support was added for Rails 7
36
+ error reporting interface these exceptions are being reported in addition to
37
+ the exception that caused the job to be retried. Mike Perham says these
38
+ exceptions can safely be ignored.
39
+ See https://github.com/rails/rails/pull/43625#issuecomment-1071574110
40
+
8
41
  ## [5.0.0] - 2022-10-18
9
42
  ### Changed
10
43
  - `Honeybadger.notify` is now idempotent; it will skip reporting exception
data/README.md CHANGED
@@ -10,7 +10,7 @@ When an uncaught exception occurs, Honeybadger will POST the relevant data to th
10
10
 
11
11
  ## Documentation and Support
12
12
 
13
- For comprehensive documentation and support, [check out our documentation site](https://docs.honeybadger.io/ruby/index.html).
13
+ For comprehensive documentation and support, [check out our documentation site](https://docs.honeybadger.io/lib/ruby/).
14
14
 
15
15
  ## Changelog
16
16
 
@@ -39,6 +39,7 @@ module Honeybadger
39
39
 
40
40
  def check_in(id)
41
41
  check_ins << id
42
+ super
42
43
  end
43
44
  end
44
45
  end
@@ -5,7 +5,11 @@ module Honeybadger
5
5
  module LogWrapper
6
6
  def add(severity, message = nil, progname = nil)
7
7
  org_severity, org_message, org_progname = severity, message, progname
8
- message, progname = [progname, nil] if message.nil?
8
+ if defined?(Dry::Logger::Entry) && progname.is_a?(Dry::Logger::Entry) # Hanami uses dry-logger
9
+ message, progname = progname.message || progname.exception, progname.progname
10
+ else
11
+ message, progname = [progname, nil] if message.nil?
12
+ end
9
13
  message = message && message.to_s.strip
10
14
  unless should_ignore_log?(message, progname)
11
15
  Honeybadger.add_breadcrumb(message, category: :log, metadata: {
@@ -28,7 +28,8 @@ module Honeybadger
28
28
  'Rack::QueryParser::InvalidParameterError',
29
29
  'CGI::Session::CookieStore::TamperedWithCookie',
30
30
  'Mongoid::Errors::DocumentNotFound',
31
- 'Sinatra::NotFound'].map(&:freeze).freeze
31
+ 'Sinatra::NotFound',
32
+ 'Sidekiq::JobRetry::Skip'].map(&:freeze).freeze
32
33
 
33
34
  DEVELOPMENT_ENVIRONMENTS = ['development', 'test', 'cucumber'].map(&:freeze).freeze
34
35
 
@@ -301,8 +302,11 @@ module Honeybadger
301
302
  type: Boolean
302
303
  },
303
304
  :'rails.subscriber_ignore_sources' => {
304
- description: "Sources (strings or regexes) that should be ignored when using the Rails' (7+) native error reporter.",
305
- default: [],
305
+ description: "Sources (strings or regexes) that should be ignored when using the Rails' (7+) native error reporter (handled exceptions only).",
306
+ # External libraries (eg Sidekiq, Resque) may wrap their execution in Rails' executor.
307
+ # But this means errors will first be reported by Rails.error, before the library's native error handler
308
+ # We ignore these reports, since the native error handler provides more context (such as job details)
309
+ default: ['application.active_support'],
306
310
  type: Array
307
311
  },
308
312
  :'resque.resque_retry.send_exceptions_when_retrying' => {
@@ -271,6 +271,8 @@ module Honeybadger
271
271
  :rails
272
272
  elsif defined?(::Sinatra::VERSION)
273
273
  :sinatra
274
+ elsif defined?(::Hanami::VERSION) && ::Hanami::VERSION >= '2.0'
275
+ :hanami
274
276
  elsif defined?(::Rack.release)
275
277
  :rack
276
278
  else
@@ -282,6 +284,7 @@ module Honeybadger
282
284
  case detected_framework
283
285
  when :rails then "Rails #{::Rails::VERSION::STRING}"
284
286
  when :sinatra then "Sinatra #{::Sinatra::VERSION}"
287
+ when :hanami then "Hanami #{::Hanami::VERSION}"
285
288
  when :rack then "Rack #{::Rack.release}"
286
289
  else
287
290
  "Ruby #{RUBY_VERSION}"
@@ -0,0 +1,19 @@
1
+ require 'honeybadger/ruby'
2
+
3
+ Honeybadger.init!({
4
+ :framework => :hanami,
5
+ :env => ENV['HANAMI_ENV'] || ENV['RACK_ENV'],
6
+ :'logging.path' => 'STDOUT'
7
+ })
8
+
9
+ Honeybadger.load_plugins!
10
+
11
+ if Hanami::VERSION >= '2.0'
12
+ Hanami.app.instance_eval do
13
+ config.middleware.use Honeybadger::Rack::UserFeedback
14
+ config.middleware.use Honeybadger::Rack::UserInformer
15
+ config.middleware.use Honeybadger::Rack::ErrorNotifier
16
+ end
17
+ end
18
+
19
+ Honeybadger.install_at_exit_callback
@@ -28,7 +28,13 @@ module Honeybadger
28
28
  def install_honeybadger
29
29
  config = Honeybadger.config
30
30
  return unless config[:'sinatra.enabled']
31
- install_honeybadger_middleware(Honeybadger::Rack::ErrorNotifier) if config[:'exceptions.enabled']
31
+ if config[:'exceptions.enabled']
32
+ # These two must come before the ErrorNotifier, since an error/response
33
+ # passes through middleware from inner to outer (bottom to top)
34
+ install_honeybadger_middleware(Honeybadger::Rack::UserFeedback)
35
+ install_honeybadger_middleware(Honeybadger::Rack::UserInformer)
36
+ install_honeybadger_middleware(Honeybadger::Rack::ErrorNotifier)
37
+ end
32
38
  end
33
39
 
34
40
  def install_honeybadger_middleware(klass)
@@ -144,6 +144,14 @@ module Honeybadger
144
144
  # Custom details data
145
145
  attr_accessor :details
146
146
 
147
+ # The parsed exception backtrace. Lines in this backtrace that are from installed gems
148
+ # have the base path for gem installs replaced by "[GEM_ROOT]", while those in the project
149
+ # have "[PROJECT_ROOT]".
150
+ # @return [Array<{:number, :file, :method => String}>]
151
+ def parsed_backtrace
152
+ @parsed_backtrace ||= parse_backtrace(backtrace)
153
+ end
154
+
147
155
  # @api private
148
156
  # Cache project path substitutions for backtrace lines.
149
157
  PROJECT_ROOT_CACHE = {}
@@ -192,7 +200,10 @@ module Honeybadger
192
200
 
193
201
  self.error_class = exception_attribute(:error_class, 'Notice') {|exception| exception.class.name }
194
202
  self.error_message = exception_attribute(:error_message, 'No message provided') do |exception|
195
- "#{exception.class.name}: #{exception.message}"
203
+ message = exception.respond_to?(:detailed_message) ?
204
+ exception.detailed_message(highlight: false).sub(" (#{exception.class.name})", '') # Gems like error_highlight append the exception class name
205
+ : exception.message
206
+ "#{exception.class.name}: #{message}"
196
207
  end
197
208
  self.backtrace = exception_attribute(:backtrace, caller)
198
209
  self.cause = opts.key?(:cause) ? opts[:cause] : (exception_cause(@exception) || $!)
@@ -235,7 +246,7 @@ module Honeybadger
235
246
  token: id,
236
247
  class: s(error_class),
237
248
  message: s(error_message),
238
- backtrace: s(parse_backtrace(backtrace)),
249
+ backtrace: s(parsed_backtrace),
239
250
  fingerprint: fingerprint_hash,
240
251
  tags: s(tags),
241
252
  causes: s(prepare_causes(causes))
@@ -297,7 +308,7 @@ module Honeybadger
297
308
  end
298
309
 
299
310
  # Gets a property named "attribute" of an exception, either from
300
- # the #args hash or actual exception (in order of precidence).
311
+ # the #args hash or actual exception (in order of precedence).
301
312
  #
302
313
  # attribute - A Symbol existing as a key in #args and/or attribute on
303
314
  # Exception.
@@ -13,7 +13,7 @@ module Honeybadger
13
13
  #
14
14
  # @return The super value of the middleware's +#render_exception()+
15
15
  # method.
16
- def render_exception(arg, exception)
16
+ def render_exception(arg, exception, *args)
17
17
  if arg.kind_of?(::ActionDispatch::Request)
18
18
  request = arg
19
19
  env = request.env
@@ -25,18 +25,28 @@ module Honeybadger
25
25
  env['honeybadger.exception'] = exception
26
26
  env['honeybadger.request.url'] = request.url rescue nil
27
27
 
28
- super(arg, exception)
28
+ super(arg, exception, *args)
29
29
  end
30
30
  end
31
31
 
32
32
  class ErrorSubscriber
33
33
  def self.report(exception, handled:, severity:, context: {}, source: nil)
34
- return if source && ::Honeybadger.config[:'rails.subscriber_ignore_sources'].any? { |regex| regex.match?(source) }
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)
35
39
 
36
40
  tags = ["severity:#{severity}", "handled:#{handled}"]
37
41
  tags << "source:#{source}" if source
38
42
  Honeybadger.notify(exception, context: context, tags: tags)
39
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
40
50
  end
41
51
 
42
52
  Plugin.register :rails_exceptions_catcher do
@@ -52,8 +62,7 @@ module Honeybadger
52
62
  ::ActionDispatch::ShowExceptions.prepend(ExceptionsCatcher)
53
63
  end
54
64
 
55
- if defined?(::ActiveSupport::ErrorReporter)
56
- # Rails 7
65
+ if defined?(::ActiveSupport::ErrorReporter) # Rails 7
57
66
  ::Rails.error.subscribe(ErrorSubscriber)
58
67
  end
59
68
  end
@@ -23,8 +23,15 @@ module Honeybadger
23
23
 
24
24
  if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
25
25
  ::Sidekiq.configure_server do |sidekiq|
26
- sidekiq.error_handlers << lambda { |ex, params|
26
+
27
+ sidekiq.error_handlers << lambda { |ex, sidekiq_params|
28
+ params = sidekiq_params.dup
29
+ if defined?(::Sidekiq::Config) && params[:_config].is_a?(::Sidekiq::Config)
30
+ params[:_config] = params[:_config].instance_variable_get(:@options)
31
+ end
32
+
27
33
  job = params[:job] || params
34
+
28
35
  job_retry = job['retry'.freeze]
29
36
 
30
37
  if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
@@ -36,9 +43,11 @@ module Honeybadger
36
43
  retry_count = job['retry_count'.freeze]
37
44
  attempt = retry_count ? retry_count + 1 : 0
38
45
 
46
+ max_retries = (::Sidekiq::VERSION > '7') ?
47
+ ::Sidekiq.default_configuration[:max_retries] : sidekiq.options[:max_retries]
39
48
  # Ensure we account for modified max_retries setting
40
49
  default_max_retry_attempts = defined?(::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS) ? ::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS : 25
41
- retry_limit = job_retry == true ? (sidekiq.options[:max_retries] || default_max_retry_attempts) : job_retry.to_i
50
+ retry_limit = job_retry == true ? (max_retries || default_max_retry_attempts) : job_retry.to_i
42
51
 
43
52
  limit = [retry_limit, threshold].min
44
53
 
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.0.0'.freeze
3
+ VERSION = '5.2.1'.freeze
4
4
  end
data/lib/honeybadger.rb CHANGED
@@ -2,6 +2,8 @@ if defined?(::Rails::Railtie)
2
2
  require 'honeybadger/init/rails'
3
3
  elsif defined?(Sinatra::Base)
4
4
  require 'honeybadger/init/sinatra'
5
+ elsif defined?(::Hanami)
6
+ require 'honeybadger/init/hanami'
5
7
  else
6
8
  require 'honeybadger/init/ruby'
7
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email:
@@ -55,6 +55,7 @@ files:
55
55
  - lib/honeybadger/const.rb
56
56
  - lib/honeybadger/context_manager.rb
57
57
  - lib/honeybadger/conversions.rb
58
+ - lib/honeybadger/init/hanami.rb
58
59
  - lib/honeybadger/init/rails.rb
59
60
  - lib/honeybadger/init/rake.rb
60
61
  - lib/honeybadger/init/ruby.rb
@@ -131,10 +132,15 @@ files:
131
132
  - vendor/cli/thor/shell/html.rb
132
133
  - vendor/cli/thor/util.rb
133
134
  - vendor/cli/thor/version.rb
134
- homepage: https://github.com/honeybadger-io/honeybadger-ruby
135
+ homepage: https://www.honeybadger.io/for/ruby/
135
136
  licenses:
136
137
  - MIT
137
- metadata: {}
138
+ metadata:
139
+ bug_tracker_uri: https://github.com/honeybadger-io/honeybadger-ruby/issues
140
+ changelog_uri: https://github.com/honeybadger-io/honeybadger-ruby/blob/master/CHANGELOG.md
141
+ documentation_uri: https://docs.honeybadger.io/lib/ruby/
142
+ homepage_uri: https://www.honeybadger.io/for/ruby/
143
+ source_code_uri: https://github.com/honeybadger-io/honeybadger-ruby
138
144
  post_install_message:
139
145
  rdoc_options:
140
146
  - "--markup=tomdoc"