honeybadger 5.16.0 → 5.26.4

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +122 -0
  3. data/lib/honeybadger/agent.rb +16 -0
  4. data/lib/honeybadger/backend/test.rb +5 -1
  5. data/lib/honeybadger/backtrace.rb +2 -1
  6. data/lib/honeybadger/breadcrumbs/active_support.rb +1 -1
  7. data/lib/honeybadger/cli/test.rb +1 -0
  8. data/lib/honeybadger/config/defaults.rb +105 -3
  9. data/lib/honeybadger/config.rb +15 -1
  10. data/lib/honeybadger/gauge.rb +1 -0
  11. data/lib/honeybadger/histogram.rb +14 -0
  12. data/lib/honeybadger/init/hanami.rb +1 -1
  13. data/lib/honeybadger/init/rails.rb +9 -4
  14. data/lib/honeybadger/init/sinatra.rb +2 -2
  15. data/lib/honeybadger/instrumentation.rb +57 -21
  16. data/lib/honeybadger/instrumentation_helper.rb +17 -11
  17. data/lib/honeybadger/karafka.rb +301 -0
  18. data/lib/honeybadger/notice.rb +14 -7
  19. data/lib/honeybadger/notification_subscriber.rb +39 -19
  20. data/lib/honeybadger/plugins/active_job.rb +1 -2
  21. data/lib/honeybadger/plugins/autotuner.rb +9 -6
  22. data/lib/honeybadger/plugins/delayed_job.rb +1 -0
  23. data/lib/honeybadger/plugins/faktory.rb +1 -0
  24. data/lib/honeybadger/plugins/karafka.rb +7 -16
  25. data/lib/honeybadger/plugins/net_http.rb +17 -3
  26. data/lib/honeybadger/plugins/rails.rb +7 -1
  27. data/lib/honeybadger/plugins/resque.rb +1 -0
  28. data/lib/honeybadger/plugins/shoryuken.rb +1 -0
  29. data/lib/honeybadger/plugins/sidekiq.rb +107 -79
  30. data/lib/honeybadger/plugins/solid_queue.rb +38 -12
  31. data/lib/honeybadger/plugins/sucker_punch.rb +1 -0
  32. data/lib/honeybadger/plugins/thor.rb +1 -0
  33. data/lib/honeybadger/registry_execution.rb +1 -0
  34. data/lib/honeybadger/version.rb +1 -1
  35. data/lib/puma/plugin/honeybadger.rb +9 -3
  36. metadata +18 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6674f1772ae54868a913de6f2acdb4286500ffc165e0d5f171b322da91776f3
4
- data.tar.gz: f22eb1fb98c3482bce89bf493dd9de0d2316e6aaf8026a57c9046728e7162c41
3
+ metadata.gz: a61036295da38a5d17bcc5061ccb9c07b106e3be1e7642d5561f8f876f9d7c7d
4
+ data.tar.gz: 8790ba8611d838ac98978976862fba259c3aa7bdeb070d7285e54d5659d456aa
5
5
  SHA512:
