honeybadger 4.6.0 → 4.8.0

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: a0a903cc9a64fe0e5b5bcbfef32b81656217d38316ffc66d368d8cc8982bdc04
4
- data.tar.gz: fd4ff117b94da660a2039ebc106e7c29430834f3c691c6940cc1bc483dcbc0ac
3
+ metadata.gz: b3ec66f5016be98ed5d5a4d805a7dca2069a1c585ac10809813acd999a4f96eb
4
+ data.tar.gz: d7a4179a6bfad487e789749ca3e38d90bc84cc4bfa1b4fbc2ce48b48a233023c
5
5
  SHA512:
6
- metadata.gz: e3f58753fa625545ffba12aaa7d9a86e3f8c7c8e3dc6ca1eaa518dd69e1636ef03d4a4b8a71677f34d8816166700102962e94288cb4e82913d1f5c2c0b6564f7
7
- data.tar.gz: 33459d61b1eae5ab575f65a0ff6b1b7e64a891538b4f5508fe3a45b72fa8c47830a55007858f8aaef97b1c5eaf22a6efdfa3e9147e53eda9a9cde8e854335f7f
6
+ metadata.gz: c5b6a551d2d3fe7feca0d4c9c02878e476a5478532475a50b46f84801ede717ea7909903c8b267f33cf62fd1dac22d8258905e86fc764f372ce63bd7bdfcd400
7
+ data.tar.gz: d143a769fe1407606480ca83415e63c937bf7d26d3ce1cbf436eefad84542c9079b6eb8659bbb31d10fadc9baa03a38e96601e7d5e08f8e8cea9a1a0fee26ebc
data/CHANGELOG.md CHANGED
@@ -5,11 +5,46 @@ adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.8.0] - 2021-03-16
9
+ ### Fixed
10
+ - Suppress any error output from the `git rev-parse` command. ([#394](https://github.com/honeybadger-io/honeybadger-ruby/pull/394))
11
+
12
+ ### Added
13
+ - Support deployment tracking in code (#397, @danleyden)
14
+
15
+ ## [4.7.3] - 2021-02-10
16
+ ### Fixed
17
+ - Don't enable Lambda plugin in non-Lambda execution environments
18
+
19
+ ## [4.7.2] - 2020-08-17
20
+ ### Fixed
21
+ - Remove usage of `ActiveRecord::Base.connection` (thanks @jcoyne for testing)
22
+ - Check for UTF-8 in ActiveRecord breadcrumb exclusion filter
23
+
24
+ ## [4.7.1] - 2020-08-11
25
+ ### Fixed
26
+ - ActiveRecord SQL Breadcrumb event pulls adapter from supplied connection,
27
+ allowing for multiple databases.
28
+ - Fix Rails deprecation of `ActionDispatch::ParamsParser::ParseError`
29
+ - Deal with invalid UTF-8 byte sequences during SQL obfuscation
30
+ - Fix Ruby 2.7 deprecation notice in sql.rb
31
+
32
+ ## [4.7.0] - 2020-06-02
33
+ ### Fixed
34
+ - Alias `Notice#controller=` as `Notice#component=`
35
+ - Fix Rails 6.1 deprecation warning with `ActiveRecord::Base.connection_config`
36
+ - Fix agent where breadcrumbs.enabled = true and local_context = true
37
+
38
+ ### Added
39
+ - Add `honeybadger_skip_rails_load` Capistrano option to skip rails load on
40
+ deployment notification (#355) -@NielsKSchjoedt
41
+
8
42
  ## [4.6.0] - 2020-03-12
9
43
  ### Fixed
10
44
  - Fixed issue where Sidekiq.attempt_threshold was triggering 2 attempts ahead
11
45
  of the setting
12
46
  - Dup notify opts before mutating (#345)
47
+
13
48
  ### Changed
14
49
  - Breadcrumbs on by default
15
50
  - Added Faktory plugin -@scottrobertson
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
 
@@ -186,6 +190,29 @@ module Honeybadger
186
190
  response.success?
187
191
  end
188
192
 
193
+ # Track a new deployment
194
+ #
195
+ # @example
196
+ # Honeybadger.track_deployment(revision: 'be2ceb6')
197
+ #
198
+ # @param [String] :env The environment name. Defaults to the current configured environment.
199
+ # @param [String] :revision The VCS revision being deployed. Defaults to the currently configured revision.
200
+ # @param [String] :local_username The name of the user who performed the deploy.
201
+ # @param [String] :repository The base URL of the VCS repository. It should be HTTPS-style.
202
+ #
203
+ # @return [Boolean] true if the deployment was successfully tracked and false
204
+ # otherwise.
205
+ def track_deployment(env: nil, revision: nil, local_username: nil, repository: nil)
206
+ opts = {
207
+ env: env || config[:env],
208
+ revision: revision || config[:revision],
209
+ local_username: local_username,
210
+ repository: repository
211
+ }
212
+ response = backend.track_deployment(opts)
213
+ response.success?
214
+ end
215
+
189
216
  # Save global context for the current request.
190
217
  #
191
218
  # @example
@@ -99,6 +99,15 @@ module Honeybadger
99
99
  raise NotImplementedError, 'must define #check_in on subclass.'
100
100
  end
101
101
 
102
+ # Track a deployment
103
+ # @example
104
+ # backend.track_deployment({ revision: 'be2ceb6' })
105
+ #
106
+ # @param [#to_json] payload The JSON payload containing all deployment data.
107
+ def track_deployment(payload)
108
+ notify(:deploys, payload)
109
+ end
110
+
102
111
  private
103
112
 
104
113
  attr_reader :config
@@ -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',
@@ -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
@@ -37,6 +37,7 @@ module Honeybadger
37
37
  def_delegator :'Honeybadger::Agent.instance', :add_breadcrumb
38
38
  def_delegator :'Honeybadger::Agent.instance', :breadcrumbs
39
39
  def_delegator :'Honeybadger::Agent.instance', :clear!
40
+ def_delegator :'Honeybadger::Agent.instance', :track_deployment
40
41
 
41
42
  # @!macro [attach] def_delegator
42
43
  # @!method $2(...)
@@ -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
@@ -26,7 +26,7 @@ module Honeybadger
26
26
 
27
27
  def from_git
28
28
  return nil unless File.directory?('.git')
29
- `git rev-parse HEAD`.strip rescue nil
29
+ `git rev-parse HEAD 2> #{File::NULL}`.strip rescue nil
30
30
  end
31
31
  end
32
32
  end
@@ -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.6.0'.freeze
3
+ VERSION = '4.8.0'.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.6.0
4
+ version: 4.8.0
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: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email:
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.0.1
156
+ rubygems_version: 3.1.4
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Error reports you can be happy about.