honeybadger 5.13.0 → 5.13.2

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: 02da7e28bdfb138d80a3e8e3e591d45383406fac1676ed04f0df139125e56247
4
- data.tar.gz: 2c08c2e0e4e42ea9b7532c09f28f8d1c60a4944dab1e0d1ebc277becb58f8947
3
+ metadata.gz: de851e791df98653d1e5af860eba6f9dec3cc39666cff9e6e8bfc04dcfd81e5d
4
+ data.tar.gz: 618b8fd621606d0e8db648807e308a67b9c0212a0dea0e66c4bd54cf9e671cf6
5
5
  SHA512:
6
- metadata.gz: cd07b8f3bfe423336690f00dc80addfb4fbda2db27bbcca0739204888b1565455ea09cbb6d5e643162f00c247ce09ff867e3eab0d71d7f59ca8d39bfc26164cd
7
- data.tar.gz: 93e0ad66065c9be2c216e69a0d631effe6ba795ff90f328bf05a24bd2d45b60369e1cf3df4b0fc15478c7a73ec497a8661265bdb3daf52b39668117a7b123c9b
6
+ metadata.gz: a5b1db0b353ff7000b6b32c7664e69003a9bb69a75282392f639df5b8b352c65b7f4bd3a4736fbfd96a44d3d0070dc9c1ef348d98878cb93f22f7cb73b856a5a
7
+ data.tar.gz: 8aea0c27bd056a5cfc41114ee0a160e00c30aa8752fcec84b215706a23b6329a6f1648106176f9ca8f484e7518716c4348e9aaf1989ee70dcbfe9de415f32e1e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.13.2](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.13.1...v5.13.2) (2024-07-03)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * buffer more and warn less ([#575](https://github.com/honeybadger-io/honeybadger-ruby/issues/575)) ([8e99e17](https://github.com/honeybadger-io/honeybadger-ruby/commit/8e99e17af65e8d0002e5e8204d5ded1cea891e86))
10
+
11
+ ## [5.13.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.13.0...v5.13.1) (2024-07-01)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * do not check for rails console ([#574](https://github.com/honeybadger-io/honeybadger-ruby/issues/574)) ([ba74af8](https://github.com/honeybadger-io/honeybadger-ruby/commit/ba74af8b55393ea0a96962085ea48c4376380be3))
17
+ * ignore content-less SQL statements ([#572](https://github.com/honeybadger-io/honeybadger-ruby/issues/572)) ([e7ecd36](https://github.com/honeybadger-io/honeybadger-ruby/commit/e7ecd36969922496e276a246406fe7d792de00e3))
18
+ * sanitize SQL when reporting SQL queries ([#571](https://github.com/honeybadger-io/honeybadger-ruby/issues/571)) ([40d4a79](https://github.com/honeybadger-io/honeybadger-ruby/commit/40d4a79a5c1f758fe49779e63697d56599537235))
19
+
4
20
  ## [5.13.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.12.0...v5.13.0) (2024-06-18)
5
21
 
6
22
 
@@ -93,7 +93,7 @@ module Honeybadger
93
93
  },
94
94
  :'events.max_queue_size' => {
95
95
  description: 'Maximum number of event for the event worker queue.',
96
- default: 10000,
96
+ default: 100000,
97
97
  type: Integer
98
98
  },
99
99
  :'events.batch_size' => {
@@ -277,7 +277,6 @@ module Honeybadger
277
277
  end
278
278
 
279
279
  def insights_enabled?
280
- return false if defined?(::Rails.application) && ::Rails.const_defined?("Console")
281
280
  !!self[:'insights.enabled']
282
281
  end
283
282
 
@@ -39,13 +39,14 @@ module Honeybadger
39
39
  @pid = Process.pid
40
40
  @send_queue = []
41
41
  @last_sent = nil
42
+ @dropped_events = 0
42
43
  end
43
44
 
44
45
  def push(msg)
45
46
  return false unless start
46
47
 
47
48
  if queue.size >= config.events_max_queue_size
48
- warn { sprintf('Unable to send event; reached max queue size of %s.', queue.size) }
49
+ @dropped_events += 1
49
50
  return false
50
51
  end
51
52
 
@@ -207,7 +208,12 @@ module Honeybadger
207
208
  send_now(mutex.synchronize { send_queue })
208
209
  mutex.synchronize do
209
210
  @last_sent = Time.now
211
+ debug { sprintf('Sending %s events', send_queue.length) }
210
212
  send_queue.clear
213
+ if @dropped_events > 0
214
+ warn { sprintf('Dropped %s messages due to exceeding max queue size of %s', @dropped_events, config.events_max_queue_size) }
215
+ end
216
+ @dropped_events = 0
211
217
  end
212
218
  end
213
219
 
@@ -1,4 +1,5 @@
1
1
  require 'honeybadger/instrumentation_helper'
2
+ require 'honeybadger/util/sql'
2
3
 
3
4
  module Honeybadger
4
5
  class NotificationSubscriber
@@ -9,7 +10,7 @@ module Honeybadger
9
10
  def finish(name, id, payload)
10
11
  @finish_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
11
12
 
12
- return unless process?(name)
13
+ return unless process?(name, payload)
13
14
 
14
15
  payload = {
15
16
  instrumenter_id: id,
@@ -23,7 +24,7 @@ module Honeybadger
23
24
  Honeybadger.event(name, payload)
24
25
  end
25
26
 
26
- def process?(event)
27
+ def process?(event, payload)
27
28
  true
28
29
  end
29
30
 
@@ -58,10 +59,16 @@ module Honeybadger
58
59
  class ActiveRecordSubscriber < NotificationSubscriber
59
60
  def format_payload(payload)
60
61
  {
61
- query: payload[:sql].to_s.gsub(/\s+/, ' ').strip,
62
+ query: Util::SQL.obfuscate(payload[:sql], payload[:connection].adapter_name),
62
63
  async: payload[:async]
63
64
  }
64
65
  end
66
+
67
+ def process?(event, payload)
68
+ return false if payload[:name] == "SCHEMA"
69
+ return false if payload[:sql]&.match?(/^(begin|commit)( transaction)?$/i)
70
+ true
71
+ end
65
72
  end
66
73
 
67
74
  class ActiveJobSubscriber < NotificationSubscriber
@@ -71,16 +71,18 @@ module Honeybadger
71
71
  end
72
72
 
73
73
  Plugin.register :rails do
74
- requirement { config.load_plugin_insights?(:rails_metrics) && defined?(::Rails.application) && ::Rails.application }
74
+ requirement { defined?(::Rails.application) && ::Rails.application }
75
75
 
76
76
  execution do
77
- ::ActiveSupport::Notifications.subscribe(/(process_action|send_file|redirect_to|halted_callback|unpermitted_parameters)\.action_controller/, Honeybadger::ActionControllerSubscriber.new)
78
- ::ActiveSupport::Notifications.subscribe(/(write_fragment|read_fragment|expire_fragment|exist_fragment\?)\.action_controller/, Honeybadger::ActionControllerCacheSubscriber.new)
79
- ::ActiveSupport::Notifications.subscribe(/cache_(read|read_multi|generate|fetch_hit|write|write_multi|increment|decrement|delete|delete_multi|cleanup|prune|exist\?)\.active_support/, Honeybadger::ActiveSupportCacheSubscriber.new)
80
- ::ActiveSupport::Notifications.subscribe(/^render_(template|partial|collection)\.action_view/, Honeybadger::ActionViewSubscriber.new)
81
- ::ActiveSupport::Notifications.subscribe("sql.active_record", Honeybadger::ActiveRecordSubscriber.new)
82
- ::ActiveSupport::Notifications.subscribe("process.action_mailer", Honeybadger::ActionMailerSubscriber.new)
83
- ::ActiveSupport::Notifications.subscribe(/(service_upload|service_download)\.active_storage/, Honeybadger::ActiveStorageSubscriber.new)
77
+ if config.load_plugin_insights?(:rails)
78
+ ::ActiveSupport::Notifications.subscribe(/(process_action|send_file|redirect_to|halted_callback|unpermitted_parameters)\.action_controller/, Honeybadger::ActionControllerSubscriber.new)
79
+ ::ActiveSupport::Notifications.subscribe(/(write_fragment|read_fragment|expire_fragment|exist_fragment\?)\.action_controller/, Honeybadger::ActionControllerCacheSubscriber.new)
80
+ ::ActiveSupport::Notifications.subscribe(/cache_(read|read_multi|generate|fetch_hit|write|write_multi|increment|decrement|delete|delete_multi|cleanup|prune|exist\?)\.active_support/, Honeybadger::ActiveSupportCacheSubscriber.new)
81
+ ::ActiveSupport::Notifications.subscribe(/^render_(template|partial|collection)\.action_view/, Honeybadger::ActionViewSubscriber.new)
82
+ ::ActiveSupport::Notifications.subscribe("sql.active_record", Honeybadger::ActiveRecordSubscriber.new)
83
+ ::ActiveSupport::Notifications.subscribe("process.action_mailer", Honeybadger::ActionMailerSubscriber.new)
84
+ ::ActiveSupport::Notifications.subscribe(/(service_upload|service_download)\.active_storage/, Honeybadger::ActiveStorageSubscriber.new)
85
+ end
84
86
  end
85
87
  end
86
88
  end
@@ -1,32 +1,29 @@
1
1
  module Honeybadger
2
2
  module Util
3
3
  class SQL
4
- EscapedQuotes = /(\\"|\\')/.freeze
5
- SQuotedData = /'(?:[^']|'')*'/.freeze
6
- DQuotedData = /"(?:[^"]|"")*"/.freeze
7
- NumericData = /\b\d+\b/.freeze
8
- Newline = /\n/.freeze
9
- Replacement = "?".freeze
10
- EmptyReplacement = "".freeze
11
- DoubleQuoters = /(postgres|sqlite|postgis)/.freeze
4
+ ESCAPE_QUOTES = /(\\"|\\')/
5
+ SQUOTE_DATA = /'(?:[^']|'')*'/
6
+ DQUOTE_DATA = /"(?:[^"]|"")*"/
7
+ NUMBER_DATA = /\b\d+\b/
8
+ DOUBLE_QUOTERS = /(postgres|sqlite|postgis)/i
12
9
 
13
10
  def self.obfuscate(sql, adapter)
14
- force_utf_8(sql.dup).tap do |s|
15
- s.gsub!(EscapedQuotes, EmptyReplacement)
16
- s.gsub!(SQuotedData, Replacement)
17
- s.gsub!(DQuotedData, Replacement) if adapter =~ DoubleQuoters
18
- s.gsub!(NumericData, Replacement)
19
- s.gsub!(Newline, EmptyReplacement)
20
- s.squeeze!(' ')
11
+ force_utf_8(sql.to_s.dup).tap do |s|
12
+ s.gsub!(/\s+/, " ")
13
+ s.gsub!(ESCAPE_QUOTES, "".freeze)
14
+ s.gsub!(SQUOTE_DATA, "'?'".freeze)
15
+ s.gsub!(DQUOTE_DATA, '"?"'.freeze) unless adapter.to_s.match?(DOUBLE_QUOTERS)
16
+ s.gsub!(NUMBER_DATA, "?".freeze)
17
+ s.strip!
21
18
  end
22
19
  end
23
20
 
24
21
  def self.force_utf_8(string)
25
22
  string.encode(
26
- Encoding.find('UTF-8'),
27
- invalid: :replace,
28
- undef: :replace,
29
- replace: ''
23
+ Encoding.find("UTF-8"),
24
+ invalid: :replace,
25
+ undef: :replace,
26
+ replace: ""
30
27
  )
31
28
  end
32
29
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.13.0'.freeze
3
+ VERSION = '5.13.2'.freeze
4
4
  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.13.0
4
+ version: 5.13.2
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: 2024-06-18 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email: