honeybadger 4.5.6 → 4.7.3

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: baff304bc3d7912d3643efbc651829441b80b52d7a48d8c2ecb7bc9ab35aac81
4
- data.tar.gz: 3892040a92da339c9f41960c61a2ad30d16597f984f630e595cc2b9fd1c7e31a
3
+ metadata.gz: 818d4ae873c692edd42ec3e8ab30e118726634ea7681d85c5bce558f558372e1
4
+ data.tar.gz: 16a590d564bd41eb7f6b498e31f46f295d68ab20ef062783cdbdc627a367e712
5
5
  SHA512:
6
- metadata.gz: e29645665a943c5e9055bd0ecd481f289ffb230c113a776311317b6d3ce65f6003bfa0cc7dd2e7461b1ca0b226e36fa73288d27dda124832051b059d090ef7e5
7
- data.tar.gz: 834c71bf1fd0d35512025d73c39485bb95fb513001acec616c342d2a4a42b4c297690415c2a2e4e00098f4d890646bc0427ff4b6f05552d94e44f77de7e6894c
6
+ metadata.gz: 2fbbaa748ba04699498d632b785c7eec3a38eebf48fc2bbeaa77092db1397091fb5fd1e7c1b896836ec9f9f5c64decd33a1e858a3ccf4a99f71d11526d27e476
7
+ data.tar.gz: 9b8063dd6c781f09c81b9d468216b504676015fd9b80a38c73e0f74d790896fead725dab28cb510558ac67c1548bf7161b67142e1d86c84ef1159ca472b1829b
data/CHANGELOG.md CHANGED
@@ -5,6 +5,43 @@ adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.7.3] - 2021-02-10
9
+ ### Fixed
10
+ - Don't enable Lambda plugin in non-Lambda execution environments
11
+
12
+ ## [4.7.2] - 2020-08-17
13
+ ### Fixed
14
+ - Remove usage of `ActiveRecord::Base.connection` (thanks @jcoyne for testing)
15
+ - Check for UTF-8 in ActiveRecord breadcrumb exclusion filter
16
+
17
+ ## [4.7.1] - 2020-08-11
18
+ ### Fixed
19
+ - ActiveRecord SQL Breadcrumb event pulls adapter from supplied connection,
20
+ allowing for multiple databases.
21
+ - Fix Rails deprecation of `ActionDispatch::ParamsParser::ParseError`
22
+ - Deal with invalid UTF-8 byte sequences during SQL obfuscation
23
+ - Fix Ruby 2.7 deprecation notice in sql.rb
24
+
25
+ ## [4.7.0] - 2020-06-02
26
+ ### Fixed
27
+ - Alias `Notice#controller=` as `Notice#component=`
28
+ - Fix Rails 6.1 deprecation warning with `ActiveRecord::Base.connection_config`
29
+ - Fix agent where breadcrumbs.enabled = true and local_context = true
30
+
31
+ ### Added
32
+ - Add `honeybadger_skip_rails_load` Capistrano option to skip rails load on
33
+ deployment notification (#355) -@NielsKSchjoedt
34
+
35
+ ## [4.6.0] - 2020-03-12
36
+ ### Fixed
37
+ - Fixed issue where Sidekiq.attempt_threshold was triggering 2 attempts ahead
38
+ of the setting
39
+ - Dup notify opts before mutating (#345)
40
+
41
+ ### Changed
42
+ - Breadcrumbs on by default
43
+ - Added Faktory plugin -@scottrobertson
44
+
8
45
  ## [4.5.6] - 2020-01-08
9
46
  ### Fixed
10
47
  - Fix remaining Ruby 2.7 deprecation warnings
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)
@@ -15,17 +15,19 @@ 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)
22
+ adapter = (connection && connection.adapter_name.downcase) || active_record_connection_db_config[:adapter]
22
23
  data[:sql] = Util::SQL.obfuscate(data[:sql], adapter)
23
24
  end
24
25
  data
25
26
  end,
26
27
  exclude_when: lambda do |data|
27
28
  # Ignore schema, begin, and commit transaction queries
28
- data[:name] == "SCHEMA" || (data[:sql] && (data[:sql] =~ /^(begin|commit)( transaction)?$/i))
29
+ data[:name] == "SCHEMA" ||
30
+ (data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( transaction)?$/i))
29
31
  end
30
32
  },
31
33
 
@@ -103,6 +105,15 @@ module Honeybadger
103
105
  }
104
106
  end
105
107
 
108
+ private_class_method def self.active_record_connection_db_config
109
+ if ::ActiveRecord::Base.respond_to?(:connection_db_config)
110
+ # >= Rails 6.1
111
+ ::ActiveRecord::Base.connection_db_config.configuration_hash
112
+ else
113
+ # < Rails 6.1
114
+ ::ActiveRecord::Base.connection_config
115
+ end
116
+ end
106
117
  end
107
118
  end
108
119
  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
 
@@ -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' => {
@@ -118,6 +118,7 @@ module Honeybadger
118
118
  # The component (if any) which was used in this request (usually the controller).
119
119
  attr_accessor :component
120
120
  alias_method :controller, :component
121
+ alias_method :controller=, :component=
121
122
 
122
123
  # The action (if any) that was called in this request.
123
124
  attr_accessor :action
@@ -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
@@ -14,7 +14,7 @@ module Honeybadger
14
14
 
15
15
  class << self
16
16
  def lambda_execution?
17
- !!ENV["AWS_EXECUTION_ENV"]
17
+ !!ENV["AWS_LAMBDA_FUNCTION_NAME"]
18
18
  end
19
19
 
20
20
  def normalized_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.6'.freeze
3
+ VERSION = '4.7.3'.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.6
4
+ version: 4.7.3
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: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2021-02-10 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,9 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.7.6.2
157
- signing_key:
156
+ rubygems_version: 3.2.3
157
+ signing_key:
158
158
  specification_version: 4
159
159
  summary: Error reports you can be happy about.
160
160
  test_files: []