exception_handling 2.16.0 → 3.0.pre.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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -3
  3. data/.ruby-version +1 -1
  4. data/Gemfile +16 -12
  5. data/Gemfile.lock +114 -109
  6. data/README.md +21 -61
  7. data/Rakefile +11 -8
  8. data/exception_handling.gemspec +10 -12
  9. data/lib/exception_handling/exception_info.rb +11 -15
  10. data/lib/exception_handling/honeybadger_callbacks.rb +59 -0
  11. data/lib/exception_handling/log_stub_error.rb +1 -2
  12. data/lib/exception_handling/methods.rb +53 -6
  13. data/lib/exception_handling/testing.rb +10 -20
  14. data/lib/exception_handling/version.rb +1 -1
  15. data/lib/exception_handling.rb +34 -95
  16. data/semaphore_ci/setup.sh +3 -0
  17. data/{spec → test}/helpers/exception_helpers.rb +2 -2
  18. data/{spec/spec_helper.rb → test/test_helper.rb} +42 -63
  19. data/test/unit/exception_handling/exception_catalog_test.rb +85 -0
  20. data/test/unit/exception_handling/exception_description_test.rb +82 -0
  21. data/{spec/unit/exception_handling/exception_info_spec.rb → test/unit/exception_handling/exception_info_test.rb} +114 -170
  22. data/test/unit/exception_handling/honeybadger_callbacks_test.rb +122 -0
  23. data/{spec/unit/exception_handling/log_error_stub_spec.rb → test/unit/exception_handling/log_error_stub_test.rb} +22 -38
  24. data/{spec/unit/exception_handling/mailer_spec.rb → test/unit/exception_handling/mailer_test.rb} +18 -17
  25. data/test/unit/exception_handling/methods_test.rb +84 -0
  26. data/test/unit/exception_handling/sensu_test.rb +52 -0
  27. data/test/unit/exception_handling_test.rb +1109 -0
  28. metadata +60 -100
  29. data/.github/CODEOWNERS +0 -1
  30. data/.github/workflows/pipeline.yml +0 -40
  31. data/.rspec +0 -3
  32. data/.tool-versions +0 -1
  33. data/Appraisals +0 -19
  34. data/CHANGELOG.md +0 -136
  35. data/gemfiles/rails_5.gemfile +0 -18
  36. data/gemfiles/rails_6.gemfile +0 -18
  37. data/gemfiles/rails_7.gemfile +0 -18
  38. data/lib/exception_handling/escalate_callback.rb +0 -19
  39. data/lib/exception_handling/logging_methods.rb +0 -27
  40. data/spec/rake_test_warning_false.rb +0 -20
  41. data/spec/unit/exception_handling/escalate_callback_spec.rb +0 -81
  42. data/spec/unit/exception_handling/exception_catalog_spec.rb +0 -85
  43. data/spec/unit/exception_handling/exception_description_spec.rb +0 -82
  44. data/spec/unit/exception_handling/logging_methods_spec.rb +0 -38
  45. data/spec/unit/exception_handling/methods_spec.rb +0 -105
  46. data/spec/unit/exception_handling/sensu_spec.rb +0 -51
  47. data/spec/unit/exception_handling_spec.rb +0 -1361
  48. /data/{spec → test}/helpers/controller_helpers.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 71ab070f1ab59f2f12838fb7d123fa541a71a8bb42fe0d057f06acb015bf32a2
4
- data.tar.gz: 1c268f42c4a302c88b98411890db5a4870d31bb96ca712e0f6463ba6629f188a
2
+ SHA1:
3
+ metadata.gz: 6aee76b81d1d4742150afdeb95f8a6f544671a3f
4
+ data.tar.gz: 4822461573c54709a2d977b82e47de35cecfa51e
5
5
  SHA512:
