honeybadger 5.19.2 → 5.20.0

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: 20909b3d33ea742bea8ebf66e119cd76e1db5bd57d1fe0a83ea15a997ff5c23c
4
- data.tar.gz: acc73eea6c152b3a4f0bda2667ab29975ca8b95cb91109d26c85795b5a9ea6a7
3
+ metadata.gz: 49d9b04a56a6e16762784db9423b067fc80efe777f9ca3de3af933489aa97a4d
4
+ data.tar.gz: 071ef334c1a1ae28539dd67acf6f3c096fc890b7ee42a8e835653a21d4909b55
5
5
  SHA512:
6
- metadata.gz: c5ac6182c0b8ef252f81ddb54ef89dc2c6cd65313601acfd404fcf60832efcc67115964395573642149c4bac08940ce4258014be032df559125ce779d487d622
7
- data.tar.gz: 5494eba2f9590c809cf3263b5c373ac9f0bcd97dfb34ac1e602979e7412632758f4f1b4ce359e382b31d1ee3921357ae7390f88a9fdb9b81dbfeaff01de56708
6
+ metadata.gz: 5436c222a36b4697c51475e06d5275086a7339c53be1843ce6db6d3b218250edc0254745a2dc05de24965b5e9db66114c07e55b0daa870319255b2689b12b087
7
+ data.tar.gz: ca87e31006c7804b84ced1a675c3c60f79b7e55180480fd599b3a5823d00a1106f5cd251016556fd62a7093ac1e5d8b9ba980209a84d0d5309535ba7c3cb9f84
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.20.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.19.2...v5.20.0) (2024-11-08)
5
+
6
+
7
+ ### Features
8
+
9
+ * add aggregated metrics for rails and more ([#630](https://github.com/honeybadger-io/honeybadger-ruby/issues/630)) ([12db5a4](https://github.com/honeybadger-io/honeybadger-ruby/commit/12db5a4d44a9597c0999d32a150283799d856d66))
10
+
4
11
  ## [5.19.2](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.19.1...v5.19.2) (2024-11-05)
5
12
 
6
13
 
@@ -32,6 +32,7 @@ module Honeybadger
32
32
  'Sidekiq::JobRetry::Skip'].map(&:freeze).freeze
33
33
 
34
34
  IGNORE_EVENTS_DEFAULT = [
35
+ { event_type: 'metric.hb', metric_name: 'duration.sql.active_record', query: /^(begin|commit)( transaction)?$/i },
35
36
  { event_type: 'sql.active_record', query: /^(begin|commit)( transaction)?$/i },
36
37
  { event_type: 'sql.active_record', query: /(solid_queue|good_job)/i },
37
38
  { event_type: 'sql.active_record', name: /^GoodJob/ },
@@ -363,6 +364,36 @@ module Honeybadger
363
364
  default: 60,
364
365
  type: Integer
365
366
  },
367
+ :'sidekiq.insights.enabled' => {
368
+ description: 'Enable automatic data collection for Sidekiq.',
369
+ default: true,
370
+ type: Boolean
371
+ },
372
+ :'sidekiq.insights.events' => {
373
+ description: 'Enable automatic event capturing for Sidekiq.',
374
+ default: true,
375
+ type: Boolean
376
+ },
377
+ :'sidekiq.insights.metrics' => {
378
+ description: 'Enable automatic metric data collection for Sidekiq.',
379
+ default: false,
380
+ type: Boolean
381
+ },
382
+ :'rails.insights.enabled' => {
383
+ description: 'Enable automatic data collection for Ruby on Rails.',
384
+ default: true,
385
+ type: Boolean
386
+ },
387
+ :'rails.insights.events' => {
388
+ description: 'Enable automatic event capturing for Ruby on Rails.',
389
+ default: true,
390
+ type: Boolean
391
+ },
392
+ :'rails.insights.metrics' => {
393
+ description: 'Enable automatic metric data collection for Ruby on Rails.',
394
+ default: false,
395
+ type: Boolean
396
+ },
366
397
  :'karafka.insights.enabled' => {
367
398
  description: 'Enable automatic data collection for Karafka.',
368
399
  default: true,
@@ -375,7 +406,7 @@ module Honeybadger
375
406
  },
376
407
  :'karafka.insights.metrics' => {
377
408
  description: 'Enable automatic metric data collection for Karafka.',
378
- default: true,
409
+ default: false,
379
410
  type: Boolean
380
411
  },
381
412
  :'net_http.insights.enabled' => {
@@ -383,6 +414,16 @@ module Honeybadger
383
414
  default: true,
384
415
  type: Boolean
385
416
  },
417
+ :'net_http.insights.events' => {
418
+ description: 'Enable automatic event capturing for Net::HTTP requests.',
419
+ default: true,
420
+ type: Boolean
421
+ },
422
+ :'net_http.insights.metrics' => {
423
+ description: 'Enable automatic metric data collection for Net::HTTP requests.',
424
+ default: false,
425
+ type: Boolean
426
+ },
386
427
  :'net_http.insights.full_url' => {
387
428
  description: 'Record the full request url during instrumentation.',
388
429
  default: false,
@@ -19,6 +19,7 @@ module Honeybadger
19
19
  def payloads
20
20
  [
21
21
  {
22
+ total: @total,
22
23
  min: @min,
23
24
  max: @max,
24
25
  avg: @avg,
@@ -34,6 +34,7 @@ module Honeybadger
34
34
 
35
35
  def payloads
36
36
  [{
37
+ total: @total,
37
38
  min: @min,
38
39
  max: @max,
39
40
  avg: @avg,
@@ -134,7 +134,7 @@ module Honeybadger
134
134
  elsif block_given?
135
135
  value = yield
136
136
  else
137
- value = attributes.delete(:value)
137
+ value = attributes.delete(:duration) || attributes.delete(:value)
138
138
  end
139
139
 
140
140
  Honeybadger::Gauge.register(registry, name, attributes).tap do |gauge|
@@ -3,6 +3,8 @@ require 'honeybadger/util/sql'
3
3
 
4
4
  module Honeybadger
5
5
  class NotificationSubscriber
6
+ include Honeybadger::InstrumentationHelper
7
+
6
8
  def start(name, id, payload)
7
9
  @start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
8
10
  end
@@ -21,7 +23,29 @@ module Honeybadger
21
23
  end
22
24
 
23
25
  def record(name, payload)
24
- Honeybadger.event(name, payload)
26
+ if Honeybadger.config.load_plugin_insights_events?(:rails)
27
+ Honeybadger.event(name, payload)
28
+ end
29
+
30
+ if Honeybadger.config.load_plugin_insights_metrics?(:rails)
31
+ metric_source 'rails'
32
+ record_metrics(name, payload)
33
+ end
34
+ end
35
+
36
+ def record_metrics(name, payload)
37
+ case name
38
+ when 'sql.active_record'
39
+ gauge('duration.sql.active_record', value: payload[:duration], **payload.slice(:query))
40
+ when 'process_action.action_controller'
41
+ gauge('duration.process_action.action_controller', value: payload[:duration], **payload.slice(:method, :controller, :action, :format, :status))
42
+ gauge('db_runtime.process_action.action_controller', value: payload[:db_runtime], **payload.slice(:method, :controller, :action, :format, :status))
43
+ gauge('view_runtime.process_action.action_controller', value: payload[:view_runtime], **payload.slice(:method, :controller, :action, :format, :status))
44
+ when 'perform.active_job'
45
+ gauge('duration.perform.active_job', value: payload[:duration], **payload.slice(:job_class, :queue_name))
46
+ when /^cache_.*.active_support$/
47
+ gauge("duration.#{name}", value: payload[:duration], **payload.slice(:store, :key))
48
+ end
25
49
  end
26
50
 
27
51
  def process?(event, payload)
@@ -109,22 +133,6 @@ module Honeybadger
109
133
  end
110
134
  end
111
135
 
112
- class ActiveJobMetricsSubscriber < NotificationSubscriber
113
- include Honeybadger::InstrumentationHelper
114
-
115
- def format_payload(payload)
116
- {
117
- job_class: payload[:job].class.to_s,
118
- queue_name: payload[:job].queue_name
119
- }
120
- end
121
-
122
- def record(name, payload)
123
- metric_source 'active_job'
124
- histogram name, { bins: [30, 60, 120, 300, 1800, 3600, 21_600] }.merge(payload)
125
- end
126
- end
127
-
128
136
  class ActionMailerSubscriber < NotificationSubscriber
129
137
  end
130
138
 
@@ -55,7 +55,6 @@ module Honeybadger
55
55
 
56
56
  if config.load_plugin_insights?(:active_job)
57
57
  ::ActiveSupport::Notifications.subscribe(/(enqueue_at|enqueue|enqueue_retry|enqueue_all|perform|retry_stopped|discard)\.active_job/, Honeybadger::ActiveJobSubscriber.new)
58
- ::ActiveSupport::Notifications.subscribe('perform.active_job', Honeybadger::ActiveJobMetricsSubscriber.new)
59
58
  end
60
59
  end
61
60
  end
@@ -7,6 +7,12 @@ module Honeybadger
7
7
  module Plugins
8
8
  module Net
9
9
  module HTTP
10
+ @@hb_config = ::Honeybadger.config
11
+
12
+ def self.set_hb_config(config)
13
+ @@hb_config = config
14
+ end
15
+
10
16
  def request(request_data, body = nil, &block)
11
17
  return super unless started?
12
18
  return super if hb?
@@ -18,19 +24,26 @@ module Honeybadger
18
24
  status: response_data.code.to_i
19
25
  }.merge(parsed_uri_data(request_data))
20
26
 
21
- Honeybadger.event('request.net_http', context)
27
+ if @@hb_config.load_plugin_insights_events?(:net_http)
28
+ Honeybadger.event('request.net_http', context)
29
+ end
30
+
31
+ if @@hb_config.load_plugin_insights_metrics?(:net_http)
32
+ context.delete(:url)
33
+ Honeybadger.gauge('duration.request', context.merge(metric_source: 'net_http'))
34
+ end
22
35
  end[1] # return the response data only
23
36
  end
24
37
 
25
38
  def hb?
26
- address.to_s[/#{Honeybadger.config[:'connection.host'].to_s}/]
39
+ address.to_s[/#{@@hb_config[:'connection.host'].to_s}/]
27
40
  end
28
41
 
29
42
  def parsed_uri_data(request_data)
30
43
  uri = request_data.uri || build_uri(request_data)
31
44
  {}.tap do |uri_data|
32
45
  uri_data[:host] = uri.host
33
- uri_data[:url] = uri.to_s if Honeybadger.config[:'net_http.insights.full_url']
46
+ uri_data[:url] = uri.to_s if @@hb_config[:'net_http.insights.full_url']
34
47
  end
35
48
  end
36
49
 
@@ -43,6 +56,7 @@ module Honeybadger
43
56
  requirement { config.load_plugin_insights?(:net_http) }
44
57
 
45
58
  execution do
59
+ Honeybadger::Plugins::Net::HTTP.set_hb_config(config)
46
60
  ::Net::HTTP.send(:prepend, Honeybadger::Plugins::Net::HTTP)
47
61
  end
48
62
  end
@@ -38,10 +38,14 @@ module Honeybadger
38
38
  raise
39
39
  ensure
40
40
  context.merge!(duration: duration, status: status)
41
- Honeybadger.event('perform.sidekiq', context)
41
+ if Honeybadger.config.load_plugin_insights_events?(:sidekiq)
42
+ Honeybadger.event('perform.sidekiq', context)
43
+ end
42
44
 
43
- metric_source 'sidekiq'
44
- histogram 'perform', { bins: [30, 60, 120, 300, 1800, 3600, 21_600] }.merge(context.slice(:worker, :queue, :duration))
45
+ if Honeybadger.config.load_plugin_insights_metrics?(:sidekiq)
46
+ metric_source 'sidekiq'
47
+ gauge 'perform', context.slice(:worker, :queue, :duration)
48
+ end
45
49
  end
46
50
  end
47
51
  end
@@ -55,7 +59,9 @@ module Honeybadger
55
59
  queue: queue
56
60
  }
57
61
 
58
- Honeybadger.event('enqueue.sidekiq', context)
62
+ if Honeybadger.config.load_plugin_insights_events?(:sidekiq)
63
+ Honeybadger.event('enqueue.sidekiq', context)
64
+ end
59
65
 
60
66
  yield
61
67
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.19.2'.freeze
3
+ VERSION = '5.20.0'.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.19.2
4
+ version: 5.20.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: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
- rubygems_version: 3.5.16
197
+ rubygems_version: 3.5.22
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: Error reports you can be happy about.