exception_handling 2.8.0 → 2.9.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 +11 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +31 -24
- data/exception_handling.gemspec +1 -0
- data/gemfiles/rails_4.gemfile +3 -2
- data/gemfiles/rails_5.gemfile +3 -2
- data/gemfiles/rails_6.gemfile +3 -2
- data/lib/exception_handling.rb +16 -8
- data/lib/exception_handling/escalate_callback.rb +19 -0
- data/lib/exception_handling/exception_info.rb +4 -3
- data/lib/exception_handling/version.rb +1 -1
- data/spec/unit/exception_handling/escalate_callback_spec.rb +81 -0
- data/spec/unit/exception_handling/exception_info_spec.rb +20 -0
- data/spec/unit/exception_handling/mailer_spec.rb +0 -1
- data/spec/unit/exception_handling_spec.rb +15 -15
- metadata +22 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98d4a360c553e3d8505ddf0d0de7d4028416f3e1bd62f513b9848dfa95de7cf3
|
|
4
|
+
data.tar.gz: 4e4ee581d5fb7f4490b1db162ba49113eee07b748a32f0854a53801633156a73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6b7f7e6d8ccd286e97aec2bc28833a041108a3b16043dfe437f688bbdf45a034c5b3f407ccffa06d26bfe949e7e1aa164747ea4e797fac4ace4f2dc7fce9c34
|
|
7
|
+
data.tar.gz: fea43abeaf0400f78a975037c5e881b9a41e07b20b934fda5ac7bf35b59ca652daee4ccaa1503abafe818ad3b741edc1ec1a3665ce32e7fdc15ee91f1bb1afb4
|
data/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,15 @@ 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.
|
|
7
|
+
## [2.9.0] - 2020-03-02
|
|
8
|
+
### Added
|
|
9
|
+
- Automatically registers with the `escalate` gem's `on_escalate` callback.
|
|
10
|
+
|
|
11
|
+
## [2.8.1] - 2020-12-01
|
|
12
|
+
### Added
|
|
13
|
+
- If the `log_context` key `honeybadger_grouping:` is set, pass that value to the `controller:` keyword argument of `HoneyBadger.notify`.
|
|
14
|
+
|
|
15
|
+
## [2.8.0] - 2020-10-19
|
|
8
16
|
### Deprecated
|
|
9
17
|
- Deprecated Email Escalation Methods: `escalate_to_production_support`, `escalate_error`, `escalate_warning`, `ensure_escalation`
|
|
10
18
|
|
|
@@ -56,6 +64,8 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
|
56
64
|
### Changed
|
|
57
65
|
- No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
|
|
58
66
|
|
|
67
|
+
[2.9.0]: https://github.com/Invoca/exception_handling/compare/v2.8.1...v2.9.0
|
|
68
|
+
[2.8.1]: https://github.com/Invoca/exception_handling/compare/v2.8.0...v2.8.1
|
|
59
69
|
[2.8.0]: https://github.com/Invoca/exception_handling/compare/v2.7.0...v2.8.0
|
|
60
70
|
[2.7.0]: https://github.com/Invoca/exception_handling/compare/v2.6.1...v2.7.0
|
|
61
71
|
[2.6.1]: https://github.com/Invoca/exception_handling/compare/v2.6.0...v2.6.1
|
data/Gemfile
CHANGED
|
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
|
|
|
4
4
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
|
+
gem 'actionmailer', '< 6.1'
|
|
8
|
+
gem 'activesupport', '< 6.1'
|
|
7
9
|
gem 'appraisal', '~> 2.2'
|
|
8
10
|
gem 'honeybadger', '3.3.1-1', git: 'git@github.com:Invoca/honeybadger-ruby', ref: 'bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6'
|
|
9
11
|
gem 'pry'
|
data/Gemfile.lock
CHANGED
|
@@ -8,40 +8,41 @@ GIT
|
|
|
8
8
|
PATH
|
|
9
9
|
remote: .
|
|
10
10
|
specs:
|
|
11
|
-
exception_handling (2.
|
|
11
|
+
exception_handling (2.9.0)
|
|
12
12
|
actionmailer (>= 4.2, < 7.0)
|
|
13
13
|
actionpack (>= 4.2, < 7.0)
|
|
14
14
|
activesupport (>= 4.2, < 7.0)
|
|
15
15
|
contextual_logger (~> 0.7)
|
|
16
|
+
escalate (~> 0.2)
|
|
16
17
|
eventmachine (~> 1.0)
|
|
17
18
|
invoca-utils (~> 0.3)
|
|
18
19
|
|
|
19
20
|
GEM
|
|
20
21
|
remote: https://rubygems.org/
|
|
21
22
|
specs:
|
|
22
|
-
actionmailer (6.0.3.
|
|
23
|
-
actionpack (= 6.0.3.
|
|
24
|
-
actionview (= 6.0.3.
|
|
25
|
-
activejob (= 6.0.3.
|
|
23
|
+
actionmailer (6.0.3.5)
|
|
24
|
+
actionpack (= 6.0.3.5)
|
|
25
|
+
actionview (= 6.0.3.5)
|
|
26
|
+
activejob (= 6.0.3.5)
|
|
26
27
|
mail (~> 2.5, >= 2.5.4)
|
|
27
28
|
rails-dom-testing (~> 2.0)
|
|
28
|
-
actionpack (6.0.3.
|
|
29
|
-
actionview (= 6.0.3.
|
|
30
|
-
activesupport (= 6.0.3.
|
|
29
|
+
actionpack (6.0.3.5)
|
|
30
|
+
actionview (= 6.0.3.5)
|
|
31
|
+
activesupport (= 6.0.3.5)
|
|
31
32
|
rack (~> 2.0, >= 2.0.8)
|
|
32
33
|
rack-test (>= 0.6.3)
|
|
33
34
|
rails-dom-testing (~> 2.0)
|
|
34
35
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
35
|
-
actionview (6.0.3.
|
|
36
|
-
activesupport (= 6.0.3.
|
|
36
|
+
actionview (6.0.3.5)
|
|
37
|
+
activesupport (= 6.0.3.5)
|
|
37
38
|
builder (~> 3.1)
|
|
38
39
|
erubi (~> 1.4)
|
|
39
40
|
rails-dom-testing (~> 2.0)
|
|
40
41
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
41
|
-
activejob (6.0.3.
|
|
42
|
-
activesupport (= 6.0.3.
|
|
42
|
+
activejob (6.0.3.5)
|
|
43
|
+
activesupport (= 6.0.3.5)
|
|
43
44
|
globalid (>= 0.3.6)
|
|
44
|
-
activesupport (6.0.3.
|
|
45
|
+
activesupport (6.0.3.5)
|
|
45
46
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
46
47
|
i18n (>= 0.7, < 2)
|
|
47
48
|
minitest (~> 5.1)
|
|
@@ -55,32 +56,35 @@ GEM
|
|
|
55
56
|
builder (3.2.4)
|
|
56
57
|
byebug (11.1.3)
|
|
57
58
|
coderay (1.1.2)
|
|
58
|
-
concurrent-ruby (1.1.
|
|
59
|
+
concurrent-ruby (1.1.8)
|
|
59
60
|
contextual_logger (0.11.0)
|
|
60
61
|
activesupport
|
|
61
62
|
json
|
|
62
63
|
crass (1.0.6)
|
|
63
64
|
diff-lcs (1.4.4)
|
|
64
|
-
erubi (1.
|
|
65
|
+
erubi (1.10.0)
|
|
66
|
+
escalate (0.2.0)
|
|
67
|
+
activesupport
|
|
65
68
|
eventmachine (1.2.7)
|
|
66
69
|
globalid (0.4.2)
|
|
67
70
|
activesupport (>= 4.2.0)
|
|
68
|
-
i18n (1.8.
|
|
71
|
+
i18n (1.8.9)
|
|
69
72
|
concurrent-ruby (~> 1.0)
|
|
70
73
|
invoca-utils (0.4.1)
|
|
71
74
|
jaro_winkler (1.5.3)
|
|
72
|
-
json (2.
|
|
73
|
-
loofah (2.
|
|
75
|
+
json (2.5.1)
|
|
76
|
+
loofah (2.9.0)
|
|
74
77
|
crass (~> 1.0.2)
|
|
75
78
|
nokogiri (>= 1.5.9)
|
|
76
79
|
mail (2.7.1)
|
|
77
80
|
mini_mime (>= 0.1.1)
|
|
78
81
|
method_source (0.9.2)
|
|
79
82
|
mini_mime (1.0.2)
|
|
80
|
-
mini_portile2 (2.
|
|
81
|
-
minitest (5.14.
|
|
82
|
-
nokogiri (1.
|
|
83
|
-
mini_portile2 (~> 2.
|
|
83
|
+
mini_portile2 (2.5.0)
|
|
84
|
+
minitest (5.14.4)
|
|
85
|
+
nokogiri (1.11.1)
|
|
86
|
+
mini_portile2 (~> 2.5.0)
|
|
87
|
+
racc (~> 1.4)
|
|
84
88
|
parallel (1.17.0)
|
|
85
89
|
parser (2.6.3.0)
|
|
86
90
|
ast (~> 2.4.0)
|
|
@@ -91,6 +95,7 @@ GEM
|
|
|
91
95
|
pry-byebug (3.8.0)
|
|
92
96
|
byebug (~> 11.0)
|
|
93
97
|
pry (~> 0.10)
|
|
98
|
+
racc (1.5.2)
|
|
94
99
|
rack (2.2.3)
|
|
95
100
|
rack-test (1.1.0)
|
|
96
101
|
rack (>= 1.0, < 3)
|
|
@@ -128,15 +133,17 @@ GEM
|
|
|
128
133
|
power_assert
|
|
129
134
|
thor (1.0.1)
|
|
130
135
|
thread_safe (0.3.6)
|
|
131
|
-
tzinfo (1.2.
|
|
136
|
+
tzinfo (1.2.9)
|
|
132
137
|
thread_safe (~> 0.1)
|
|
133
138
|
unicode-display_width (1.6.0)
|
|
134
|
-
zeitwerk (2.4.
|
|
139
|
+
zeitwerk (2.4.2)
|
|
135
140
|
|
|
136
141
|
PLATFORMS
|
|
137
142
|
ruby
|
|
138
143
|
|
|
139
144
|
DEPENDENCIES
|
|
145
|
+
actionmailer (< 6.1)
|
|
146
|
+
activesupport (< 6.1)
|
|
140
147
|
appraisal (~> 2.2)
|
|
141
148
|
exception_handling!
|
|
142
149
|
honeybadger (= 3.3.1.pre.1)!
|
data/exception_handling.gemspec
CHANGED
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.add_dependency 'actionpack', '>= 4.2', '< 7.0'
|
|
25
25
|
spec.add_dependency 'activesupport', '>= 4.2', '< 7.0'
|
|
26
26
|
spec.add_dependency 'contextual_logger', '~> 0.7'
|
|
27
|
+
spec.add_dependency 'escalate', '~> 0.2'
|
|
27
28
|
spec.add_dependency 'eventmachine', '~> 1.0'
|
|
28
29
|
spec.add_dependency 'invoca-utils', '~> 0.3'
|
|
29
30
|
end
|
data/gemfiles/rails_4.gemfile
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
+
gem "actionmailer", "~> 4.2"
|
|
6
|
+
gem "activesupport", "~> 4.2"
|
|
5
7
|
gem "appraisal", "~> 2.2"
|
|
8
|
+
gem "escalate", "0.2.0.pre.1"
|
|
6
9
|
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
|
7
10
|
gem "pry"
|
|
8
11
|
gem "pry-byebug"
|
|
@@ -11,8 +14,6 @@ gem "rspec"
|
|
|
11
14
|
gem "rspec_junit_formatter"
|
|
12
15
|
gem "rubocop"
|
|
13
16
|
gem "test-unit"
|
|
14
|
-
gem "actionmailer", "~> 4.2"
|
|
15
17
|
gem "actionpack", "~> 4.2"
|
|
16
|
-
gem "activesupport", "~> 4.2"
|
|
17
18
|
|
|
18
19
|
gemspec path: "../"
|
data/gemfiles/rails_5.gemfile
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
+
gem "actionmailer", "~> 5.2"
|
|
6
|
+
gem "activesupport", "~> 5.2"
|
|
5
7
|
gem "appraisal", "~> 2.2"
|
|
8
|
+
gem "escalate", "0.2.0.pre.1"
|
|
6
9
|
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
|
7
10
|
gem "pry"
|
|
8
11
|
gem "pry-byebug"
|
|
@@ -11,8 +14,6 @@ gem "rspec"
|
|
|
11
14
|
gem "rspec_junit_formatter"
|
|
12
15
|
gem "rubocop"
|
|
13
16
|
gem "test-unit"
|
|
14
|
-
gem "actionmailer", "~> 5.2"
|
|
15
17
|
gem "actionpack", "~> 5.2"
|
|
16
|
-
gem "activesupport", "~> 5.2"
|
|
17
18
|
|
|
18
19
|
gemspec path: "../"
|
data/gemfiles/rails_6.gemfile
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
+
gem "actionmailer", "~> 6.0"
|
|
6
|
+
gem "activesupport", "~> 6.0"
|
|
5
7
|
gem "appraisal", "~> 2.2"
|
|
8
|
+
gem "escalate", "0.2.0.pre.1"
|
|
6
9
|
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
|
7
10
|
gem "pry"
|
|
8
11
|
gem "pry-byebug"
|
|
@@ -11,8 +14,6 @@ gem "rspec"
|
|
|
11
14
|
gem "rspec_junit_formatter"
|
|
12
15
|
gem "rubocop"
|
|
13
16
|
gem "test-unit"
|
|
14
|
-
gem "actionmailer", "~> 6.0"
|
|
15
17
|
gem "actionpack", "~> 6.0"
|
|
16
|
-
gem "activesupport", "~> 6.0"
|
|
17
18
|
|
|
18
19
|
gemspec path: "../"
|
data/lib/exception_handling.rb
CHANGED
|
@@ -7,14 +7,15 @@ require 'contextual_logger'
|
|
|
7
7
|
|
|
8
8
|
require 'invoca/utils'
|
|
9
9
|
|
|
10
|
-
require
|
|
11
|
-
require
|
|
12
|
-
require
|
|
13
|
-
require
|
|
14
|
-
require
|
|
15
|
-
require
|
|
16
|
-
require
|
|
17
|
-
require
|
|
10
|
+
require 'exception_handling/mailer'
|
|
11
|
+
require 'exception_handling/sensu'
|
|
12
|
+
require 'exception_handling/methods'
|
|
13
|
+
require 'exception_handling/log_stub_error'
|
|
14
|
+
require 'exception_handling/exception_description'
|
|
15
|
+
require 'exception_handling/exception_catalog'
|
|
16
|
+
require 'exception_handling/exception_info'
|
|
17
|
+
require 'exception_handling/honeybadger_callbacks'
|
|
18
|
+
require 'exception_handling/escalate_callback'
|
|
18
19
|
|
|
19
20
|
_ = ActiveSupport::HashWithIndifferentAccess
|
|
20
21
|
|
|
@@ -52,6 +53,10 @@ module ExceptionHandling # never included
|
|
|
52
53
|
@exception_recipients or raise ArgumentError, "You must assign a value to #{name}.exception_recipients"
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
def configured?
|
|
57
|
+
!@logger.nil?
|
|
58
|
+
end
|
|
59
|
+
|
|
55
60
|
def logger
|
|
56
61
|
@logger or raise ArgumentError, "You must assign a value to #{name}.logger"
|
|
57
62
|
end
|
|
@@ -63,6 +68,7 @@ module ExceptionHandling # never included
|
|
|
63
68
|
Deprecation3_0.deprecation_warning('implicit extend with ContextualLogger::LoggerMixin', 'extend your logger instance or include into your logger class first')
|
|
64
69
|
logger.extend(ContextualLogger::LoggerMixin)
|
|
65
70
|
end
|
|
71
|
+
EscalateCallback.register_if_configured!
|
|
66
72
|
end
|
|
67
73
|
|
|
68
74
|
def default_metric_name(exception_data, exception, treat_like_warning)
|
|
@@ -484,4 +490,6 @@ module ExceptionHandling # never included
|
|
|
484
490
|
end
|
|
485
491
|
end
|
|
486
492
|
end
|
|
493
|
+
|
|
494
|
+
EscalateCallback.register_if_configured!
|
|
487
495
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'escalate'
|
|
4
|
+
|
|
5
|
+
module ExceptionHandling
|
|
6
|
+
module EscalateCallback
|
|
7
|
+
class << self
|
|
8
|
+
def register_if_configured!
|
|
9
|
+
register! if ::ExceptionHandling.configured?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def register!
|
|
13
|
+
Escalate.on_escalate(log_first: false) do |exception, location_message, **context|
|
|
14
|
+
::ExceptionHandling.log_error(exception, location_message, **context)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -82,9 +82,10 @@ module ExceptionHandling
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def controller_name
|
|
85
|
-
@controller_name ||=
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
@controller_name ||= (
|
|
86
|
+
@merged_log_context[:honeybadger_grouping] ||
|
|
87
|
+
(@controller && @controller.request.parameters.with_indifferent_access[:controller])
|
|
88
|
+
).to_s
|
|
88
89
|
end
|
|
89
90
|
|
|
90
91
|
private
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'exception_handling/escalate_callback'
|
|
4
|
+
require File.expand_path('../../spec_helper', __dir__)
|
|
5
|
+
|
|
6
|
+
module ExceptionHandling
|
|
7
|
+
describe EscalateCallback do
|
|
8
|
+
before do
|
|
9
|
+
class TestGem
|
|
10
|
+
class << self
|
|
11
|
+
attr_accessor :logger
|
|
12
|
+
end
|
|
13
|
+
include Escalate.mixin
|
|
14
|
+
end
|
|
15
|
+
TestGem.logger = logger
|
|
16
|
+
Escalate.clear_on_escalate_callbacks
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after do
|
|
20
|
+
Escalate.clear_on_escalate_callbacks
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:exception) do
|
|
24
|
+
raise "boom!"
|
|
25
|
+
rescue => ex
|
|
26
|
+
ex
|
|
27
|
+
end
|
|
28
|
+
let(:location_message) { "happened in TestGem" }
|
|
29
|
+
let(:context_hash) { { cuid: 'AABBCD' } }
|
|
30
|
+
let(:logger) { double("logger") }
|
|
31
|
+
|
|
32
|
+
describe '.register_if_configured!' do
|
|
33
|
+
context 'when already configured' do
|
|
34
|
+
before do
|
|
35
|
+
@original_logger = ExceptionHandling.logger
|
|
36
|
+
ExceptionHandling.logger = ::Logger.new('/dev/null')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
after do
|
|
40
|
+
ExceptionHandling.logger = @original_logger
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'registers a callback' do
|
|
44
|
+
EscalateCallback.register_if_configured!
|
|
45
|
+
|
|
46
|
+
expect(logger).to_not receive(:error)
|
|
47
|
+
expect(logger).to_not receive(:fatal)
|
|
48
|
+
expect(ExceptionHandling).to receive(:log_error).with(exception, location_message, context_hash)
|
|
49
|
+
|
|
50
|
+
TestGem.escalate(exception, location_message, context_hash)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context 'when not yet configured' do
|
|
55
|
+
before do
|
|
56
|
+
@original_logger = ExceptionHandling.logger
|
|
57
|
+
ExceptionHandling.logger = nil
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
after do
|
|
61
|
+
ExceptionHandling.logger = @original_logger
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'registers a callback once the logger is set' do
|
|
65
|
+
EscalateCallback.register_if_configured!
|
|
66
|
+
|
|
67
|
+
expect(Escalate.on_escalate_callbacks).to be_empty
|
|
68
|
+
|
|
69
|
+
ExceptionHandling.logger = ::Logger.new('/dev/null')
|
|
70
|
+
expect(Escalate.on_escalate_callbacks).to_not be_empty
|
|
71
|
+
|
|
72
|
+
expect(logger).to_not receive(:error)
|
|
73
|
+
expect(logger).to_not receive(:fatal)
|
|
74
|
+
expect(ExceptionHandling).to receive(:log_error).with(exception, location_message, context_hash)
|
|
75
|
+
|
|
76
|
+
TestGem.escalate(exception, location_message, context_hash)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -361,6 +361,26 @@ module ExceptionHandling
|
|
|
361
361
|
}
|
|
362
362
|
end
|
|
363
363
|
|
|
364
|
+
it "returns honeybadger_grouping from the log context" do
|
|
365
|
+
allow(ExceptionHandling.logger).to receive(:current_context_for_thread).and_return({ honeybadger_grouping: 'Group 1' })
|
|
366
|
+
exception_info = ExceptionInfo.new(@exception, @exception_context, @timestamp)
|
|
367
|
+
|
|
368
|
+
expect(exception_info.controller_name).to eq('Group 1')
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
it "returns honeybadger_grouping from log context even if controller is defined" do
|
|
372
|
+
allow(ExceptionHandling.logger).to receive(:current_context_for_thread).and_return({ honeybadger_grouping: 'Group 1' })
|
|
373
|
+
|
|
374
|
+
env = { server: 'fe98' }
|
|
375
|
+
parameters = { controller: 'some_controller' }
|
|
376
|
+
session = { username: 'smith' }
|
|
377
|
+
request_uri = "host/path"
|
|
378
|
+
controller = create_dummy_controller(env, parameters, session, request_uri)
|
|
379
|
+
exception_info = ExceptionInfo.new(@exception, @exception_context, @timestamp, controller: controller)
|
|
380
|
+
|
|
381
|
+
expect(exception_info.controller_name).to eq('Group 1')
|
|
382
|
+
end
|
|
383
|
+
|
|
364
384
|
it "return controller_name when controller is present" do
|
|
365
385
|
env = { server: 'fe98' }
|
|
366
386
|
parameters = { controller: 'some_controller' }
|
|
@@ -117,7 +117,7 @@ describe ExceptionHandling do
|
|
|
117
117
|
before { @original_logger = ExceptionHandling.logger }
|
|
118
118
|
after { ExceptionHandling.logger = @original_logger }
|
|
119
119
|
|
|
120
|
-
it "
|
|
120
|
+
it "stores logger as-is if it has ContextualLogger::Mixin" do
|
|
121
121
|
logger = Logger.new('/dev/null')
|
|
122
122
|
logger.extend(ContextualLogger::LoggerMixin)
|
|
123
123
|
ancestors = logger.singleton_class.ancestors.*.name
|
|
@@ -126,33 +126,33 @@ describe ExceptionHandling do
|
|
|
126
126
|
expect(ExceptionHandling.logger.singleton_class.ancestors.*.name).to eq(ancestors)
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
it "
|
|
129
|
+
it "allows logger = nil (no deprecation warning)" do
|
|
130
130
|
expect(STDERR).to receive(:puts).with(/DEPRECATION WARNING/).never
|
|
131
131
|
ExceptionHandling.logger = nil
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
it "[deprecated]
|
|
134
|
+
it "[deprecated] mixes in ContextualLogger::Mixin if not there" do
|
|
135
135
|
expect(STDERR).to receive(:puts).with(/DEPRECATION WARNING: implicit extend with ContextualLogger::LoggerMixin is deprecated and will be removed from exception_handling 3\.0/)
|
|
136
136
|
logger = Logger.new('/dev/null')
|
|
137
137
|
ancestors = logger.singleton_class.ancestors.*.name
|
|
138
138
|
|
|
139
139
|
ExceptionHandling.logger = logger
|
|
140
|
-
expect(ExceptionHandling.logger.singleton_class.ancestors.*.name).to_not eq(ancestors)
|
|
141
140
|
expect(ExceptionHandling.logger).to be_kind_of(ContextualLogger::LoggerMixin)
|
|
141
|
+
expect(ExceptionHandling.logger.singleton_class.ancestors.*.name).to_not eq(ancestors)
|
|
142
142
|
end
|
|
143
|
-
end
|
|
144
143
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
context "#log_error" do
|
|
145
|
+
it "takes in additional logging context hash and pass it to the logger" do
|
|
146
|
+
ExceptionHandling.log_error('This is an Error', 'This is the prefix context', service_name: 'exception_handling')
|
|
147
|
+
expect(logged_excluding_reload_filter.last[:message]).to match(/This is an Error/)
|
|
148
|
+
expect(logged_excluding_reload_filter.last[:context]).to_not be_empty
|
|
149
|
+
expect(service_name: 'exception_handling').to eq(logged_excluding_reload_filter.last[:context])
|
|
150
|
+
end
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
it "logs with Severity::FATAL" do
|
|
153
|
+
ExceptionHandling.log_error('This is a Warning', service_name: 'exception_handling')
|
|
154
|
+
expect('FATAL').to eq(logged_excluding_reload_filter.last[:severity])
|
|
155
|
+
end
|
|
156
156
|
end
|
|
157
157
|
end
|
|
158
158
|
|
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.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionmailer
|
|
@@ -84,6 +84,20 @@ dependencies:
|
|
|
84
84
|
- - "~>"
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
86
|
version: '0.7'
|
|
87
|
+
- !ruby/object:Gem::Dependency
|
|
88
|
+
name: escalate
|
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - "~>"
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0.2'
|
|
94
|
+
type: :runtime
|
|
95
|
+
prerelease: false
|
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - "~>"
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0.2'
|
|
87
101
|
- !ruby/object:Gem::Dependency
|
|
88
102
|
name: eventmachine
|
|
89
103
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -139,6 +153,7 @@ files:
|
|
|
139
153
|
- gemfiles/rails_5.gemfile
|
|
140
154
|
- gemfiles/rails_6.gemfile
|
|
141
155
|
- lib/exception_handling.rb
|
|
156
|
+
- lib/exception_handling/escalate_callback.rb
|
|
142
157
|
- lib/exception_handling/exception_catalog.rb
|
|
143
158
|
- lib/exception_handling/exception_description.rb
|
|
144
159
|
- lib/exception_handling/exception_info.rb
|
|
@@ -154,6 +169,7 @@ files:
|
|
|
154
169
|
- spec/helpers/exception_helpers.rb
|
|
155
170
|
- spec/rake_test_warning_false.rb
|
|
156
171
|
- spec/spec_helper.rb
|
|
172
|
+
- spec/unit/exception_handling/escalate_callback_spec.rb
|
|
157
173
|
- spec/unit/exception_handling/exception_catalog_spec.rb
|
|
158
174
|
- spec/unit/exception_handling/exception_description_spec.rb
|
|
159
175
|
- spec/unit/exception_handling/exception_info_spec.rb
|
|
@@ -172,7 +188,7 @@ licenses: []
|
|
|
172
188
|
metadata:
|
|
173
189
|
source_code_uri: https://github.com/Invoca/exception_handling
|
|
174
190
|
allowed_push_host: https://rubygems.org
|
|
175
|
-
post_install_message:
|
|
191
|
+
post_install_message:
|
|
176
192
|
rdoc_options: []
|
|
177
193
|
require_paths:
|
|
178
194
|
- lib
|
|
@@ -188,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
188
204
|
version: '0'
|
|
189
205
|
requirements: []
|
|
190
206
|
rubygems_version: 3.0.3
|
|
191
|
-
signing_key:
|
|
207
|
+
signing_key:
|
|
192
208
|
specification_version: 4
|
|
193
209
|
summary: Invoca's exception handling logger/emailer layer, based on exception_notifier.
|
|
194
210
|
Works with Rails or EventMachine or EventMachine+Synchrony.
|
|
@@ -197,6 +213,7 @@ test_files:
|
|
|
197
213
|
- spec/helpers/exception_helpers.rb
|
|
198
214
|
- spec/rake_test_warning_false.rb
|
|
199
215
|
- spec/spec_helper.rb
|
|
216
|
+
- spec/unit/exception_handling/escalate_callback_spec.rb
|
|
200
217
|
- spec/unit/exception_handling/exception_catalog_spec.rb
|
|
201
218
|
- spec/unit/exception_handling/exception_description_spec.rb
|
|
202
219
|
- spec/unit/exception_handling/exception_info_spec.rb
|