exception_handling 2.13.0 → 2.14.0.pre.gk.1
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 +5 -0
- data/Gemfile.lock +9 -11
- data/lib/exception_handling/exception_info.rb +2 -1
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +5 -1
- data/spec/unit/exception_handling/exception_info_spec.rb +17 -0
- data/spec/unit/exception_handling/sensu_spec.rb +3 -3
- data/spec/unit/exception_handling_spec.rb +6 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9443856b4b95e8a7a4447797e52afc5f7278e10574e3f42b6b761f6d914b7a8f
|
4
|
+
data.tar.gz: de0790fced3ccdd7e6dbcff2ecd153f7cc9619bf729adf1b6322fd486ff004b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd845247940506ce0ebc30ffe35a715454926e2a4b90b9f56c39bb6386c8267b06d8da911c57ee52327451ddb10ca16c3cfe63f0aeb9088423cc7211a737736
|
7
|
+
data.tar.gz: 888c7ab078a79727813d58656b1bba588e7c70c9482c21cc2e8bf95bed37e3bf228787be055dda3bc05d57e9c56915dc9ee3f6aba32d539d2e5e5633d3418ebc
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [2.14.0] - Unreleased
|
8
|
+
### Added
|
9
|
+
- Added support for plumbing tags through to honeybadger via the `honeybadger_tags` log context parameter
|
10
|
+
|
7
11
|
## [2.13.0] - 2022-09-15
|
8
12
|
### Added
|
9
13
|
- Added an option for removing the 'exception_handling.' prefix from metric names in ExceptionHandling::default_metric_name
|
@@ -99,6 +103,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
99
103
|
### Changed
|
100
104
|
- No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
|
101
105
|
|
106
|
+
[2.14.0]: https://github.com/Invoca/exception_handling/compare/v2.13.0...v2.14.0
|
102
107
|
[2.13.0]: https://github.com/Invoca/exception_handling/compare/v2.12.0...v2.13.0
|
103
108
|
[2.12.0]: https://github.com/Invoca/exception_handling/compare/v2.11.3...v2.12.0
|
104
109
|
[2.11.3]: https://github.com/Invoca/exception_handling/compare/v2.11.2...v2.11.3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
exception_handling (2.
|
4
|
+
exception_handling (2.14.0.pre.gk.1)
|
5
5
|
actionmailer (>= 5.2, < 7.0)
|
6
6
|
actionpack (>= 5.2, < 7.0)
|
7
7
|
activesupport (>= 5.2, < 7.0)
|
@@ -52,12 +52,11 @@ GEM
|
|
52
52
|
byebug (11.1.3)
|
53
53
|
coderay (1.1.2)
|
54
54
|
concurrent-ruby (1.1.10)
|
55
|
-
contextual_logger (1.
|
55
|
+
contextual_logger (1.1.1)
|
56
56
|
activesupport
|
57
57
|
json
|
58
58
|
crass (1.0.6)
|
59
59
|
diff-lcs (1.5.0)
|
60
|
-
digest (3.1.0)
|
61
60
|
erubi (1.10.0)
|
62
61
|
escalate (0.3.0)
|
63
62
|
eventmachine (1.2.7)
|
@@ -66,9 +65,10 @@ GEM
|
|
66
65
|
honeybadger (4.11.0)
|
67
66
|
i18n (1.10.0)
|
68
67
|
concurrent-ruby (~> 1.0)
|
69
|
-
invoca-utils (0.
|
68
|
+
invoca-utils (0.5.0)
|
69
|
+
activesupport (>= 5.0)
|
70
70
|
jaro_winkler (1.5.3)
|
71
|
-
json (2.6.
|
71
|
+
json (2.6.3)
|
72
72
|
loofah (2.15.0)
|
73
73
|
crass (~> 1.0.2)
|
74
74
|
nokogiri (>= 1.5.9)
|
@@ -78,12 +78,10 @@ GEM
|
|
78
78
|
mini_mime (1.1.2)
|
79
79
|
mini_portile2 (2.8.0)
|
80
80
|
minitest (5.15.0)
|
81
|
-
net-protocol (0.1
|
81
|
+
net-protocol (0.2.1)
|
82
82
|
timeout
|
83
|
-
net-smtp (0.3.
|
84
|
-
digest
|
83
|
+
net-smtp (0.3.3)
|
85
84
|
net-protocol
|
86
|
-
timeout
|
87
85
|
nokogiri (1.13.3)
|
88
86
|
mini_portile2 (~> 2.8.0)
|
89
87
|
racc (~> 1.4)
|
@@ -97,7 +95,7 @@ GEM
|
|
97
95
|
pry-byebug (3.8.0)
|
98
96
|
byebug (~> 11.0)
|
99
97
|
pry (~> 0.10)
|
100
|
-
psych (3.3.
|
98
|
+
psych (3.3.4)
|
101
99
|
racc (1.6.0)
|
102
100
|
rack (2.2.3)
|
103
101
|
rack-test (1.1.0)
|
@@ -136,7 +134,7 @@ GEM
|
|
136
134
|
power_assert
|
137
135
|
thor (1.0.1)
|
138
136
|
thread_safe (0.3.6)
|
139
|
-
timeout (0.3.
|
137
|
+
timeout (0.3.2)
|
140
138
|
tzinfo (1.2.9)
|
141
139
|
thread_safe (~> 0.1)
|
142
140
|
unicode-display_width (1.6.0)
|
@@ -49,7 +49,7 @@ module ExceptionHandling
|
|
49
49
|
HONEYBADGER_CONTEXT_SECTIONS = [:timestamp, :error_class, :exception_context, :server, :scm_revision, :notes,
|
50
50
|
:user_details, :request, :session, :environment, :backtrace, :event_response, :log_context].freeze
|
51
51
|
|
52
|
-
attr_reader :exception, :controller, :exception_context, :timestamp
|
52
|
+
attr_reader :exception, :controller, :exception_context, :timestamp, :honeybadger_tags
|
53
53
|
|
54
54
|
def initialize(exception, exception_context, timestamp, controller: nil, data_callback: nil, log_context: nil)
|
55
55
|
@exception = exception
|
@@ -59,6 +59,7 @@ module ExceptionHandling
|
|
59
59
|
@data_callback = data_callback
|
60
60
|
# merge into the surrounding context just like ContextualLogger does when logging
|
61
61
|
@merged_log_context = ExceptionHandling.logger.current_context_for_thread.deep_merge(log_context || {})
|
62
|
+
@honeybadger_tags = Array(@merged_log_context[:honeybadger_tags] || [])
|
62
63
|
end
|
63
64
|
|
64
65
|
def data
|
data/lib/exception_handling.rb
CHANGED
@@ -270,11 +270,15 @@ module ExceptionHandling # never included
|
|
270
270
|
def send_exception_to_honeybadger(exception_info)
|
271
271
|
exception = exception_info.exception
|
272
272
|
exception_description = exception_info.exception_description
|
273
|
+
# Note: Both commas and spaces are treated as delimiters for the :tags string. Space-delimiters are not officially documented.
|
274
|
+
# https://github.com/honeybadger-io/honeybadger-ruby/pull/422
|
275
|
+
tags = exception_info.honeybadger_tags.join(' ')
|
273
276
|
response = Honeybadger.notify(error_class: exception_description ? exception_description.filter_name : exception.class.name,
|
274
277
|
error_message: exception.message.to_s,
|
275
278
|
exception: exception,
|
276
279
|
context: exception_info.honeybadger_context_data,
|
277
|
-
controller: exception_info.controller_name
|
280
|
+
controller: exception_info.controller_name,
|
281
|
+
tags: tags)
|
278
282
|
response ? :success : :failure
|
279
283
|
rescue Exception => ex
|
280
284
|
warn("ExceptionHandling.send_exception_to_honeybadger rescued exception while logging #{exception_info.exception_context}:\n#{exception.class}: #{exception.message}:\n#{ex.class}: #{ex.message}\n#{ex.backtrace.join("\n")}")
|
@@ -44,6 +44,23 @@ module ExceptionHandling
|
|
44
44
|
expect(exception_info.controller).to be_nil
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
context "honeybadger_tags" do
|
49
|
+
it "retrieved from log_context" do
|
50
|
+
exception_info = ExceptionInfo.new(@exception, "string context", @timestamp, log_context: { honeybadger_tags: ['Data-Services'] })
|
51
|
+
expect(exception_info.honeybadger_tags).to eq(['Data-Services'])
|
52
|
+
end
|
53
|
+
|
54
|
+
it "retrieved from log_context and normalized to array if a string" do
|
55
|
+
exception_info = ExceptionInfo.new(@exception, "string context", @timestamp, log_context: { honeybadger_tags: 'Data-Services' })
|
56
|
+
expect(exception_info.honeybadger_tags).to eq(['Data-Services'])
|
57
|
+
end
|
58
|
+
|
59
|
+
it "defaults to empty array if not given" do
|
60
|
+
exception_info = ExceptionInfo.new(@exception, "string context", @timestamp)
|
61
|
+
expect(exception_info.honeybadger_tags).to eq([])
|
62
|
+
end
|
63
|
+
end
|
47
64
|
end
|
48
65
|
|
49
66
|
context "data" do
|
@@ -6,7 +6,7 @@ module ExceptionHandling
|
|
6
6
|
describe Sensu do
|
7
7
|
context "#generate_event" do
|
8
8
|
it "create an event" do
|
9
|
-
expect(ExceptionHandling::Sensu).to receive(:send_event).with(name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1)
|
9
|
+
expect(ExceptionHandling::Sensu).to receive(:send_event).with({ name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1 })
|
10
10
|
|
11
11
|
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye")
|
12
12
|
end
|
@@ -14,13 +14,13 @@ module ExceptionHandling
|
|
14
14
|
it "add the sensu prefix" do
|
15
15
|
ExceptionHandling.sensu_prefix = "cnn_"
|
16
16
|
|
17
|
-
expect(ExceptionHandling::Sensu).to receive(:send_event).with(name: "cnn_world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1)
|
17
|
+
expect(ExceptionHandling::Sensu).to receive(:send_event).with({ name: "cnn_world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1 })
|
18
18
|
|
19
19
|
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "allow the level to be set to critical" do
|
23
|
-
expect(ExceptionHandling::Sensu).to receive(:send_event).with(name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 2)
|
23
|
+
expect(ExceptionHandling::Sensu).to receive(:send_event).with({ name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 2 })
|
24
24
|
|
25
25
|
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye", :critical)
|
26
26
|
end
|
@@ -158,12 +158,8 @@ describe ExceptionHandling do
|
|
158
158
|
|
159
159
|
context "#log_warning" do
|
160
160
|
it "have empty array as a backtrace" do
|
161
|
-
|
162
|
-
|
163
|
-
else
|
164
|
-
[ExceptionHandling::Warning]
|
165
|
-
end
|
166
|
-
expect(ExceptionHandling).to receive(:log_error).with(*expected_args) do |error|
|
161
|
+
expect(ExceptionHandling).to receive(:log_error) do |error|
|
162
|
+
expect(error.class).to eq(ExceptionHandling::Warning)
|
167
163
|
expect(error.backtrace).to eq([])
|
168
164
|
end
|
169
165
|
ExceptionHandling.log_warning('Now with empty array as a backtrace!')
|
@@ -727,7 +723,7 @@ describe ExceptionHandling do
|
|
727
723
|
expect(Honeybadger).to receive(:notify).with(any_args) do |data|
|
728
724
|
honeybadger_data = data
|
729
725
|
end
|
730
|
-
ExceptionHandling.logger.global_context = { service_name: "rails", region: "AWS-us-east-1" }
|
726
|
+
ExceptionHandling.logger.global_context = { service_name: "rails", region: "AWS-us-east-1", honeybadger_tags: ['Data-Services', 'web'] }
|
731
727
|
log_context = { log_source: "gem/listen", service_name: "bin/console" }
|
732
728
|
ExceptionHandling.log_error(@exception, @exception_context, @controller, **log_context) do |data|
|
733
729
|
data[:scm_revision] = "5b24eac37aaa91f5784901e9aabcead36fd9df82"
|
@@ -741,6 +737,7 @@ describe ExceptionHandling do
|
|
741
737
|
error_message: "Some Exception",
|
742
738
|
controller: "some_controller",
|
743
739
|
exception: @exception,
|
740
|
+
tags: "Data-Services web",
|
744
741
|
context: {
|
745
742
|
timestamp: Time.now.to_i,
|
746
743
|
error_class: "StandardError",
|
@@ -766,7 +763,7 @@ describe ExceptionHandling do
|
|
766
763
|
"spec/unit/exception_handling_spec.rb:455:in `block (4 levels) in <class:ExceptionHandlingTest>'"
|
767
764
|
],
|
768
765
|
event_response: "Event successfully received",
|
769
|
-
log_context: { "service_name" => "bin/console", "region" => "AWS-us-east-1", "log_source" => "gem/listen" }
|
766
|
+
log_context: { "service_name" => "bin/console", "region" => "AWS-us-east-1", "log_source" => "gem/listen", "honeybadger_tags" => ['Data-Services', 'web'] }
|
770
767
|
}
|
771
768
|
}
|
772
769
|
expect(honeybadger_data).to eq(expected_data)
|
@@ -791,6 +788,7 @@ describe ExceptionHandling do
|
|
791
788
|
error_message: "Some Exception",
|
792
789
|
controller: "some_controller",
|
793
790
|
exception: @exception,
|
791
|
+
tags: "",
|
794
792
|
context: {
|
795
793
|
timestamp: Time.now.to_i,
|
796
794
|
error_class: "StandardError",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_handling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0.pre.gk.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -222,9 +222,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
224
|
requirements:
|
225
|
-
- - "
|
225
|
+
- - ">"
|
226
226
|
- !ruby/object:Gem::Version
|
227
|
-
version:
|
227
|
+
version: 1.3.1
|
228
228
|
requirements: []
|
229
229
|
rubygems_version: 3.1.6
|
230
230
|
signing_key:
|