6
- metadata.gz: 532f696d90a9d2ffb9343b5cf5a64bf3e2a38485360198d32b6d16a297819dd80dc58bdbca81a8b00da2a7c6e9a6cb1fafe7f77ee6b4f7cec586c0e726fabed2
7
- data.tar.gz: 571036d50c716b884a2ea06cad05829ee182d6ee84a82a44b170fb030dc63d00e937afad62983d44eab64de3e2f9f94844c9c4d4aeaca9a1de6ebbec809056bb
6
+ metadata.gz: 6f8f7051e9326b04cf314ae0201606a8a558c66235066706df3c00f093318a126599eb055ed574accf9acc2048b015604e1778b19e4aacd5f0c8952264f6a207
7
+ data.tar.gz: 27251a44c22ffa1b1f7b244de298650e119dda596ebc5a9642800ac030f14232fcc938cc79386581b06c085beaa53573c28de876bd4974b8a3a6398912b8403d
data/CHANGELOG.md CHANGED
@@ -1,6 +1,128 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.26.4](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.26.3...v5.26.4) (2025-02-18)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * ignore transactions with the immediate keyword ([#668](https://github.com/honeybadger-io/honeybadger-ruby/issues/668)) ([43e9ccb](https://github.com/honeybadger-io/honeybadger-ruby/commit/43e9ccb8afb86b6be340dba064af14c5cfd4929f))
10
+
11
+ ## [5.26.3](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.26.2...v5.26.3) (2025-02-10)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * remove mail objects from ActionMailer events ([#664](https://github.com/honeybadger-io/honeybadger-ruby/issues/664)) ([07e0520](https://github.com/honeybadger-io/honeybadger-ruby/commit/07e0520ae1cd27beb16a96e075e64eb6463c97a8)), closes [#663](https://github.com/honeybadger-io/honeybadger-ruby/issues/663)
17
+
18
+ ## [5.26.2](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.26.1...v5.26.2) (2025-01-10)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * ensure instrumentation durations are unique during threaded executions ([#658](https://github.com/honeybadger-io/honeybadger-ruby/issues/658)) ([4c3f0a6](https://github.com/honeybadger-io/honeybadger-ruby/commit/4c3f0a6e69e826b6664d4385009e67fb94c5160e))
24
+
25
+ ## [5.26.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.26.0...v5.26.1) (2024-12-17)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * support Ruby 3.4 quote syntax in backtraces ([1655a04](https://github.com/honeybadger-io/honeybadger-ruby/commit/1655a041d707be1dcd8dd30314cc2383af084d8f))
31
+
32
+ ## [5.26.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.25.0...v5.26.0) (2024-11-27)
33
+
34
+
35
+ ### Features
36
+
37
+ * use after_change for context changes ([#651](https://github.com/honeybadger-io/honeybadger-ruby/issues/651)) ([2cfc766](https://github.com/honeybadger-io/honeybadger-ruby/commit/2cfc766660d0462168aded9c34712904f8a1f774))
38
+
39
+ ## [5.25.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.24.0...v5.25.0) (2024-11-26)
40
+
41
+
42
+ ### Features
43
+
44
+ * set context during rails error report ([#649](https://github.com/honeybadger-io/honeybadger-ruby/issues/649)) ([dee37e1](https://github.com/honeybadger-io/honeybadger-ruby/commit/dee37e157b0913e24a5d368e3d2cbe733f87214e))
45
+
46
+ ## [5.24.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.23.0...v5.24.0) (2024-11-21)
47
+
48
+
49
+ ### Features
50
+
51
+ * skip middleware, plugins, and exception reporting when exceptions are disabled ([#646](https://github.com/honeybadger-io/honeybadger-ruby/issues/646)) ([6c4d7d5](https://github.com/honeybadger-io/honeybadger-ruby/commit/6c4d7d53f7356717894269b5fc9095621c9e8014))
52
+
53
+ ## [5.23.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.22.0...v5.23.0) (2024-11-19)
54
+
55
+
56
+ ### Features
57
+
58
+ * update puma and autotuner plugins ([#644](https://github.com/honeybadger-io/honeybadger-ruby/issues/644)) ([1ed9687](https://github.com/honeybadger-io/honeybadger-ruby/commit/1ed96874c31c0273bc28cb917043f19140fd8204))
59
+
60
+ ## [5.22.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.21.0...v5.22.0) (2024-11-14)
61
+
62
+
63
+ ### Features
64
+
65
+ * only allow for insights to be enabled when public ([#642](https://github.com/honeybadger-io/honeybadger-ruby/issues/642)) ([2d3ab26](https://github.com/honeybadger-io/honeybadger-ruby/commit/2d3ab26ca3673b5b01082d55737bf7907c02e799))
66
+
67
+ ## [5.21.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.20.1...v5.21.0) (2024-11-14)
68
+
69
+
70
+ ### Features
71
+
72
+ * add event stats for sidekiq and sq ([#638](https://github.com/honeybadger-io/honeybadger-ruby/issues/638)) ([0d15bf5](https://github.com/honeybadger-io/honeybadger-ruby/commit/0d15bf543d4c425a2d9f6000d328dc0e71261647))
73
+ * disable all workers in rails console ([#636](https://github.com/honeybadger-io/honeybadger-ruby/issues/636)) ([d0bcb42](https://github.com/honeybadger-io/honeybadger-ruby/commit/d0bcb4278ad84d02e3706766269582067bc76e29))
74
+ * emit an event for karafka stats ([#637](https://github.com/honeybadger-io/honeybadger-ruby/issues/637)) ([e7e74b5](https://github.com/honeybadger-io/honeybadger-ruby/commit/e7e74b51324f7c718b1adc634cee4233d0c91813))
75
+
76
+ ## [5.20.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.20.0...v5.20.1) (2024-11-13)
77
+
78
+
79
+ ### Bug Fixes
80
+
81
+ * cli test for rails 8 ([#639](https://github.com/honeybadger-io/honeybadger-ruby/issues/639)) ([ec74cfd](https://github.com/honeybadger-io/honeybadger-ruby/commit/ec74cfd95519cd49509ff63fb34a7673f5c76323))
82
+
83
+ ## [5.20.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.19.2...v5.20.0) (2024-11-08)
84
+
85
+
86
+ ### Features
87
+
88
+ * 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))
89
+
90
+ ## [5.19.2](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.19.1...v5.19.2) (2024-11-05)
91
+
92
+
93
+ ### Bug Fixes
94
+
95
+ * don't run middleware in Sinatra when not configured ([#629](https://github.com/honeybadger-io/honeybadger-ruby/issues/629)) ([d84c2b1](https://github.com/honeybadger-io/honeybadger-ruby/commit/d84c2b15f61b1a019be6329981d8f5323115d1e9))
96
+ * pin rspec-its gem to 1.3.1 ([#631](https://github.com/honeybadger-io/honeybadger-ruby/issues/631)) ([5f78b8a](https://github.com/honeybadger-io/honeybadger-ruby/commit/5f78b8adfb1b86c233bf9ad3ddb69dc702341e11))
97
+
98
+ ## [5.19.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.19.0...v5.19.1) (2024-11-02)
99
+
100
+
101
+ ### Bug Fixes
102
+
103
+ * don't raise errors in instrumentation metrics ([#627](https://github.com/honeybadger-io/honeybadger-ruby/issues/627)) ([1231dae](https://github.com/honeybadger-io/honeybadger-ruby/commit/1231dae0c48a2fab4cdaa14f7308ab3e0b44c287))
104
+
105
+ ## [5.19.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.18.0...v5.19.0) (2024-10-29)
106
+
107
+
108
+ ### Features
109
+
110
+ * improved karafka plugin for insights ([#625](https://github.com/honeybadger-io/honeybadger-ruby/issues/625)) ([21880fc](https://github.com/honeybadger-io/honeybadger-ruby/commit/21880fc92493abb044ba3c0d64299ad8b92ad5f3))
111
+
112
+ ## [5.18.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.17.0...v5.18.0) (2024-10-25)
113
+
114
+
115
+ ### Features
116
+
117
+ * add a separate configuration for Insights in a console ([#623](https://github.com/honeybadger-io/honeybadger-ruby/issues/623)) ([a89488e](https://github.com/honeybadger-io/honeybadger-ruby/commit/a89488e535ff04ec2e362807f0001471ba5c6fe3))
118
+
119
+ ## [5.17.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.16.0...v5.17.0) (2024-10-22)
120
+
121
+
122
+ ### Features
123
+
124
+ * add request_id to notices ([#619](https://github.com/honeybadger-io/honeybadger-ruby/issues/619)) ([fa4d878](https://github.com/honeybadger-io/honeybadger-ruby/commit/fa4d878ad0f0a5c37e49adeab1c53e6ffa463295)), closes [#616](https://github.com/honeybadger-io/honeybadger-ruby/issues/616)
125
+
4
126
  ## [5.16.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.15.6...v5.16.0) (2024-09-19)
5
127
 
6
128
 
@@ -125,6 +125,11 @@ module Honeybadger
125
125
  # @return [String] UUID reference to the notice within Honeybadger.
126
126
  # @return [false] when ignored.
127
127
  def notify(exception_or_opts = nil, opts = {}, **kwargs)
128
+ if !config[:'exceptions.enabled']
129
+ debug { 'disabled feature=notices' }
130
+ return false
131
+ end
132
+
128
133
  opts = opts.dup
129
134
  opts.merge!(kwargs)
130
135
 
@@ -149,6 +154,7 @@ module Honeybadger
149
154
  opts[:rack_env] ||= context_manager.get_rack_env
150
155
  opts[:global_context] ||= context_manager.get_context
151
156
  opts[:breadcrumbs] ||= breadcrumbs.dup
157
+ opts[:request_id] ||= context_manager.get_request_id
152
158
 
153
159
  notice = Notice.new(config, opts)
154
160
 
@@ -376,6 +382,16 @@ module Honeybadger
376
382
  true
377
383
  end
378
384
 
385
+ # Stops the Honeybadger Insights related services.
386
+ #
387
+ # @example
388
+ # Honeybadger.stop_insights # => nil
389
+ def stop_insights(force = false)
390
+ events_worker&.shutdown(force)
391
+ metrics_worker&.shutdown(force)
392
+ true
393
+ end
394
+
379
395
  # Sends event to events backend
380
396
  #
381
397
  # @example
@@ -42,13 +42,17 @@ module Honeybadger
42
42
  self.class.check_ins
43
43
  end
44
44
 
45
+ def events
46
+ self.class.events
47
+ end
48
+
45
49
  def notify(feature, payload)
46
50
  notifications[feature] << payload
47
51
  super
48
52
  end
49
53
 
50
54
  def event(payload)
51
- events << payload
55
+ events.concat(payload.dup)
52
56
  super
53
57
  end
54
58
 
@@ -7,7 +7,8 @@ module Honeybadger
7
7
  # Handles backtrace parsing line by line.
8
8
  class Line
9
9
  # Backtrace line regexp (optionally allowing leading X: for windows support).
10
- INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
10
+ # Capture quoted strings either with leading backtick (pre Ruby 3.4) or single quote.
11
+ INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in (?:`|')([^']+)')?$}.freeze
11
12
 
12
13
  # The file portion of the line (such as app/models/user.rb).
13
14
  attr_reader :file
@@ -27,7 +27,7 @@ module Honeybadger
27
27
  exclude_when: lambda do |data|
28
28
  # Ignore schema, begin, and commit transaction queries
29
29
  data[:name] == "SCHEMA" ||
30
- (data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( transaction)?$/i))
30
+ (data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( immediate)?( transaction)?$/i))
31
31
  end
32
32
  },
33
33
 
@@ -142,6 +142,7 @@ module Honeybadger
142
142
  end
143
143
  CONTROLLER
144
144
 
145
+ ::Rails.application.try(:reload_routes_unless_loaded)
145
146
  ::Rails.application.routes.tap do |r|
146
147
  # RouteSet#disable_clear_and_finalize prevents existing routes from
147
148
  # being cleared. We'll set it back to the original value when we're
@@ -32,8 +32,10 @@ module Honeybadger
32
32
  'Sidekiq::JobRetry::Skip'].map(&:freeze).freeze
33
33
 
34
34
  IGNORE_EVENTS_DEFAULT = [
35
- { event_type: 'sql.active_record', query: /^(begin|commit)( transaction)?$/i },
35
+ { event_type: 'metric.hb', metric_name: 'duration.sql.active_record', query: /^(begin|commit)( immediate)?( transaction)?$/i },
36
+ { event_type: 'sql.active_record', query: /^(begin|commit)( immediate)?( transaction)?$/i },
36
37
  { event_type: 'sql.active_record', query: /(solid_queue|good_job)/i },
38
+ { event_type: 'sql.active_record', name: /^GoodJob/ },
37
39
  { event_type: 'process_action.action_controller', controller: 'Rails::HealthController' }
38
40
  ].freeze
39
41
 
@@ -342,6 +344,21 @@ module Honeybadger
342
344
  default: true,
343
345
  type: Boolean
344
346
  },
347
+ :'sidekiq.insights.enabled' => {
348
+ description: 'Enable automatic data collection for Sidekiq.',
349
+ default: true,
350
+ type: Boolean
351
+ },
352
+ :'sidekiq.insights.events' => {
353
+ description: 'Enable automatic event capturing for Sidekiq.',
354
+ default: true,
355
+ type: Boolean
356
+ },
357
+ :'sidekiq.insights.metrics' => {
358
+ description: 'Enable automatic metric data collection for Sidekiq.',
359
+ default: false,
360
+ type: Boolean
361
+ },
345
362
  :'sidekiq.insights.cluster_collection' => {
346
363
  description: 'Collect cluster based metrics for Sidekiq.',
347
364
  default: true,
@@ -349,9 +366,24 @@ module Honeybadger
349
366
  },
350
367
  :'sidekiq.insights.collection_interval' => {
351
368
  description: 'The frequency in which Sidekiq cluster metrics are sampled.',
352
- default: 60,
369
+ default: 5,
353
370
  type: Integer
354
371
  },
372
+ :'solid_queue.insights.enabled' => {
373
+ description: 'Enable automatic data collection for SolidQueue.',
374
+ default: true,
375
+ type: Boolean
376
+ },
377
+ :'solid_queue.insights.events' => {
378
+ description: 'Enable automatic event capturing for SolidQueue.',
379
+ default: true,
380
+ type: Boolean
381
+ },
382
+ :'solid_queue.insights.metrics' => {
383
+ description: 'Enable automatic metric data collection for SolidQueue.',
384
+ default: false,
385
+ type: Boolean
386
+ },
355
387
  :'solid_queue.insights.cluster_collection' => {
356
388
  description: 'Collect cluster based metrics for SolidQueue.',
357
389
  default: true,
@@ -359,14 +391,54 @@ module Honeybadger
359
391
  },
360
392
  :'solid_queue.insights.collection_interval' => {
361
393
  description: 'The frequency in which SolidQueue cluster metrics are sampled.',
362
- default: 60,
394
+ default: 5,
363
395
  type: Integer
364
396
  },
397
+ :'rails.insights.enabled' => {
398
+ description: 'Enable automatic data collection for Ruby on Rails.',
399
+ default: true,
400
+ type: Boolean
401
+ },
402
+ :'rails.insights.events' => {
403
+ description: 'Enable automatic event capturing for Ruby on Rails.',
404
+ default: true,
405
+ type: Boolean
406
+ },
407
+ :'rails.insights.metrics' => {
408
+ description: 'Enable automatic metric data collection for Ruby on Rails.',
409
+ default: false,
410
+ type: Boolean
411
+ },
412
+ :'karafka.insights.enabled' => {
413
+ description: 'Enable automatic data collection for Karafka.',
414
+ default: true,
415
+ type: Boolean
416
+ },
417
+ :'karafka.insights.events' => {
418
+ description: 'Enable automatic event capturing for Karafka.',
419
+ default: true,
420
+ type: Boolean
421
+ },
422
+ :'karafka.insights.metrics' => {
423
+ description: 'Enable automatic metric data collection for Karafka.',
424
+ default: false,
425
+ type: Boolean
426
+ },
365
427
  :'net_http.insights.enabled' => {
366
428
  description: 'Allow automatic instrumentation of Net::HTTP requests.',
367
429
  default: true,
368
430
  type: Boolean
369
431
  },
432
+ :'net_http.insights.events' => {
433
+ description: 'Enable automatic event capturing for Net::HTTP requests.',
434
+ default: true,
435
+ type: Boolean
436
+ },
437
+ :'net_http.insights.metrics' => {
438
+ description: 'Enable automatic metric data collection for Net::HTTP requests.',
439
+ default: false,
440
+ type: Boolean
441
+ },
370
442
  :'net_http.insights.full_url' => {
371
443
  description: 'Record the full request url during instrumentation.',
372
444
  default: false,
@@ -410,10 +482,40 @@ module Honeybadger
410
482
  default: false,
411
483
  type: Boolean
412
484
  },
485
+ :'insights.console.enabled' => {
486
+ description: "Enable/Disable Honeybadger Insights built-in instrumentation in a Rails console.",
487
+ default: false,
488
+ type: Boolean
489
+ },
413
490
  :'insights.registry_flush_interval' => {
414
491
  description: "Number of seconds between registry flushes.",
415
492
  default: 60,
416
493
  type: Integer
494
+ },
495
+ :'puma.insights.events' => {
496
+ description: 'Enable automatic event capturing for Puma stats.',
497
+ default: true,
498
+ type: Boolean
499
+ },
500
+ :'puma.insights.metrics' => {
501
+ description: 'Enable automatic metric data aggregation for Puma stats.',
502
+ default: false,
503
+ type: Boolean
504
+ },
505
+ :'puma.insights.collection_interval' => {
506
+ description: 'The frequency in which the Honeybadger gem will collect Puma stats.',
507
+ default: 1,
508
+ type: Integer
509
+ },
510
+ :'autotuner.insights.events' => {
511
+ description: 'Enable automatic event capturing for Autotuner stats.',
512
+ default: true,
513
+ type: Boolean
514
+ },
515
+ :'autotuner.insights.metrics' => {
516
+ description: 'Enable automatic metric data aggregation for Autotuner stats.',
517
+ default: false,
518
+ type: Boolean
417
519
  }
418
520
  }.freeze
419
521
 
@@ -289,7 +289,7 @@ module Honeybadger
289
289
  end
290
290
 
291
291
  def insights_enabled?
292
- !!self[:'insights.enabled']
292
+ public? && !!self[:'insights.enabled']
293
293
  end
294
294
 
295
295
  def cluster_collection?(name)
@@ -309,6 +309,20 @@ module Honeybadger
309
309
  !!self[:"#{name}.insights.enabled"]
310
310
  end
311
311
 
312
+ def load_plugin_insights_events?(name)
313
+ return false unless insights_enabled?
314
+ return false unless load_plugin_insights?(name)
315
+ return true if self[:"#{name}.insights.events"].nil?
316
+ !!self[:"#{name}.insights.events"]
317
+ end
318
+
319
+ def load_plugin_insights_metrics?(name)
320
+ return false unless insights_enabled?
321
+ return false unless load_plugin_insights?(name)
322
+ return true if self[:"#{name}.insights.metrics"].nil?
323
+ !!self[:"#{name}.insights.metrics"]
324
+ end
325
+
312
326
  def root_regexp
313
327
  return @root_regexp if @root_regexp
314
328
  return nil if @no_root
@@ -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,
@@ -9,6 +9,15 @@ module Honeybadger
9
9
  return unless value
10
10
 
11
11
  @samples += 1
12
+
13
+ @total ||= 0
14
+ @total = @total + value
15
+
16
+ @min = value if @min.nil? || @min > value
17
+ @max = value if @max.nil? || @max < value
18
+ @avg = @total.to_f / @samples
19
+ @latest = value
20
+
12
21
  @bin_counts ||= Hash.new(0)
13
22
  @bin_counts[find_bin(value)] += 1
14
23
  end
@@ -25,6 +34,11 @@ module Honeybadger
25
34
 
26
35
  def payloads
27
36
  [{
37
+ total: @total,
38
+ min: @min,
39
+ max: @max,
40
+ avg: @avg,
41
+ latest: @latest,
28
42
  bins: (bins + [INFINITY]).map { |bin| [bin.to_f, @bin_counts[bin]] }
29
43
  }]
30
44
  end
@@ -8,7 +8,7 @@ Honeybadger.init!({
8
8
 
9
9
  Honeybadger.load_plugins!
10
10
 
11
- if Hanami::VERSION >= '2.0'
11
+ if Hanami::VERSION >= '2.0' && Honeybadger.config[:'exceptions.enabled']
12
12
  Hanami.app.instance_eval do
13
13
  config.middleware.use Honeybadger::Rack::UserFeedback
14
14
  config.middleware.use Honeybadger::Rack::UserInformer
@@ -14,9 +14,11 @@ module Honeybadger
14
14
  initializer 'honeybadger.install_middleware' do |app|
15
15
  honeybadger_config = Honeybadger::Agent.instance.config
16
16
 
17
- app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
18
- app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer) if honeybadger_config[:'user_informer.enabled']
19
- app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback) if honeybadger_config[:'feedback.enabled']
17
+ if honeybadger_config[:'exceptions.enabled']
18
+ app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
19
+ app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer) if honeybadger_config[:'user_informer.enabled']
20
+ app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback) if honeybadger_config[:'feedback.enabled']
21
+ end
20
22
  end
21
23
 
22
24
  config.before_initialize do
@@ -34,7 +36,10 @@ module Honeybadger
34
36
  end
35
37
 
36
38
  console do
37
- Honeybadger::Agent.instance.config[:'insights.enabled'] = false unless Honeybadger::Agent.instance.config.env.has_key?(:'insights.enabled')
39
+ unless Honeybadger::Agent.instance.config[:'insights.enabled'] = Honeybadger::Agent.instance.config[:'insights.console.enabled']
40
+ Honeybadger::Agent.instance.config.logger.debug("Rails console detected, shutting down Honeybadger Insights workers.")
41
+ Honeybadger::Agent.instance.stop_insights
42
+ end
38
43
  end
39
44
  end
40
45
  end
@@ -31,8 +31,8 @@ module Honeybadger
31
31
  if config[:'exceptions.enabled']
32
32
  # These two must come before the ErrorNotifier, since an error/response
33
33
  # passes through middleware from inner to outer (bottom to top)
34
- install_honeybadger_middleware(Honeybadger::Rack::UserFeedback)
35
- install_honeybadger_middleware(Honeybadger::Rack::UserInformer)
34
+ install_honeybadger_middleware(Honeybadger::Rack::UserFeedback) if config[:'feedback.enabled']
35
+ install_honeybadger_middleware(Honeybadger::Rack::UserInformer) if config[:'user_informer.enabled']
36
36
  install_honeybadger_middleware(Honeybadger::Rack::ErrorNotifier)
37
37
  end
38
38
  end
@@ -47,66 +47,102 @@ module Honeybadger
47
47
  def time(name, *args)
48
48
  attributes = extract_attributes(args)
49
49
  callable = extract_callable(args)
50
- duration = attributes.delete(:duration)
50
+ value = nil
51
51
 
52
52
  if callable
53
- duration = monotonic_timer{ callable.call }[0]
53
+ value = monotonic_timer{ callable.call }[0]
54
54
  elsif block_given?
55
- duration = monotonic_timer{ yield }[0]
55
+ value = monotonic_timer{ yield }[0]
56
+ else
57
+ value = attributes.delete(:duration) || attributes.delete(:value)
56
58
  end
57
59
 
58
- raise 'No duration found' if duration.nil?
59
-
60
60
  Honeybadger::Timer.register(registry, name, attributes).tap do |timer|
61
- timer.record(duration)
61
+ if value.nil?
62
+ agent.config.logger.warn("No value found for timer #{name}. Must specify either duration or value. Skipping.")
63
+ else
64
+ timer.record(value)
65
+ end
62
66
  end
63
67
  end
64
68
 
65
69
  def histogram(name, *args)
66
70
  attributes = extract_attributes(args)
67
71
  callable = extract_callable(args)
68
- duration = attributes.delete(:duration)
72
+ value = nil
69
73
 
70
74
  if callable
71
- duration = monotonic_timer{ callable.call }[0]
75
+ value = monotonic_timer{ callable.call }[0]
72
76
  elsif block_given?
73
- duration = monotonic_timer{ yield }[0]
77
+ value = monotonic_timer{ yield }[0]
78
+ else
79
+ value = attributes.delete(:duration) || attributes.delete(:value)
74
80
  end
75
81
 
76
- raise 'No duration found' if duration.nil?
77
-
78
82
  Honeybadger::Histogram.register(registry, name, attributes).tap do |histogram|
79
- histogram.record(duration)
83
+ if value.nil?
84
+ agent.config.logger.warn("No value found for histogram #{name}. Must specify either duration or value. Skipping.")
85
+ else
86
+ histogram.record(value)
87
+ end
80
88
  end
81
89
  end
82
90
 
83
91
  def increment_counter(name, *args)
84
92
  attributes = extract_attributes(args)
85
- by = extract_callable(args)&.call || attributes.delete(:by) || 1
86
- by = yield if block_given?
93
+ callable = extract_callable(args)
94
+ value = nil
95
+
96
+ if callable
97
+ value = callable.call
98
+ elsif block_given?
99
+ value = yield
100
+ else
101
+ value = attributes.delete(:by) || attributes.delete(:value) || 1
102
+ end
87
103
 
88
104
  Honeybadger::Counter.register(registry, name, attributes).tap do |counter|
89
- counter.count(by)
105
+ counter.count(value)
90
106
  end
91
107
  end
92
108
 
93
109
  def decrement_counter(name, *args)
94
110
  attributes = extract_attributes(args)
95
- by = extract_callable(args)&.call || attributes.delete(:by) || 1
96
- by = yield if block_given?
111
+ callable = extract_callable(args)
112
+ value = nil
113
+
114
+ if callable
115
+ value = callable.call
116
+ elsif block_given?
117
+ value = yield
118
+ else
119
+ value = attributes.delete(:by) || attributes.delete(:value) || 1
120
+ end
97
121
 
98
122
  Honeybadger::Counter.register(registry, name, attributes).tap do |counter|
99
- counter.count(by * -1)
123
+ counter.count(value * -1)
100
124
  end
101
125
  end
102
126
 
103
127
  def gauge(name, *args)
104
128
  attributes = extract_attributes(args)
105
- value = extract_callable(args)&.call || attributes.delete(:value)
106
- value = yield if block_given?
129
+ callable = extract_callable(args)
130
+ value = nil
131
+
132
+ if callable
133
+ value = callable.call
134
+ elsif block_given?
135
+ value = yield
136
+ else
137
+ value = attributes.delete(:duration) || attributes.delete(:value)
138
+ end
107
139
 
108
140
  Honeybadger::Gauge.register(registry, name, attributes).tap do |gauge|
109
- gauge.record(value)
141
+ if value.nil?
142
+ agent.config.logger.warn("No value found for gauge #{name}. Must specify value. Skipping.")
143
+ else
144
+ gauge.record(value)
145
+ end
110
146
  end
111
147
  end
112
148