honeybadger 6.9.0 → 6.9.2

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: c0df809e34f5f0cbd3e4d63c411f215dc2f9418b8909a7aedb9a5fb6c454afbe
4
- data.tar.gz: e811145ad02eef49a8078d3cb827ad47cdf35693a986a55e12bf2a6108f1b052
3
+ metadata.gz: 3a87b6390eaeefa3027fa561efe5c289817d3bf7785d5e9f7ba0d56bf0937141
4
+ data.tar.gz: a191e258298fbe566e6a7914fef8647f3b3dfb3c0ab83dfa0aaa1689ba4f30d7
5
5
  SHA512:
6
- metadata.gz: e4470a6b43117aad7db8069fe87287fc8486c9b02a79ebf43184228251fb81eeb3549b7458593f0ee0ce0e9784b85790b2ad3b97bc01c0cf46d98f49bafd2699
7
- data.tar.gz: 2aefdc40100c38c1707642be6ab04d0a72248b09734ef8f681e06753f3945854fbcc07f2e89f71ee3477fca1177e273899bb470983cabeb62b080ebafd0f04be
6
+ metadata.gz: dd5b1e3392c7d74312d66bf50a9a80ae7534526a717fbc68e851283bd0ff02f2f9d578bd6730b32364d4e9ca1dd1b3031e52191aa148c1da72634733c9a3a16b
7
+ data.tar.gz: f3c484065df9a52ef468140d725681238cf8701a5bf819f80fd06e36b0f515eea94245d42ab9682c44801ede8036fe227b7b546deca7c90fb2fa7bd0cf28790e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [6.9.2](https://github.com/honeybadger-io/honeybadger-ruby/compare/v6.9.1...v6.9.2) (2026-09-15)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * truncate very large SQL queries instead of obfuscating them ([#841](https://github.com/honeybadger-io/honeybadger-ruby/issues/841)) ([c80e046](https://github.com/honeybadger-io/honeybadger-ruby/commit/c80e0468ee167496ba7f5798aca2974463cf1af2))
10
+
11
+ ## [6.9.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v6.9.0...v6.9.1) (2026-07-16)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * ignore more cache events ([#832](https://github.com/honeybadger-io/honeybadger-ruby/issues/832)) ([2cb6e02](https://github.com/honeybadger-io/honeybadger-ruby/commit/2cb6e02759b97b2ff0aa754e5eae2e737f9b5440))
17
+ * pin rdoc for jruby compatibility ([#835](https://github.com/honeybadger-io/honeybadger-ruby/issues/835)) ([98f5580](https://github.com/honeybadger-io/honeybadger-ruby/commit/98f5580827c1b1acbf2585110cd11b110fdcfd4c))
18
+ * respect logging.level with Rails logger ([#834](https://github.com/honeybadger-io/honeybadger-ruby/issues/834)) ([441ce44](https://github.com/honeybadger-io/honeybadger-ruby/commit/441ce444c65c58d95882f9cba958bcfd96fe309c)), closes [#375](https://github.com/honeybadger-io/honeybadger-ruby/issues/375)
19
+
4
20
  ## [6.9.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v6.8.0...v6.9.0) (2026-06-11)
5
21
 
6
22
 
@@ -20,14 +20,15 @@ module Honeybadger
20
20
  if data[:sql]
21
21
  connection = data.delete(:connection)
22
22
  adapter = connection&.adapter_name&.downcase || active_record_connection_db_config[:adapter]
23
- data[:sql] = Util::SQL.obfuscate(data[:sql], adapter)
23
+ data[:sql] = Util::SQL.obfuscate(data[:sql], adapter, max_length: Honeybadger.config[:"sql.max_length"])
24
24
  end
25
25
  data
26
26
  end,
27
27
  exclude_when: lambda do |data|
28
- # Ignore schema, begin, and commit transaction queries
28
+ # Ignore schema, begin, and commit transaction queries. Those
29
+ # statements are tiny, so skip the scan for large queries.
29
30
  data[:name] == "SCHEMA" ||
30
- (data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( immediate)?( transaction)?$/i))
31
+ (data[:sql] && data[:sql].bytesize <= 64 && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( immediate)?( transaction)?$/i))
31
32
  end
32
33
  },
33
34
 
@@ -34,15 +34,21 @@ module Honeybadger
34
34
 
35
35
  IGNORE_EVENTS_DEFAULT = [
36
36
  {event_type: "sql.active_record", query: /^(begin|commit)( immediate)?( transaction)?$/i},
37
- {event_type: "sql.active_record", query: /(solid_queue|good_job|solid_cable_messages)/i},
37
+ {event_type: "sql.active_record", query: /(solid_queue|solid_cache|good_job|solid_cable_messages)/i},
38
38
  {event_type: "sql.active_record", name: /^GoodJob/},
39
39
  {event_type: "process_action.action_controller", controller: "Rails::HealthController"},
40
40
  {event_type: "cache_read.active_support"},
41
+ {event_type: "cache_read_multi.active_support"},
41
42
  {event_type: "cache_fetch_hit.active_support"},
42
43
  {event_type: "cache_exist?.active_support"},
43
44
  {event_type: "cache_write.active_support"},
45
+ {event_type: "cache_write_multi.active_support"},
44
46
  {event_type: "cache_generate.active_support"},
45
47
  {event_type: "cache_delete.active_support"},
48
+ {event_type: "cache_delete_multi.active_support"},
49
+ {event_type: "cache_delete_matched.active_support"},
50
+ {event_type: "cache_cleanup.active_support"},
51
+ {event_type: "cache_prune.active_support"},
46
52
  {event_type: "cache_increment.active_support"},
47
53
  {event_type: "cache_decrement.active_support"}
48
54
  ].freeze
@@ -147,6 +153,11 @@ module Honeybadger
147
153
  default: 100,
148
154
  type: Integer
149
155
  },
156
+ "sql.max_length": {
157
+ description: "SQL queries larger than this many bytes are truncated instead of obfuscated (in Insights events and breadcrumbs). Scanning very large queries is slow and can exceed Regexp.timeout.",
158
+ default: 1_000_000,
159
+ type: Integer
160
+ },
150
161
  plugins: {
151
162
  description: "An optional list of plugins to load. Default is to load all plugins.",
152
163
  default: nil,
@@ -124,12 +124,14 @@ module Honeybadger
124
124
 
125
125
  def initialize(config, logger = Logger.new(nil))
126
126
  @config = config
127
+ @log_level = @config.log_level
127
128
  @tty = $stdout.tty?
128
129
  @tty_level = @config.log_level(:"logging.tty_level")
129
130
  super(logger)
130
131
  end
131
132
 
132
133
  def add(severity, msg)
134
+ return true if suppress_log_level?(severity)
133
135
  return true if suppress_tty?(severity)
134
136
 
135
137
  # There is no debug level in Honeybadger. Debug logs will be logged at
@@ -148,6 +150,11 @@ module Honeybadger
148
150
 
149
151
  private
150
152
 
153
+ def suppress_log_level?(severity)
154
+ effective_severity = (severity == Logger::Severity::DEBUG) ? Logger::Severity::INFO : severity
155
+ effective_severity < @log_level
156
+ end
157
+
151
158
  def suppress_debug?
152
159
  !debug?
153
160
  end
@@ -20,6 +20,9 @@ module Honeybadger
20
20
 
21
21
  record(name, payload)
22
22
  record_metrics(name, payload)
23
+ rescue => e
24
+ # Instrumentation must never break the instrumented code.
25
+ Honeybadger.config.logger.error("Error in Honeybadger instrumentation for #{name}: #{e.class}: #{e.message}")
23
26
  end
24
27
 
25
28
  def record(name, payload)
@@ -116,7 +119,7 @@ module Honeybadger
116
119
  class ActiveRecordSubscriber < RailsSubscriber
117
120
  def format_payload(_name, payload)
118
121
  {
119
- query: Util::SQL.obfuscate(payload[:sql], payload[:connection]&.adapter_name),
122
+ query: Util::SQL.obfuscate(payload[:sql], payload[:connection]&.adapter_name, max_length: Honeybadger.config[:"sql.max_length"]),
120
123
  cached: payload[:cached],
121
124
  async: payload[:async]
122
125
  }
@@ -100,6 +100,9 @@ module Honeybadger
100
100
  category: notification_config[:category] || :custom,
101
101
  metadata: data
102
102
  )
103
+ rescue => e
104
+ # Instrumentation must never break the instrumented code.
105
+ Honeybadger.config.logger.error("Error in Honeybadger breadcrumb for #{name}: #{e.class}: #{e.message}")
103
106
  end
104
107
 
105
108
  # @api private
@@ -4,20 +4,48 @@ module Honeybadger
4
4
  ESCAPE_QUOTES = /(\\"|\\')/
5
5
  SQUOTE_DATA = /'(?:[^']|'')*'/
