honeybadger 4.5.4 → 4.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2e3e46ae65528005cf9ff22cb073c92a4c159b316bacc040907bdff79828a42
4
- data.tar.gz: 788b73aab89e83e52b1d94c8d18f3ce3a9232698412ac11bd16be91ce7011cc1
3
+ metadata.gz: 2c76ef937ae77d449421f97e342bd86f77176a705fb6b7a75e4928e0a48fc71b
4
+ data.tar.gz: db036be307a2f741187951a46f30845451e5e01d49d266250837dcb6869b084c
5
5
  SHA512:
6
- metadata.gz: d4304b0457b18a8b7ed6748e453e99979cc496dff52bbae872940d3341f6aaa642214966dbffd9c73a0d0170ebdaf84ce00af891a1e24deaeaa1bc064d6ad557
7
- data.tar.gz: e1b3d6a70a1ae058380c4ff4fbb65722475c431879cb5add603e2a0b5efef7a6ed4de85204af03ecf020afb74b94d682d221a02a2c6ab5b2337289e263becc61
6
+ metadata.gz: e57d7371fa97c9e9f356824ac5ee15454106cbf332d772c0fc74f01a5d8d5aaac7b78f7f09eacc2d4e902c432f24ca30146ed36e697048ee9a9e31902472942d
7
+ data.tar.gz: 6f14009e5ea56d72bdba4a95a3bcfe23fd29e6bc8870b701e3f6a0869e4aa750bc56485ac149f512484881bdd477af7c8dd41668b104323d54be840c31f13800
@@ -5,6 +5,43 @@ adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.7.1] - 2020-08-11
9
+ ### Fixed
10
+ - ActiveRecord SQL Breadcrumb event pulls adapter from supplied connection,
11
+ allowing for multiple databases.
12
+ - Fix Rails deprecation of `ActionDispatch::ParamsParser::ParseError`
13
+ - Deal with invalid UTF-8 byte sequences during SQL obfuscation
14
+ - Fix Ruby 2.7 deprecation notice in sql.rb
15
+
16
+ ## [4.7.0] - 2020-06-02
17
+ ### Fixed
18
+ - Alias `Notice#controller=` as `Notice#component=`
19
+ - Fix Rails 6.1 deprecation warning with `ActiveRecord::Base.connection_config`
20
+ - Fix agent where breadcrumbs.enabled = true and local_context = true
21
+
22
+ ### Added
23
+ - Add `honeybadger_skip_rails_load` Capistrano option to skip rails load on
24
+ deployment notification (#355) -@NielsKSchjoedt
25
+
26
+ ## [4.6.0] - 2020-03-12
27
+ ### Fixed
28
+ - Fixed issue where Sidekiq.attempt_threshold was triggering 2 attempts ahead
29
+ of the setting
30
+ - Dup notify opts before mutating (#345)
31
+
32
+ ### Changed
33
+ - Breadcrumbs on by default
34
+ - Added Faktory plugin -@scottrobertson
35
+
36
+ ## [4.5.6] - 2020-01-08
37
+ ### Fixed
38
+ - Fix remaining Ruby 2.7 deprecation warnings
39
+
40
+ ## [4.5.5] - 2020-01-06
41
+ ### Fixed
42
+ - Replace empty `Proc.new` with explicit block param to suppress warnings
43
+ in Ruby 2.7
44
+
8
45
  ## [4.5.4] - 2019-12-09
9
46
  ### Fixed
10
47
  - Re-released to remove vendor cruft
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Honeybadger for Ruby
2
2
 
3
- [![CircleCI](https://circleci.com/gh/honeybadger-io/honeybadger-ruby.svg?style=svg)](https://circleci.com/gh/honeybadger-io/honeybadger-ruby)
3
+ ![Ruby](https://github.com/honeybadger-io/honeybadger-ruby/workflows/Ruby/badge.svg)
4
+ ![JRuby](https://github.com/honeybadger-io/honeybadger-ruby/workflows/JRuby/badge.svg)
4
5
  [![Gem Version](https://badge.fury.io/rb/honeybadger.svg)](http://badge.fury.io/rb/honeybadger)
5
6
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=honeybadger&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=honeybadger&package-manager=bundler&version-scheme=semver)
6
7
 
@@ -63,13 +63,17 @@ module Honeybadger
63
63
  end
64
64
 
65
65
  @context = opts.delete(:context)
66
- if opts.delete(:local_context)
66
+ local_context = opts.delete(:local_context)
67
+
68
+ @config ||= Config.new(opts)
69
+
70
+ if local_context
67
71
  @context ||= ContextManager.new
68
72
  @breadcrumbs = Breadcrumbs::Collector.new(config)
73
+ else
74
+ @breadcrumbs = nil
69
75
  end
70
76
 
71
- @config ||= Config.new(opts)
72
-
73
77
  init_worker
74
78
  end
75
79
 
@@ -115,6 +119,8 @@ module Honeybadger
115
119
  # @return [String] UUID reference to the notice within Honeybadger.
116
120
  # @return [false] when ignored.
117
121
  def notify(exception_or_opts, opts = {})
122
+ opts = opts.dup
123
+
118
124
  if exception_or_opts.is_a?(Exception)
119
125
  opts[:exception] = exception_or_opts
120
126
  elsif exception_or_opts.respond_to?(:to_hash)
@@ -278,7 +284,7 @@ module Honeybadger
278
284
  metadata: metadata
279
285
  })
280
286
 
281
- breadcrumbs.add!(Breadcrumbs::Breadcrumb.new(params))
287
+ breadcrumbs.add!(Breadcrumbs::Breadcrumb.new(**params))
282
288
 
283
289
  self
284
290
  end
@@ -15,10 +15,11 @@ module Honeybadger
15
15
  ["Active Record", name].compact.join(" - ")
16
16
  end,
17
17
  category: "query",
18
- select_keys: [:sql, :name, :connection_id, :cached],
18
+ select_keys: [:sql, :name, :connection, :connection_id, :cached],
19
19
  transform: lambda do |data|
20
20
  if data[:sql]
21
- adapter = ::ActiveRecord::Base.connection_config[:adapter]
21
+ connection = data.delete(:connection) || ::ActiveRecord::Base.connection
22
+ adapter = connection.adapter_name.downcase
22
23
  data[:sql] = Util::SQL.obfuscate(data[:sql], adapter)
23
24
  end
24
25
  data
@@ -102,7 +103,6 @@ module Honeybadger
102
103
  }
103
104
  }
104
105
  end
105
-
106
106
  end
107
107
  end
108
108
  end
@@ -15,7 +15,7 @@ To fix this issue, please try the following:
15
15
 
16
16
  - Make sure the gem is configured properly.
17
17
  - Retry executing this command a few times.
18
- - Make sure you can connect to #{host} (`ping #{host}`).
18
+ - Make sure you can connect to #{host} (`curl https://#{host}/v1/notices`).
19
19
  - Email support@honeybadger.io for help. Include as much debug info as you
20
20
  can for a faster resolution!
21
21
 
@@ -196,7 +196,7 @@ WELCOME
196
196
  # What can I do?
197
197
 
198
198
  - Retry the command.
199
- - Make sure you can connect to api.honeybadger.io (`ping api.honeybadger.io`).
199
+ - Make sure you can connect to api.honeybadger.io (`curl https://api.honeybadger.io/v1/notices`).
200
200
  - If you continue to see this message, email us at support@honeybadger.io
201
201
  (don't forget to attach this output!)
202
202
 
@@ -175,7 +175,7 @@ To fix this issue, please try the following:
175
175
 
176
176
  - Make sure the gem is configured properly.
177
177
  - Retry executing this command a few times.
178
- - Make sure you can connect to #{host} (`ping #{host}`).
178
+ - Make sure you can connect to #{host} (`curl https://#{host}/v1/notices`).
179
179
  - Email support@honeybadger.io for help. Include as much debug info as you
180
180
  can for a faster resolution!
181
181
 
@@ -79,10 +79,10 @@ module Honeybadger
79
79
  self
80
80
  end
81
81
 
82
- def backtrace_filter
82
+ def backtrace_filter(&block)
83
83
  if block_given?
84
84
  warn('DEPRECATED: backtrace_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#backtrace_filter')
85
- self[:backtrace_filter] = Proc.new
85
+ self[:backtrace_filter] = block
86
86
  end
87
87
 
88
88
  self[:backtrace_filter]
@@ -92,19 +92,19 @@ module Honeybadger
92
92
  (ruby[:before_notify] || []).clone
93
93
  end
94
94
 
95
- def exception_filter
95
+ def exception_filter(&block)
96
96
  if block_given?
97
97
  warn('DEPRECATED: exception_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_filter')
98
- self[:exception_filter] = Proc.new
98
+ self[:exception_filter] = block
99
99
  end
100
100
 
101
101
  self[:exception_filter]
102
102
  end
103
103
 
104
- def exception_fingerprint
104
+ def exception_fingerprint(&block)
105
105
  if block_given?
106
106
  warn('DEPRECATED: exception_fingerprint is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_fingerprint')
107
- self[:exception_fingerprint] = Proc.new
107
+ self[:exception_fingerprint] = block
108
108
  end
109
109
 
110
110
  self[:exception_fingerprint]
@@ -13,7 +13,12 @@ module Honeybadger
13
13
  'ActionController::UnknownFormat',
14
14
  'ActionController::InvalidAuthenticityToken',
15
15
  'ActionController::InvalidCrossOriginRequest',
16
+ # ActionDispatch::ParamsParser::ParseError was removed in Rails 6.0
17
+ # and may be removed here once support for Rails 5.2 is dropped.
18
+ # https://github.com/rails/rails/commit/e16c765ac6dcff068ff2e5554d69ff345c003de1
19
+ # https://github.com/honeybadger-io/honeybadger-ruby/pull/358
16
20
  'ActionDispatch::ParamsParser::ParseError',
21
+ 'ActionDispatch::Http::Parameters::ParseError',
17
22
  'ActionController::BadRequest',
18
23
  'ActionController::ParameterMissing',
19
24
  'ActiveRecord::RecordNotFound',
@@ -279,6 +284,11 @@ module Honeybadger
279
284
  default: 0,
280
285
  type: Integer
281
286
  },
287
+ :'faktory.attempt_threshold' => {
288
+ description: 'The number of attempts before notifications will be sent.',
289
+ default: 0,
290
+ type: Integer
291
+ },
282
292
  :'sidekiq.use_component' => {
283
293
  description: 'Automatically set the component to the class of the job. Helps with grouping.',
284
294
  default: true,
@@ -295,8 +305,8 @@ module Honeybadger
295
305
  type: Boolean
296
306
  },
297
307
  :'breadcrumbs.enabled' => {
298
- description: 'Enable/Disable breadcrumb functionality.',
299
- default: false,
308
+ description: 'Disable breadcrumb functionality.',
309
+ default: true,
300
310
  type: Boolean
301
311
  },
302
312
  :'breadcrumbs.active_support_notifications' => {
@@ -93,28 +93,28 @@ module Honeybadger
93
93
  hash[:before_notify] = hooks
94
94
  end
95
95
 
96
- def backtrace_filter
96
+ def backtrace_filter(&block)
97
97
  if block_given?
98
98
  logger.warn('DEPRECATED: backtrace_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#backtrace_filter')
99
- hash[:backtrace_filter] = Proc.new if block_given?
99
+ hash[:backtrace_filter] = block if block_given?
100
100
  end
101
101
 
102
102
  get(:backtrace_filter)
103
103
  end
104
104
 
105
- def exception_filter
105
+ def exception_filter(&block)
106
106
  if block_given?
107
107
  logger.warn('DEPRECATED: exception_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_filter')
108
- hash[:exception_filter] = Proc.new
108
+ hash[:exception_filter] = block
109
109
  end
110
110
 
111
111
  get(:exception_filter)
112
112
  end
113
113
 
114
- def exception_fingerprint
114
+ def exception_fingerprint(&block)
115
115
  if block_given?
116
116
  logger.warn('DEPRECATED: exception_fingerprint is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_fingerprint')
117
- hash[:exception_fingerprint] = Proc.new
117
+ hash[:exception_fingerprint] = block
118
118
  end
119
119
 
120
120
  get(:exception_fingerprint)
@@ -42,6 +42,10 @@ module Honeybadger
42
42
  # @api private
43
43
  MAX_EXCEPTION_CAUSES = 5
44
44
 
45
+ # @api private
46
+ # Binding#source_location was added in Ruby 2.6.
47
+ BINDING_HAS_SOURCE_LOCATION = Binding.method_defined?(:source_location)
48
+
45
49
  class Notice
46
50
  extend Forwardable
47
51
 
@@ -114,6 +118,7 @@ module Honeybadger
114
118
  # The component (if any) which was used in this request (usually the controller).
115
119
  attr_accessor :component
116
120
  alias_method :controller, :component
121
+ alias_method :controller=, :component=
117
122
 
118
123
  # The action (if any) that was called in this request.
119
124
  attr_accessor :action
@@ -444,7 +449,13 @@ module Honeybadger
444
449
  return {} if exception.__honeybadger_bindings_stack.empty?
445
450
 
446
451
  if config[:root]
447
- binding = exception.__honeybadger_bindings_stack.find { |b| b.eval('__FILE__') =~ /^#{Regexp.escape(config[:root].to_s)}/ }
452
+ binding = exception.__honeybadger_bindings_stack.find { |b|
453
+ if BINDING_HAS_SOURCE_LOCATION
454
+ b.source_location[0]
455
+ else
456
+ b.eval('__FILE__')
457
+ end =~ /^#{Regexp.escape(config[:root].to_s)}/
458
+ }
448
459
  end
449
460
 
450
461
  binding ||= exception.__honeybadger_bindings_stack[0]
@@ -66,11 +66,11 @@ module Honeybadger
66
66
  # +snake_case+. The name is inferred from the current file name if omitted.
67
67
  #
68
68
  # @return nil
69
- def register(name = nil)
69
+ def register(name = nil, &block)
70
70
  name ||= name_from_caller(caller) or
71
71
  raise(ArgumentError, 'Plugin name is required, but was nil.')
72
72
  instances[key = name.to_sym] and fail("Already registered: #{name}")
73
- instances[key] = new(name).tap { |d| d.instance_eval(&Proc.new) }
73
+ instances[key] = new(name).tap { |d| d.instance_eval(&block) }
74
74
  end
75
75
 
76
76
  # @api private
@@ -136,8 +136,8 @@ module Honeybadger
136
136
  # end
137
137
  #
138
138
  # @return nil
139
- def requirement
140
- @requirements << Proc.new
139
+ def requirement(&block)
140
+ @requirements << block
141
141
  end
142
142
 
143
143
  # Define an execution block. Execution blocks will be executed if all
@@ -161,8 +161,8 @@ module Honeybadger
161
161
  # end
162
162
  #
163
163
  # @return nil
164
- def execution
165
- @executions << Proc.new
164
+ def execution(&block)
165
+ @executions << block
166
166
  end
167
167
 
168
168
  # @api private
@@ -0,0 +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
@@ -25,20 +25,30 @@ module Honeybadger
25
25
  ::Sidekiq.configure_server do |sidekiq|
26
26
  sidekiq.error_handlers << lambda {|ex, params|
27
27
  job = params[:job] || params
28
- retry_count = job['retry_count'.freeze].to_i
29
- retry_opt = job['retry'.freeze]
30
- max_retries = if retry_opt.is_a?(Integer)
31
- [retry_opt - 1, config[:'sidekiq.attempt_threshold'].to_i].min
32
- else
33
- config[:'sidekiq.attempt_threshold'].to_i
28
+ job_retry = job['retry'.freeze]
29
+
30
+ if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
31
+ # We calculate the job attempts to determine the need to
32
+ # skip. Sidekiq's first job execution will have nil for the
33
+ # 'retry_count' job key. The first retry will have 0 set for
34
+ # the 'retry_count' key, incrementing on each execution
35
+ # afterwards.
36
+ retry_count = job['retry_count'.freeze]
37
+ attempt = retry_count ? retry_count + 1 : 0
38
+
39
+ # Ensure we account for modified max_retries setting
40
+ retry_limit = job_retry == true ? (sidekiq.options[:max_retries] || 25) : job_retry.to_i
41
+ limit = [retry_limit, threshold].min
42
+
43
+ return if attempt < limit
34
44
  end
35
45
 
36
- return if retry_opt && retry_count < max_retries
37
46
  opts = {parameters: params}
38
47
  if config[:'sidekiq.use_component']
39
48
  opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
40
49
  opts[:action] = 'perform' if opts[:component]
41
50
  end
51
+
42
52
  Honeybadger.notify(ex, opts)
43
53
  }
44
54
  end
@@ -187,7 +187,7 @@ module Honeybadger
187
187
 
188
188
  def valid_encoding(string)
189
189
  return string if valid_encoding?(string)
190
- string.encode(Encoding::UTF_8, ENCODE_OPTS)
190
+ string.encode(Encoding::UTF_8, **ENCODE_OPTS)
191
191
  end
192
192
 
193
193
  def recursive?(data)
@@ -11,7 +11,7 @@ module Honeybadger
11
11
  DoubleQuoters = /(postgres|sqlite|postgis)/.freeze
12
12
 
13
13
  def self.obfuscate(sql, adapter)
14
- sql.dup.tap do |s|
14
+ force_utf_8(sql.dup).tap do |s|
15
15
  s.gsub!(EscapedQuotes, EmptyReplacement)
16
16
  s.gsub!(SQuotedData, Replacement)
17
17
  s.gsub!(DQuotedData, Replacement) if adapter =~ DoubleQuoters
@@ -20,6 +20,15 @@ module Honeybadger
20
20
  s.squeeze!(' ')
21
21
  end
22
22
  end
23
+
24
+ def self.force_utf_8(string)
25
+ string.encode(
26
+ Encoding.find('UTF-8'),
27
+ invalid: :replace,
28
+ undef: :replace,
29
+ replace: ''
30
+ )
31
+ end
23
32
  end
24
33
  end
25
34
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '4.5.4'.freeze
3
+ VERSION = '4.7.1'.freeze
4
4
  end
@@ -24,6 +24,7 @@ namespace :honeybadger do
24
24
 
25
25
  api_key = fetch(:honeybadger_api_key, ENV['HONEYBADGER_API_KEY'])
26
26
  options += ['--api-key', api_key] if api_key
27
+ options << '--skip-rails-load' if fetch(:honeybadger_skip_rails_load, false)
27
28
 
28
29
  if fetch(:honeybadger_async_notify, false)
29
30
  ::SSHKit.config.command_map.prefix[:honeybadger].push(:nohup)
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: 4.5.4
4
+ version: 4.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email:
@@ -65,6 +65,7 @@ files:
65
65
  - lib/honeybadger/plugins/breadcrumbs.rb
66
66
  - lib/honeybadger/plugins/delayed_job.rb
67
67
  - lib/honeybadger/plugins/delayed_job/plugin.rb
68
+ - lib/honeybadger/plugins/faktory.rb
68
69
  - lib/honeybadger/plugins/lambda.rb
69
70
  - lib/honeybadger/plugins/local_variables.rb
70
71
  - lib/honeybadger/plugins/passenger.rb
@@ -134,7 +135,7 @@ homepage: https://github.com/honeybadger-io/honeybadger-ruby
134
135
  licenses:
135
136
  - MIT
136
137
  metadata: {}
137
- post_install_message:
138
+ post_install_message:
138
139
  rdoc_options:
139
140
  - "--markup=tomdoc"
140
141
  - "--main=README.md"
@@ -152,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubygems_version: 3.0.3
156
- signing_key:
156
+ rubygems_version: 3.1.2
157
+ signing_key:
157
158
  specification_version: 4
158
159
  summary: Error reports you can be happy about.
159
160
  test_files: []