honeybadger 5.28.0 → 5.29.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/honeybadger/agent.rb +49 -0
- data/lib/honeybadger/config/defaults.rb +5 -0
- data/lib/honeybadger/config.rb +12 -1
- data/lib/honeybadger/context_manager.rb +48 -0
- data/lib/honeybadger/plugins/solid_queue.rb +3 -2
- data/lib/honeybadger/singleton.rb +2 -0
- data/lib/honeybadger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60e0469389628b0aac4876a067dcdd195b7ac92e46545c1efe4abaf60b85bfeb
|
4
|
+
data.tar.gz: 6829c83ceab8d7e1e731beeca047d427eff33713968b3dc71643562a66a05e36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aaa649a67f0757ddc75a8f951b3c44e2d03e4b55725fdd858f90108f01e1036a3f6b1f19c167194e871e37d62bc6081c24d93200f65a321a6fc918dd37aaa84
|
7
|
+
data.tar.gz: 29569d4d2a230d9b1c83bfac13d1b945cd36092a9b5b45fdcbcec85d2d03308af436864f745c9d6383fb8ed30c432b334c4c4d33520c955cfbaed4b2e9ed24e0
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
3
|
|
4
|
+
## [5.29.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.28.0...v5.29.0) (2025-06-27)
|
5
|
+
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* add event context ([#700](https://github.com/honeybadger-io/honeybadger-ruby/issues/700)) ([36abc18](https://github.com/honeybadger-io/honeybadger-ruby/commit/36abc1826a62954b83b11b10d7e91d41f3052524))
|
10
|
+
* exclude insights from rake tasks config ([#697](https://github.com/honeybadger-io/honeybadger-ruby/issues/697)) ([118034c](https://github.com/honeybadger-io/honeybadger-ruby/commit/118034c8395dd79fada9979f9f519ded8e81234a))
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* avoid database connections during asset precompilation ([#695](https://github.com/honeybadger-io/honeybadger-ruby/issues/695)) ([14ae485](https://github.com/honeybadger-io/honeybadger-ruby/commit/14ae4858da865cb6f95d16e1a12faf3ecc2caedd))
|
16
|
+
|
4
17
|
## [5.28.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.27.4...v5.28.0) (2025-05-02)
|
5
18
|
|
6
19
|
|
data/lib/honeybadger/agent.rb
CHANGED
@@ -413,6 +413,7 @@ module Honeybadger
|
|
413
413
|
extra_payload = {}.tap do |p|
|
414
414
|
p[:request_id] = context_manager.get_request_id if context_manager.get_request_id
|
415
415
|
p[:hostname] = config[:hostname].to_s if config[:'events.attach_hostname']
|
416
|
+
p.update(context_manager.get_event_context || {})
|
416
417
|
end
|
417
418
|
|
418
419
|
event = Event.new(event_type, extra_payload.merge(payload))
|
@@ -442,6 +443,54 @@ module Honeybadger
|
|
442
443
|
events_worker.push(event.as_json)
|
443
444
|
end
|
444
445
|
|
446
|
+
# Save event-specific context for the current request.
|
447
|
+
#
|
448
|
+
# @example
|
449
|
+
# Honeybadger.event_context({user_id: current_user.id})
|
450
|
+
#
|
451
|
+
# # Inside a Rails controller:
|
452
|
+
# before_action do
|
453
|
+
# Honeybadger.event_context({user_id: current_user.id})
|
454
|
+
# end
|
455
|
+
#
|
456
|
+
# # Explicit conversion
|
457
|
+
# class User < ActiveRecord::Base
|
458
|
+
# def to_honeybadger_context
|
459
|
+
# { user_id: id, user_email: email }
|
460
|
+
# end
|
461
|
+
# end
|
462
|
+
#
|
463
|
+
# user = User.first
|
464
|
+
# Honeybadger.event_context(user)
|
465
|
+
#
|
466
|
+
# # Clearing event context:
|
467
|
+
# Honeybadger.clear_event_context
|
468
|
+
#
|
469
|
+
# @param [Hash] context A Hash of data which will be sent to Honeybadger
|
470
|
+
# when an event occurs. If the object responds to +#to_honeybadger_context+,
|
471
|
+
# the return value of that method will be used (explicit conversion). Can
|
472
|
+
# include any key/value, but a few keys have a special meaning in
|
473
|
+
# Honeybadger.
|
474
|
+
#
|
475
|
+
# @return [Object, self] value of the block if passed, otherwise self
|
476
|
+
def event_context(context = nil, &block)
|
477
|
+
block_result = context_manager.set_event_context(context, &block) unless context.nil?
|
478
|
+
return block_result if block_given?
|
479
|
+
|
480
|
+
self
|
481
|
+
end
|
482
|
+
|
483
|
+
# Get event-specific context for the current request.
|
484
|
+
#
|
485
|
+
# @example
|
486
|
+
# Honeybadger.event_context({my_data: 'my value'})
|
487
|
+
# Honeybadger.get_event_context # => {my_data: 'my value'}
|
488
|
+
#
|
489
|
+
# @return [Hash, nil]
|
490
|
+
def get_event_context
|
491
|
+
context_manager.get_event_context
|
492
|
+
end
|
493
|
+
|
445
494
|
# @api private
|
446
495
|
def collect(collector)
|
447
496
|
return unless config.insights_enabled?
|
@@ -497,6 +497,11 @@ module Honeybadger
|
|
497
497
|
default: 60,
|
498
498
|
type: Integer
|
499
499
|
},
|
500
|
+
:'insights.exclude_rake_tasks' => {
|
501
|
+
description: "List of Rake tasks to exclude from Insights instrumentation.",
|
502
|
+
default: ['assets:precompile'],
|
503
|
+
type: Array
|
504
|
+
},
|
500
505
|
:'puma.insights.events' => {
|
501
506
|
description: 'Enable automatic event capturing for Puma stats.',
|
502
507
|
default: true,
|
data/lib/honeybadger/config.rb
CHANGED
@@ -289,7 +289,18 @@ module Honeybadger
|
|
289
289
|
end
|
290
290
|
|
291
291
|
def insights_enabled?
|
292
|
-
public?
|
292
|
+
return false unless public?
|
293
|
+
return false if insights_exclude_for_rake_tasks?
|
294
|
+
!!self[:'insights.enabled']
|
295
|
+
end
|
296
|
+
|
297
|
+
def insights_exclude_for_rake_tasks?
|
298
|
+
return false unless defined?(Rake) && Rake.application&.top_level_tasks
|
299
|
+
|
300
|
+
current_tasks = Array(Rake.application.top_level_tasks)
|
301
|
+
excluded_tasks = Array(self[:'insights.exclude_rake_tasks'])
|
302
|
+
|
303
|
+
(current_tasks & excluded_tasks).any?
|
293
304
|
end
|
294
305
|
|
295
306
|
def cluster_collection?(name)
|
@@ -53,6 +53,52 @@ module Honeybadger
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def clear_context
|
57
|
+
@mutex.synchronize do
|
58
|
+
@global_context = nil
|
59
|
+
@local_context = nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_event_context(hash, &block)
|
64
|
+
local = block_given?
|
65
|
+
@mutex.synchronize do
|
66
|
+
@global_event_context ||= {}
|
67
|
+
@local_event_context ||= []
|
68
|
+
|
69
|
+
new_context = Context(hash)
|
70
|
+
|
71
|
+
if local
|
72
|
+
@local_event_context << new_context
|
73
|
+
else
|
74
|
+
@global_event_context.update(new_context)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if local
|
79
|
+
begin
|
80
|
+
yield
|
81
|
+
ensure
|
82
|
+
@mutex.synchronize { @local_event_context&.pop }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_event_context
|
88
|
+
@mutex.synchronize do
|
89
|
+
return @global_event_context unless @local_event_context
|
90
|
+
|
91
|
+
@global_event_context.merge(@local_event_context.inject({}, :merge))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def clear_event_context
|
96
|
+
@mutex.synchronize do
|
97
|
+
@global_event_context = nil
|
98
|
+
@local_event_context = nil
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
56
102
|
def set_rack_env(env)
|
57
103
|
@mutex.synchronize { @rack_env = env }
|
58
104
|
end
|
@@ -77,6 +123,8 @@ module Honeybadger
|
|
77
123
|
@mutex.synchronize do
|
78
124
|
@global_context = nil
|
79
125
|
@local_context = nil
|
126
|
+
@global_event_context = nil
|
127
|
+
@local_event_context = nil
|
80
128
|
@rack_env = nil
|
81
129
|
@request_id = nil
|
82
130
|
end
|
@@ -3,6 +3,7 @@ module Honeybadger
|
|
3
3
|
module SolidQueue
|
4
4
|
Plugin.register :solid_queue do
|
5
5
|
requirement { config.load_plugin_insights?(:solid_queue) && defined?(::SolidQueue) }
|
6
|
+
requirement { defined?(ActiveRecord::Base) && ActiveRecord::Base.connected? }
|
6
7
|
|
7
8
|
collect_solid_queue_stats = -> do
|
8
9
|
data = {}
|
@@ -26,9 +27,9 @@ module Honeybadger
|
|
26
27
|
end
|
27
28
|
|
28
29
|
collect do
|
29
|
-
stats = collect_solid_queue_stats.call
|
30
|
-
|
31
30
|
if config.cluster_collection?(:solid_queue)
|
31
|
+
stats = collect_solid_queue_stats.call
|
32
|
+
|
32
33
|
if Honeybadger.config.load_plugin_insights_events?(:solid_queue)
|
33
34
|
Honeybadger.event('stats.solid_queue', stats.except(:stats).merge(stats[:stats]))
|
34
35
|
end
|
@@ -27,8 +27,10 @@ module Honeybadger
|
|
27
27
|
# @see Agent#$2
|
28
28
|
def_delegator :'Honeybadger::Agent.instance', :check_in
|
29
29
|
def_delegator :'Honeybadger::Agent.instance', :context
|
30
|
+
def_delegator :'Honeybadger::Agent.instance', :event_context
|
30
31
|
def_delegator :'Honeybadger::Agent.instance', :configure
|
31
32
|
def_delegator :'Honeybadger::Agent.instance', :get_context
|
33
|
+
def_delegator :'Honeybadger::Agent.instance', :get_event_context
|
32
34
|
def_delegator :'Honeybadger::Agent.instance', :flush
|
33
35
|
def_delegator :'Honeybadger::Agent.instance', :stop
|
34
36
|
def_delegator :'Honeybadger::Agent.instance', :exception_filter
|
data/lib/honeybadger/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honeybadger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Honeybadger Industries LLC
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-06-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: logger
|