6
- metadata.gz: f571e8c9dd62c70eba4b01c917af6c4715e3d4750900fec8ad7e4a3d5c67fc30ddc299c1456b48adef17c74a3860769806fd0df4e410cb5180c3f778e58c1aad
7
- data.tar.gz: 98f1596f0a95e1591a768b23574c76e4b4039b54a7bb95f07b4f6d41d40336bae360b7ce76750cc5fec7d9c1a64c78ffc4c72d15b88b4924734bab228bb30c94
6
+ metadata.gz: de1c0ab7cb7e7a493ce5f8c8d155ad98450edc891636e2d8e9d82ec2d8bdc312b45ba96f5902e0bc2d70adb35c0e4e20317bbea7d72d54625d7c2764ac2fb374
7
+ data.tar.gz: 7546dd2be9a2701d360cdd5fee3ea0e93b9a26e0072c835940659d5244c0e625743924cdde737fee08a7d5f909d03df1752b8e9ae6b8a7d354b62a77d8b89a57
data/.gitignore CHANGED
@@ -1,6 +1,3 @@
1
1
  .idea
2
2
  .DS_Store
3
3
  .rubocop-http*
4
- spec/reports/*
5
- gemfiles/*.lock
6
- pkg/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.5
1
+ 2.4.2
data/Gemfile CHANGED
@@ -2,17 +2,21 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # Specify your gem's dependencies in attr_default.gemspec
5
6
  gemspec
6
7
 
7
- gem 'actionmailer', '~> 6.0'
8
- gem 'actionpack', '~> 6.0'
9
- gem 'activesupport', '~> 6.0'
10
- gem 'appraisal', '~> 2.2'
11
- gem 'honeybadger', '~> 4.11'
12
- gem 'pry'
13
- gem 'pry-byebug'
14
- gem 'rake'
15
- gem 'rspec'
16
- gem 'rspec_junit_formatter'
17
- gem 'rubocop'
18
- gem 'test-unit'
8
+ gem 'actionmailer', '>= 4.2.11.1'
9
+ gem 'actionpack', '>= 4.2.11.1'
10
+ gem 'activesupport', '>= 4.2.11.1'
11
+
12
+ group :development do
13
+ gem 'pry'
14
+ gem 'rake', '>=0.9'
15
+ gem 'rr'
16
+ gem 'rubocop'
17
+ gem 'shoulda', '> 3.1.1'
18
+ end
19
+
20
+ group :test do
21
+ gem 'honeybadger', '3.3.1-1', git: 'git@github.com:Invoca/honeybadger-ruby', ref: 'bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6'
22
+ end
data/Gemfile.lock CHANGED
@@ -1,127 +1,126 @@
1
+ GIT
2
+ remote: git@github.com:Invoca/honeybadger-ruby
3
+ revision: bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6
4
+ ref: bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6
5
+ specs:
6
+ honeybadger (3.3.1.pre.1)
7
+
1
8
  PATH
2
9
  remote: .
3
10
  specs:
4
- exception_handling (2.16.0)
5
- actionmailer (>= 5.2)
6
- actionpack (>= 5.2)
7
- activesupport (>= 5.2)
8
- contextual_logger (~> 1.0)
9
- escalate (~> 0.3)
11
+ exception_handling (3.0.pre.1)
12
+ actionmailer (~> 4.2)
13
+ actionpack (~> 4.2)
14
+ activesupport (~> 4.2)
15
+ contextual_logger
10
16
  eventmachine (~> 1.0)
11
- invoca-utils (~> 0.3)
12
- net-smtp
13
- psych (~> 3.0)
17
+ hobo_support
18
+ invoca-utils (~> 0.0)
14
19
 
15
20
  GEM
16
21
  remote: https://rubygems.org/
17
22
  specs:
18
- actionmailer (6.0.4.7)
19
- actionpack (= 6.0.4.7)
20
- actionview (= 6.0.4.7)
21
- activejob (= 6.0.4.7)
23
+ actionmailer (4.2.11.1)
24
+ actionpack (= 4.2.11.1)
25
+ actionview (= 4.2.11.1)
26
+ activejob (= 4.2.11.1)
22
27
  mail (~> 2.5, >= 2.5.4)
23
- rails-dom-testing (~> 2.0)
24
- actionpack (6.0.4.7)
25
- actionview (= 6.0.4.7)
26
- activesupport (= 6.0.4.7)
27
- rack (~> 2.0, >= 2.0.8)
28
- rack-test (>= 0.6.3)
29
- rails-dom-testing (~> 2.0)
30
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
31
- actionview (6.0.4.7)
32
- activesupport (= 6.0.4.7)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ actionpack (4.2.11.1)
30
+ actionview (= 4.2.11.1)
31
+ activesupport (= 4.2.11.1)
32
+ rack (~> 1.6)
33
+ rack-test (~> 0.6.2)
34
+ rails-dom-testing (~> 1.0, >= 1.0.5)
35
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
36
+ actionview (4.2.11.1)
37
+ activesupport (= 4.2.11.1)
38
+ builder (~> 3.1)
39
+ erubis (~> 2.7.0)
40
+ rails-dom-testing (~> 1.0, >= 1.0.5)
41
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
42
+ activejob (4.2.11.1)
43
+ activesupport (= 4.2.11.1)
44
+ globalid (>= 0.3.0)
45
+ activemodel (4.2.11.1)
46
+ activesupport (= 4.2.11.1)
33
47
  builder (~> 3.1)
34
- erubi (~> 1.4)
35
- rails-dom-testing (~> 2.0)
36
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
37
- activejob (6.0.4.7)
38
- activesupport (= 6.0.4.7)
39
- globalid (>= 0.3.6)
40
- activesupport (6.0.4.7)
41
- concurrent-ruby (~> 1.0, >= 1.0.2)
42
- i18n (>= 0.7, < 2)
48
+ activerecord (4.2.11.1)
49
+ activemodel (= 4.2.11.1)
50
+ activesupport (= 4.2.11.1)
51
+ arel (~> 6.0)
52
+ activesupport (4.2.11.1)
53
+ i18n (~> 0.7)
43
54
  minitest (~> 5.1)
55
+ thread_safe (~> 0.3, >= 0.3.4)
44
56
  tzinfo (~> 1.1)
45
- zeitwerk (~> 2.2, >= 2.2.2)
46
- appraisal (2.2.0)
47
- bundler
48
- rake
49
- thor (>= 0.14.0)
57
+ arel (6.0.4)
50
58
  ast (2.4.0)
51
- builder (3.2.4)
52
- byebug (11.1.3)
59
+ builder (3.2.3)
53
60
  coderay (1.1.2)
54
- concurrent-ruby (1.1.10)
55
- contextual_logger (1.1.1)
61
+ concurrent-ruby (1.1.5)
62
+ contextual_logger (0.3.1)
56
63
  activesupport
57
64
  json
58
- crass (1.0.6)
59
- diff-lcs (1.5.0)
60
- erubi (1.10.0)
61
- escalate (0.3.0)
65
+ crass (1.0.4)
66
+ erubis (2.7.0)
62
67
  eventmachine (1.2.7)
63
- globalid (1.0.0)
64
- activesupport (>= 5.0)
65
- honeybadger (4.11.0)
66
- i18n (1.10.0)
68
+ globalid (0.4.2)
69
+ activesupport (>= 4.2.0)
70
+ hobo_support (2.2.6)
71
+ rails (~> 4.2.6)
72
+ i18n (0.9.5)
67
73
  concurrent-ruby (~> 1.0)
68
- invoca-utils (0.5.1)
69
- activesupport (>= 5.0)
74
+ invoca-utils (0.0.5)
70
75
  jaro_winkler (1.5.3)
71
- json (2.6.3)
72
- loofah (2.15.0)
76
+ json (2.3.0)
77
+ loofah (2.2.3)
73
78
  crass (~> 1.0.2)
74
79
  nokogiri (>= 1.5.9)
75
80
  mail (2.7.1)
76
81
  mini_mime (>= 0.1.1)
77
82
  method_source (0.9.2)
78
- mini_mime (1.1.2)
79
- mini_portile2 (2.8.0)
80
- minitest (5.15.0)
81
- net-protocol (0.2.1)
82
- timeout
83
- net-smtp (0.3.3)
84
- net-protocol
85
- nokogiri (1.13.3)
86
- mini_portile2 (~> 2.8.0)
87
- racc (~> 1.4)
83
+ mini_mime (1.0.1)
84
+ mini_portile2 (2.4.0)
85
+ minitest (5.11.3)
86
+ nokogiri (1.10.4)
87
+ mini_portile2 (~> 2.4.0)
88
88
  parallel (1.17.0)
89
89
  parser (2.6.3.0)
90
90
  ast (~> 2.4.0)
91
- power_assert (1.2.0)
92
91
  pry (0.12.2)
93
92
  coderay (~> 1.1.0)
94
93
  method_source (~> 0.9.0)
95
- pry-byebug (3.8.0)
96
- byebug (~> 11.0)
97
- pry (~> 0.10)
98
- psych (3.3.4)
99
- racc (1.6.0)
100
- rack (2.2.3)
101
- rack-test (1.1.0)
102
- rack (>= 1.0, < 3)
103
- rails-dom-testing (2.0.3)
104
- activesupport (>= 4.2.0)
105
- nokogiri (>= 1.6)
106
- rails-html-sanitizer (1.4.2)
107
- loofah (~> 2.3)
94
+ rack (1.6.11)
95
+ rack-test (0.6.3)
96
+ rack (>= 1.0)
97
+ rails (4.2.11.1)
98
+ actionmailer (= 4.2.11.1)
99
+ actionpack (= 4.2.11.1)
100
+ actionview (= 4.2.11.1)
101
+ activejob (= 4.2.11.1)
102
+ activemodel (= 4.2.11.1)
103
+ activerecord (= 4.2.11.1)
104
+ activesupport (= 4.2.11.1)
105
+ bundler (>= 1.3.0, < 2.0)
106
+ railties (= 4.2.11.1)
107
+ sprockets-rails
108
+ rails-deprecated_sanitizer (1.0.3)
109
+ activesupport (>= 4.2.0.alpha)
110
+ rails-dom-testing (1.0.9)
111
+ activesupport (>= 4.2.0, < 5.0)
112
+ nokogiri (~> 1.6)
113
+ rails-deprecated_sanitizer (>= 1.0.1)
114
+ rails-html-sanitizer (1.0.4)
115
+ loofah (~> 2.2, >= 2.2.2)
116
+ railties (4.2.11.1)
117
+ actionpack (= 4.2.11.1)
118
+ activesupport (= 4.2.11.1)
119
+ rake (>= 0.8.7)
120
+ thor (>= 0.18.1, < 2.0)
108
121
  rainbow (3.0.0)
109
- rake (13.0.1)
110
- rspec (3.9.0)
111
- rspec-core (~> 3.9.0)
112
- rspec-expectations (~> 3.9.0)
113
- rspec-mocks (~> 3.9.0)
114
- rspec-core (3.9.2)
115
- rspec-support (~> 3.9.3)
116
- rspec-expectations (3.9.2)
117
- diff-lcs (>= 1.2.0, < 2.0)
118
- rspec-support (~> 3.9.0)
119
- rspec-mocks (3.9.1)
120
- diff-lcs (>= 1.2.0, < 2.0)
121
- rspec-support (~> 3.9.0)
122
- rspec-support (3.9.4)
123
- rspec_junit_formatter (0.4.1)
124
- rspec-core (>= 2, < 4, != 2.12.0)
122
+ rake (12.3.2)
123
+ rr (1.2.1)
125
124
  rubocop (0.74.0)
126
125
  jaro_winkler (~> 1.5.1)
127
126
  parallel (~> 1.10)
@@ -130,33 +129,39 @@ GEM
130
129
  ruby-progressbar (~> 1.7)
131
130
  unicode-display_width (>= 1.4.0, < 1.7)
132
131
  ruby-progressbar (1.10.1)
133
- test-unit (3.3.6)
134
- power_assert
132
+ shoulda (3.6.0)
133
+ shoulda-context (~> 1.0, >= 1.0.1)
134
+ shoulda-matchers (~> 3.0)
135
+ shoulda-context (1.2.2)
136
+ shoulda-matchers (3.1.3)
137
+ activesupport (>= 4.0.0)
138
+ sprockets (3.7.2)
139
+ concurrent-ruby (~> 1.0)
140
+ rack (> 1, < 3)
141
+ sprockets-rails (3.2.1)
142
+ actionpack (>= 4.0)
143
+ activesupport (>= 4.0)
144
+ sprockets (>= 3.0.0)
135
145
  thor (1.0.1)
136
146
  thread_safe (0.3.6)
137
- timeout (0.3.2)
138
- tzinfo (1.2.9)
147
+ tzinfo (1.2.5)
139
148
  thread_safe (~> 0.1)
140
149
  unicode-display_width (1.6.0)
141
- zeitwerk (2.5.4)
142
150
 
143
151
  PLATFORMS
144
152
  ruby
145
153
 
146
154
  DEPENDENCIES
147
- actionmailer (~> 6.0)
148
- actionpack (~> 6.0)
149
- activesupport (~> 6.0)
150
- appraisal (~> 2.2)
155
+ actionmailer (>= 4.2.11.1)
156
+ actionpack (>= 4.2.11.1)
157
+ activesupport (>= 4.2.11.1)
151
158
  exception_handling!
152
- honeybadger (~> 4.11)
159
+ honeybadger (= 3.3.1.pre.1)!
153
160
  pry
154
- pry-byebug
155
- rake
156
- rspec
157
- rspec_junit_formatter
161
+ rake (>= 0.9)
162
+ rr
158
163
  rubocop
159
- test-unit
164
+ shoulda (> 3.1.1)
160
165
 
161
166
  BUNDLED WITH
162
- 2.3.22
167
+ 1.17.2
data/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  Enable emails for your exceptions that occur in your application!
4
4
 
5
- ## Dependencies
6
- - Ruby 2.6
7
- - Rails >= 4.2, < 7
8
-
9
5
  ## Installation
10
6
 
11
7
  Add this line to your application's Gemfile:
@@ -25,26 +21,24 @@ Or install it yourself as:
25
21
  Add some code to initialize the settings in your application.
26
22
  For example:
27
23
 
28
- ```ruby
29
- require "exception_handling"
30
-
31
- # required
32
- ExceptionHandling.server_name = Cluster['server_name']
33
- ExceptionHandling.sender_address = %("Exceptions" <exceptions@example.com>)
34
- ExceptionHandling.exception_recipients = ['exceptions@example.com']
35
- ExceptionHandling.logger = Rails.logger
36
-
37
- # optional
38
- ExceptionHandling.escalation_recipients = ['escalation@example.com']
39
- ExceptionHandling.filter_list_filename = "#{Rails.root}/config/exception_filters.yml"
40
- ExceptionHandling.email_environment = Rails.env
41
- ExceptionHandling.eventmachine_safe = false
42
- ExceptionHandling.eventmachine_synchrony = false
43
- ExceptionHandling.sensu_host = "127.0.0.1"
44
- ExceptionHandling.sensu_port = 3030
45
- ExceptionHandling.sensu_prefix = ""
46
- ExceptionHandling.honeybadger_auto_tagger = ->(exception) { [] } # See "Automatically Tagging Exceptions" section below for examples
47
- ```
24
+ require "exception_handling"
25
+
26
+ # required
27
+ ExceptionHandling.server_name = Cluster['server_name']
28
+ ExceptionHandling.sender_address = %("Exceptions" <exceptions@example.com>)
29
+ ExceptionHandling.exception_recipients = ['exceptions@example.com']
30
+ ExceptionHandling.logger = Rails.logger
31
+
32
+ # optional
33
+ ExceptionHandling.escalation_recipients = ['escalation@example.com']
34
+ ExceptionHandling.filter_list_filename = "#{Rails.root}/config/exception_filters.yml"
35
+ ExceptionHandling.email_environment = Rails.env
36
+ ExceptionHandling.eventmachine_safe = false
37
+ ExceptionHandling.eventmachine_synchrony = false
38
+ ExceptionHandling.sensu_host = "127.0.0.1"
39
+ ExceptionHandling.sensu_port = 3030
40
+ ExceptionHandling.sensu_prefix = ""
41
+
48
42
 
49
43
  ## Usage
50
44
 
@@ -64,40 +58,6 @@ Then call any method available in the `ExceptionHandling::Methods` mixin:
64
58
  flash.now['error'] = "A specific error occurred. Support has been notified."
65
59
  end
66
60
 
67
- ### Tagging Exceptions in Honeybadger
68
-
69
- ⚠️ Honeybadger differentiates tags by spaces and/or commas, so you should **not** include spaces or commas in your tags.
70
-
71
- ⚠️ Tags are case-sensitive.
72
-
73
- #### Manually Tagging Exceptions
74
-
75
- Add `:honeybadger_tags` to your `log_context` usage with an array of strings.
76
-
77
- ```ruby
78
- log_error(ex, "A specific error occurred.", honeybadger_tags: ["critical", "sequoia"])
79
- ```
80
-
81
- **Note**: Manual tags will be merged with any automatic tags.
82
-
83
- #### Automatically Tagging Exceptions (`honeybadger_auto_tagger=`)
84
-
85
- Configure exception handling so that you can automatically apply multiple tags to exceptions sent to honeybadger.
86
-
87
- The Proc must accept an `exception` argument that will be the exception in question and must always return an array of strings (the array can be empty).
88
-
89
- Example to enable auto-tagging:
90
- ```ruby
91
- ExceptionHandling.honeybadger_auto_tagger = ->(exception) do
92
- exception.message.match?(/fire/) ? ["high-urgency", "danger"] : ["low-urgency"]
93
- end
94
- ```
95
-
96
- Example to disable auto-tagging:
97
- ```ruby
98
- ExceptionHandling.honeybadger_auto_tagger = nil
99
- ```
100
-
101
61
  ## Custom Hooks
102
62
 
103
63
  ### custom_data_hook
@@ -129,15 +89,15 @@ There is another hook available intended for custom actions after an error email
129
89
  else
130
90
  Invoca::Metrics::Client.metrics.counter("exception_handling/exception")
131
91
  end
132
-
92
+
133
93
  case honeybadger_status
134
94
  when :success
135
95
  Invoca::Metrics::Client.metrics.counter("exception_handling.honeybadger.success")
136
- when :failure
96
+ when :failure
137
97
  Invoca::Metrics::Client.metrics.counter("exception_handling.honeybadger.failure")
138
98
  when :skipped
139
99
  Invoca::Metrics::Client.metrics.counter("exception_handling.honeybadger.skipped")
140
- end
100
+ end
141
101
  end
142
102
  ExceptionHandling.post_log_error_hook = method(:log_error_metrics)
143
103
 
data/Rakefile CHANGED
@@ -1,15 +1,18 @@
1
1
  #!/usr/bin/env rake
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'rake/testtask'
5
4
  require "bundler/gem_tasks"
5
+ require 'rake/testtask'
6
6
 
7
- require_relative 'spec/rake_test_warning_false'
8
-
9
- desc "run rspec unit tests"
10
- begin
11
- require 'rspec/core/rake_task'
12
- RSpec::Core::RakeTask.new(:rspec)
7
+ namespace :test do
8
+ Rake::TestTask.new do |t|
9
+ t.name = :unit
10
+ t.libs << "test"
11
+ t.pattern = 'test/unit/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+ Rake::Task['test:unit'].comment = "Run the unit tests"
13
15
  end
14
16
 
15
- task default: :rspec
17
+ task test: 'test:unit'
18
+ task default: 'test'
@@ -3,13 +3,13 @@
3
3
  require File.expand_path('lib/exception_handling/version', __dir__)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.authors = ["Invoca"]
7
- spec.email = ["development@invoca.com"]
6
+ spec.authors = ["Colin Kelley"]
7
+ spec.email = ["colindkelley@gmail.com"]
8
8
  spec.description = 'Exception handling logger/emailer'
9
9
  spec.summary = "Invoca's exception handling logger/emailer layer, based on exception_notifier. Works with Rails or EventMachine or EventMachine+Synchrony."
10
10
  spec.homepage = "https://github.com/Invoca/exception_handling"
11
11
 
12
- spec.files = `git ls-files`.split("\n")
12
+ spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
13
13
  spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/.*\.rb})
15
15
  spec.name = "exception_handling"
@@ -20,13 +20,11 @@ Gem::Specification.new do |spec|
20
20
  "allowed_push_host" => "https://rubygems.org"
21
21
  }
22
22
 
23
- spec.add_dependency 'actionmailer', '>= 5.2'
24
- spec.add_dependency 'actionpack', '>= 5.2'
25
- spec.add_dependency 'activesupport', '>= 5.2'
26
- spec.add_dependency 'contextual_logger', '~> 1.0'
27
- spec.add_dependency 'escalate', '~> 0.3'
28
- spec.add_dependency 'eventmachine', '~> 1.0'
29
- spec.add_dependency 'invoca-utils', '~> 0.3'
30
- spec.add_dependency 'psych', '~> 3.0'
31
- spec.add_dependency 'net-smtp'
23
+ spec.add_dependency 'actionmailer', '~> 4.2'
24
+ spec.add_dependency 'actionpack', '~> 4.2'
25
+ spec.add_dependency 'activesupport', '~> 4.2'
26
+ spec.add_dependency 'contextual_logger'
27
+ spec.add_dependency 'eventmachine', '~> 1.0'
28
+ spec.add_dependency 'hobo_support'
29
+ spec.add_dependency 'invoca-utils', '~> 0.0'
32
30
  end
@@ -3,7 +3,7 @@
3
3
  module ExceptionHandling
4
4
  class ExceptionInfo
5
5
 
6
- ENVIRONMENT_ALLOWLIST = [
6
+ ENVIRONMENT_WHITELIST = [
7
7
  /^HTTP_/,
8
8
  /^QUERY_/,
9
9
  /^REQUEST_/,
@@ -46,20 +46,16 @@ module ExceptionHandling
46
46
  EOS
47
47
 
48
48
  SECTIONS = [:request, :session, :environment, :backtrace, :event_response].freeze
49
- HONEYBADGER_CONTEXT_SECTIONS = [:timestamp, :error_class, :exception_context, :server, :scm_revision, :notes,
50
- :user_details, :request, :session, :environment, :backtrace, :event_response, :log_context].freeze
49
+ HONEYBADGER_CONTEXT_SECTIONS = [:timestamp, :error_class, :exception_context, :server, :scm_revision, :notes, :user_details, :request, :session, :environment, :backtrace, :event_response].freeze
51
50
 
52
- attr_reader :exception, :controller, :exception_context, :timestamp, :honeybadger_tags
51
+ attr_reader :exception, :controller, :exception_context, :timestamp
53
52
 
54
- def initialize(exception, exception_context, timestamp, controller: nil, data_callback: nil, log_context: nil)
53
+ def initialize(exception, exception_context, timestamp, controller = nil, data_callback = nil)
55
54
  @exception = exception
56
55
  @exception_context = exception_context
57
56
  @timestamp = timestamp
58
57
  @controller = controller || controller_from_context(exception_context)
59
58
  @data_callback = data_callback
60
- # merge into the surrounding context just like ContextualLogger does when logging
61
- @merged_log_context = ExceptionHandling.logger.current_context_for_thread.deep_merge(log_context || {})
62
- @honeybadger_tags = Array(@merged_log_context[:honeybadger_tags] || [])
63
59
  end
64
60
 
65
61
  def data
@@ -83,10 +79,9 @@ module ExceptionHandling
83
79
  end
84
80
 
85
81
  def controller_name
86
- @controller_name ||= (
87
- @merged_log_context[:honeybadger_grouping] ||
88
- (@controller && @controller.request.parameters.with_indifferent_access[:controller])
89
- ).to_s
82
+ @controller_name ||= if @controller
83
+ @controller.request.parameters.with_indifferent_access[:controller]
84
+ end.to_s
90
85
  end
91
86
 
92
87
  private
@@ -181,7 +176,7 @@ module ExceptionHandling
181
176
 
182
177
  def clean_environment(env)
183
178
  Hash[ env.map do |k, v|
184
- [k, v] if !"#{k}: #{v}".in?(ENVIRONMENT_OMIT) && ENVIRONMENT_ALLOWLIST.any? { |regex| k =~ regex }
179
+ [k, v] if !"#{k}: #{v}".in?(ENVIRONMENT_OMIT) && ENVIRONMENT_WHITELIST.any? { |regex| k =~ regex }
185
180
  end.compact ]
186
181
  end
187
182
 
@@ -272,13 +267,14 @@ module ExceptionHandling
272
267
  data = enhanced_data.dup
273
268
  data[:server] = ExceptionHandling.server_name
274
269
  data[:exception_context] = deep_clean_hash(@exception_context) if @exception_context.present?
275
- data[:log_context] = @merged_log_context
276
270
  unstringify_sections(data)
277
- HONEYBADGER_CONTEXT_SECTIONS.each_with_object({}) do |section, context|
271
+ context_data = HONEYBADGER_CONTEXT_SECTIONS.reduce({}) do |context, section|
278
272
  if data[section].present?
279
273
  context[section] = data[section]
280
274
  end
275
+ context
281
276
  end
277
+ context_data
282
278
  end
283
279
  end
284
280
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExceptionHandling
4
+ module HoneybadgerCallbacks
5
+ class << self
6
+ def register_callbacks
7
+ if ExceptionHandling.honeybadger_defined?
8
+ Honeybadger.local_variable_filter(&method(:local_variable_filter))
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def inspect_object(object, filter_keys)
15
+ inspection_output = object.inspect
16
+
17
+ if contains_filter_key?(filter_keys, inspection_output)
18
+ filtered_object(object)
19
+ else
20
+ inspection_output
21
+ end
22
+ rescue => ex
23
+ details = if object.respond_to?(:to_pk)
24
+ " @pk=#{object.to_pk}"
25
+ elsif object.respond_to?(:id)
26
+ " @id=#{object.id}"
27
+ end
28
+
29
+ "#<#{object.class.name}#{details} [error '#{ex.class.name}: #{ex.message}' while calling #inspect]>"
30
+ end
31
+
32
+ def local_variable_filter(_symbol, object, filter_keys)
33
+ case object
34
+ # Honeybadger will filter these data types for us
35
+ when String, Hash, Array, Set, Numeric, TrueClass, FalseClass, NilClass
36
+ object
37
+ else # handle other Ruby objects, intended for POROs
38
+ inspect_object(object, filter_keys)
39
+ end
40
+ end
41
+
42
+ def contains_filter_key?(filter_keys, string)
43
+ filter_keys._?.any? { |key| string.include?(key) }
44
+ end
45
+
46
+ def filtered_object(object)
47
+ # make the output look similar to inspect
48
+ # use [FILTERED], just like honeybadger does
49
+ if object.respond_to?(:to_pk)
50
+ "#<#{object.class.name} @pk=#{object.to_pk}, [FILTERED]>"
51
+ elsif object.respond_to?(:id)
52
+ "#<#{object.class.name} @id=#{object.id}, [FILTERED]>"
53
+ else
54
+ "#<#{object.class.name} [FILTERED]>"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Test Helper that supports Minitest::Test and Test::Unit
5
- # Used by tests in the consumers of this gem to track exceptions.
4
+ # Used by functional tests to track exceptions.
6
5
  #
7
6
 
8
7
  module LogErrorStub