6
6
  DQUOTE_DATA = /"(?:[^"]|"")*"/
7
- NUMBER_DATA = /\b\d+\b/
7
+ # Underscore separators are allowed in numeric literals by PostgreSQL
8
+ # 16+ and SQLite 3.46+, and \b does not match next to one.
9
+ NUMBER_DATA = /\b\d+(?:_\d+)*\b/
10
+ HEX_DATA = /\b0[xbo][0-9a-f]+(?:_[0-9a-f]+)*\b/i
8
11
  DOUBLE_QUOTERS = /(postgres|sqlite|postgis)/i
12
+ TRUNCATED_HEAD_LENGTH = 200
13
+ # Leading run of characters that can't start a string literal or a
14
+ # comment in any supported adapter: stops at ', $, /, -, #, \ and so
15
+ # on. Double quotes and backticks are kept because they quote
16
+ # identifiers; adapters that use double quotes for strings are cut
17
+ # at the first double quote in .truncate.
18
+ TRUNCATED_HEAD_SAFE = /\A[\w\s.,()=*"`]*/
9
19
 
10
- def self.obfuscate(sql, adapter)
11
- force_utf_8(sql.to_s.dup).tap do |s|
20
+ # Obfuscates literal values in a SQL query. When +max_length+ is given
21
+ # and the query is larger than that many bytes, the query is truncated
22
+ # instead (see .truncate): scanning multi-megabyte queries (e.g. an
23
+ # INSERT of a serialized cache value) is slow, and can exceed the
24
+ # Regexp.timeout that Rails 8.1+ sets by default.
25
+ def self.obfuscate(sql, adapter, max_length: nil)
26
+ sql = sql.to_s
27
+ return truncate(sql, adapter, max_length) if max_length && sql.bytesize > max_length
28
+
29
+ force_utf_8(sql.dup).tap do |s|
12
30
  s.gsub!(/\s+/, " ")
13
31
  s.gsub!(ESCAPE_QUOTES, "".freeze)
14
32
  s.gsub!(SQUOTE_DATA, "'?'".freeze)
15
33
  s.gsub!(DQUOTE_DATA, '"?"'.freeze) unless adapter.to_s.match?(DOUBLE_QUOTERS)
34
+ s.gsub!(HEX_DATA, "?".freeze)
16
35
  s.gsub!(NUMBER_DATA, "?".freeze)
17
36
  s.strip!
18
37
  end
19
38
  end
20
39
 
40
+ # Keeps only the head of the statement (up to the first quoted value or
41
+ # comment) so that no literal data leaks, and notes the original size.
42
+ def self.truncate(sql, adapter, max_length)
43
+ head = force_utf_8(sql.byteslice(0, TRUNCATED_HEAD_LENGTH)).scrub("")[TRUNCATED_HEAD_SAFE]
44
+ head = head[0, head.index('"')] if head.include?('"') && !adapter.to_s.match?(DOUBLE_QUOTERS)
45
+
46
+ "#{obfuscate(head, adapter)} ... [truncated #{sql.bytesize} bytes]"
47
+ end
48
+
21
49
  def self.force_utf_8(string)
22
50
  string.encode(
23
51
  Encoding.find("UTF-8"),
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = "6.9.0".freeze
3
+ VERSION = "6.9.2".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.9.0
4
+ version: 6.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  - !ruby/object:Gem::Version
218
218
  version: "0"
219
219
  requirements: []
220
- rubygems_version: 4.1.0.dev
220
+ rubygems_version: 4.1.0.beta1
221
221
  specification_version: 4
222
222
  summary: "Full-stack error tracking, performance monitoring, logging, and more."
223
223
  test_files: []