honeybadger 5.11.1 → 5.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/lib/honeybadger/agent.rb +11 -17
- data/lib/honeybadger/cli/install.rb +4 -0
- data/lib/honeybadger/cli/main.rb +1 -0
- data/lib/honeybadger/config/ruby.rb +17 -5
- data/lib/honeybadger/config.rb +4 -0
- data/lib/honeybadger/event.rb +56 -0
- data/lib/honeybadger/plugins/active_job.rb +2 -1
- data/lib/honeybadger/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02da7e28bdfb138d80a3e8e3e591d45383406fac1676ed04f0df139125e56247
|
4
|
+
data.tar.gz: 2c08c2e0e4e42ea9b7532c09f28f8d1c60a4944dab1e0d1ebc277becb58f8947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd07b8f3bfe423336690f00dc80addfb4fbda2db27bbcca0739204888b1565455ea09cbb6d5e643162f00c247ce09ff867e3eab0d71d7f59ca8d39bfc26164cd
|
7
|
+
data.tar.gz: 93e0ad66065c9be2c216e69a0d631effe6ba795ff90f328bf05a24bd2d45b60369e1cf3df4b0fc15478c7a73ec497a8661265bdb3daf52b39668117a7b123c9b
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
3
|
|
4
|
+
## [5.13.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.12.0...v5.13.0) (2024-06-18)
|
5
|
+
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* add before_event hook for intercepting events ([#567](https://github.com/honeybadger-io/honeybadger-ruby/issues/567)) ([2f86728](https://github.com/honeybadger-io/honeybadger-ruby/commit/2f8672814af3b12b3bfbc775de63b7a34b5087ad))
|
10
|
+
|
11
|
+
## [5.12.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.11.2...v5.12.0) (2024-06-17)
|
12
|
+
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
* add --insights flag to install command ([#564](https://github.com/honeybadger-io/honeybadger-ruby/issues/564)) ([02a41c6](https://github.com/honeybadger-io/honeybadger-ruby/commit/02a41c67e4b33012057e4ae4c2bd23ca8c13c99b))
|
17
|
+
|
18
|
+
## [5.11.2](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.11.1...v5.11.2) (2024-06-12)
|
19
|
+
|
20
|
+
|
21
|
+
### Bug Fixes
|
22
|
+
|
23
|
+
* don't blow up if ActiveJob queue_adapter isn't a string or symbol ([#561](https://github.com/honeybadger-io/honeybadger-ruby/issues/561)) ([4550ea3](https://github.com/honeybadger-io/honeybadger-ruby/commit/4550ea393680a07599deb95f6b49e45112447efa)), closes [#560](https://github.com/honeybadger-io/honeybadger-ruby/issues/560)
|
24
|
+
|
4
25
|
## [5.11.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.11.0...v5.11.1) (2024-06-07)
|
5
26
|
|
6
27
|
|
data/lib/honeybadger/agent.rb
CHANGED
@@ -4,6 +4,7 @@ require 'honeybadger/version'
|
|
4
4
|
require 'honeybadger/config'
|
5
5
|
require 'honeybadger/context_manager'
|
6
6
|
require 'honeybadger/notice'
|
7
|
+
require 'honeybadger/event'
|
7
8
|
require 'honeybadger/plugin'
|
8
9
|
require 'honeybadger/logging'
|
9
10
|
require 'honeybadger/worker'
|
@@ -392,28 +393,21 @@ module Honeybadger
|
|
392
393
|
def event(event_type, payload = {})
|
393
394
|
init_events_worker
|
394
395
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
if event_type.is_a?(String)
|
399
|
-
merged[:event_type] = event_type
|
400
|
-
else
|
401
|
-
merged.merge!(Hash(event_type))
|
396
|
+
extra_payload = {}.tap do |p|
|
397
|
+
p[:request_id] = context_manager.get_request_id if context_manager.get_request_id
|
398
|
+
p[:hostname] = config[:hostname].to_s if config[:'events.attach_hostname']
|
402
399
|
end
|
403
400
|
|
404
|
-
|
405
|
-
merged[:request_id] = request_id
|
406
|
-
end
|
401
|
+
event = Event.new(event_type, extra_payload.merge(payload))
|
407
402
|
|
408
|
-
|
409
|
-
|
403
|
+
config.before_event_hooks.each do |hook|
|
404
|
+
with_error_handling { hook.call(event) }
|
410
405
|
end
|
411
406
|
|
412
|
-
|
413
|
-
|
414
|
-
return if config.ignored_events.any? { |check| merged[:event_type]&.match?(check) }
|
407
|
+
return if config.ignored_events.any? { |check| event.event_type&.match?(check) }
|
408
|
+
return if event.halted?
|
415
409
|
|
416
|
-
events_worker.push(
|
410
|
+
events_worker.push(event.as_json)
|
417
411
|
end
|
418
412
|
|
419
413
|
# @api private
|
@@ -590,7 +584,7 @@ module Honeybadger
|
|
590
584
|
def with_error_handling
|
591
585
|
yield
|
592
586
|
rescue => ex
|
593
|
-
error { "Rescued an error in a before
|
587
|
+
error { "Rescued an error in a before hook: #{ex.message}" }
|
594
588
|
end
|
595
589
|
|
596
590
|
@instance = new(Config.new)
|
data/lib/honeybadger/cli/main.rb
CHANGED
@@ -48,6 +48,7 @@ WELCOME
|
|
48
48
|
end
|
49
49
|
|
50
50
|
desc 'install API_KEY', 'Install Honeybadger into a new project'
|
51
|
+
option :insights, type: :boolean, aliases: :'-i', default: false, desc: 'Enable Honeybadger Insights'
|
51
52
|
def install(api_key)
|
52
53
|
Install.new(options, api_key).run
|
53
54
|
rescue => e
|
@@ -89,15 +89,27 @@ module Honeybadger
|
|
89
89
|
def before_notify(action = nil, &block)
|
90
90
|
hooks = Array(get(:before_notify)).dup
|
91
91
|
|
92
|
-
if action && validate_before_action(action)
|
92
|
+
if action && validate_before_action(action, 'notify')
|
93
93
|
hooks << action
|
94
|
-
elsif block_given? && validate_before_action(block)
|
94
|
+
elsif block_given? && validate_before_action(block, 'notify')
|
95
95
|
hooks << block
|
96
96
|
end
|
97
97
|
|
98
98
|
hash[:before_notify] = hooks
|
99
99
|
end
|
100
100
|
|
101
|
+
def before_event(action = nil, &block)
|
102
|
+
hooks = Array(get(:before_event)).dup
|
103
|
+
|
104
|
+
if action && validate_before_action(action, 'event')
|
105
|
+
hooks << action
|
106
|
+
elsif block_given? && validate_before_action(block, 'event')
|
107
|
+
hooks << block
|
108
|
+
end
|
109
|
+
|
110
|
+
hash[:before_event] = hooks
|
111
|
+
end
|
112
|
+
|
101
113
|
def backtrace_filter(&block)
|
102
114
|
if block_given?
|
103
115
|
logger.warn('DEPRECATED: backtrace_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#backtrace_filter')
|
@@ -127,17 +139,17 @@ module Honeybadger
|
|
127
139
|
|
128
140
|
private
|
129
141
|
|
130
|
-
def validate_before_action(action)
|
142
|
+
def validate_before_action(action, type)
|
131
143
|
if !action.respond_to?(:call)
|
132
144
|
logger.warn(
|
133
|
-
|
145
|
+
"You attempted to add a before #{type} hook that does not respond " \
|
134
146
|
'to #call. We are discarding this hook so your intended behavior ' \
|
135
147
|
'will not occur.'
|
136
148
|
)
|
137
149
|
false
|
138
150
|
elsif action.arity != 1
|
139
151
|
logger.warn(
|
140
|
-
|
152
|
+
"You attempted to add a before #{type} hook that has an arity " \
|
141
153
|
'other than one. We are discarding this hook so your intended ' \
|
142
154
|
'behavior will not occur.'
|
143
155
|
)
|
data/lib/honeybadger/config.rb
CHANGED
@@ -92,6 +92,10 @@ module Honeybadger
|
|
92
92
|
(ruby[:before_notify] || []).clone
|
93
93
|
end
|
94
94
|
|
95
|
+
def before_event_hooks
|
96
|
+
(ruby[:before_event] || []).clone
|
97
|
+
end
|
98
|
+
|
95
99
|
def exception_filter(&block)
|
96
100
|
if block_given?
|
97
101
|
warn('DEPRECATED: exception_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_filter')
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
class Event
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
# The timestamp of the event
|
8
|
+
attr_reader :ts
|
9
|
+
|
10
|
+
# The event_type of the event
|
11
|
+
attr_reader :event_type
|
12
|
+
|
13
|
+
# The payload data of the event
|
14
|
+
attr_reader :payload
|
15
|
+
|
16
|
+
def_delegator :payload, :[]
|
17
|
+
|
18
|
+
# @api private
|
19
|
+
def initialize(event_type_or_payload, payload={})
|
20
|
+
if event_type_or_payload.is_a?(String)
|
21
|
+
@event_type = event_type_or_payload
|
22
|
+
@payload = payload
|
23
|
+
elsif event_type_or_payload.is_a?(Hash)
|
24
|
+
@event_type = event_type_or_payload[:event_type] || event_type_or_payload["event_type"]
|
25
|
+
@payload = event_type_or_payload
|
26
|
+
end
|
27
|
+
|
28
|
+
@ts = payload[:ts] || Time.now.utc.strftime("%FT%T.%LZ")
|
29
|
+
@halted = false
|
30
|
+
end
|
31
|
+
|
32
|
+
# Halts the event and the before_event callback chain.
|
33
|
+
#
|
34
|
+
# Returns nothing.
|
35
|
+
def halt!
|
36
|
+
@halted ||= true
|
37
|
+
end
|
38
|
+
|
39
|
+
# @api private
|
40
|
+
# Determines if this event will be discarded.
|
41
|
+
def halted?
|
42
|
+
!!@halted
|
43
|
+
end
|
44
|
+
|
45
|
+
# @api private
|
46
|
+
# Template used to create JSON payload.
|
47
|
+
#
|
48
|
+
# @return [Hash] JSON representation of the event.
|
49
|
+
def as_json(*args)
|
50
|
+
payload.tap do |p|
|
51
|
+
p[:ts] = ts
|
52
|
+
p[:event_type] = event_type if event_type
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -39,12 +39,13 @@ module Honeybadger
|
|
39
39
|
requirement do
|
40
40
|
defined?(::Rails.application) &&
|
41
41
|
::Rails.application.config.respond_to?(:active_job) &&
|
42
|
+
::Rails.application.config.active_job[:queue_adapter].respond_to?(:to_sym) &&
|
42
43
|
!EXCLUDED_ADAPTERS.include?(::Rails.application.config.active_job[:queue_adapter].to_sym)
|
43
44
|
end
|
44
45
|
|
45
46
|
# Don't report errors if GoodJob is reporting them
|
46
47
|
requirement do
|
47
|
-
|
48
|
+
!::Rails.application.config.active_job[:queue_adapter].to_s.match?(/(GoodJob::Adapter|good_job)/) ||
|
48
49
|
!::Rails.application.config.respond_to?(:good_job) ||
|
49
50
|
::Rails.application.config.good_job[:on_thread_error].nil?
|
50
51
|
end
|
data/lib/honeybadger/version.rb
CHANGED
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.
|
4
|
+
version: 5.13.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-06-
|
11
|
+
date: 2024-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Make managing application errors a more pleasant experience.
|
14
14
|
email:
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/honeybadger/context_manager.rb
|
57
57
|
- lib/honeybadger/conversions.rb
|
58
58
|
- lib/honeybadger/counter.rb
|
59
|
+
- lib/honeybadger/event.rb
|
59
60
|
- lib/honeybadger/events_worker.rb
|
60
61
|
- lib/honeybadger/gauge.rb
|
61
62
|
- lib/honeybadger/histogram.rb
|