exception_notification 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Appraisals +3 -1
- data/CHANGELOG.rdoc +33 -0
- data/Gemfile +2 -0
- data/README.md +36 -13
- data/Rakefile +2 -0
- data/examples/sample_app.rb +2 -0
- data/examples/sinatra/Gemfile +2 -0
- data/examples/sinatra/config.ru +2 -0
- data/examples/sinatra/sinatra_app.rb +6 -2
- data/exception_notification.gemspec +13 -12
- data/gemfiles/rails5_2.gemfile +3 -3
- data/gemfiles/rails6_1.gemfile +7 -0
- data/gemfiles/rails7_0.gemfile +7 -0
- data/lib/exception_notification/rack.rb +24 -13
- data/lib/exception_notification/rails.rb +2 -0
- data/lib/exception_notification/resque.rb +2 -0
- data/lib/exception_notification/sidekiq.rb +5 -3
- data/lib/exception_notification/version.rb +3 -1
- data/lib/exception_notification.rb +2 -0
- data/lib/exception_notifier/base_notifier.rb +8 -2
- data/lib/exception_notifier/datadog_notifier.rb +12 -9
- data/lib/exception_notifier/email_notifier.rb +10 -2
- data/lib/exception_notifier/google_chat_notifier.rb +2 -0
- data/lib/exception_notifier/hipchat_notifier.rb +2 -0
- data/lib/exception_notifier/irc_notifier.rb +4 -3
- data/lib/exception_notifier/mattermost_notifier.rb +10 -0
- data/lib/exception_notifier/modules/backtrace_cleaner.rb +2 -0
- data/lib/exception_notifier/modules/error_grouping.rb +20 -9
- data/lib/exception_notifier/modules/formatter.rb +8 -1
- data/lib/exception_notifier/notifier.rb +5 -1
- data/lib/exception_notifier/slack_notifier.rb +2 -0
- data/lib/exception_notifier/sns_notifier.rb +7 -3
- data/lib/exception_notifier/teams_notifier.rb +10 -3
- data/lib/exception_notifier/webhook_notifier.rb +3 -3
- data/lib/exception_notifier.rb +46 -8
- data/lib/generators/exception_notification/install_generator.rb +8 -2
- data/test/exception_notification/rack_test.rb +48 -2
- data/test/exception_notification/resque_test.rb +2 -0
- data/test/exception_notifier/datadog_notifier_test.rb +2 -0
- data/test/exception_notifier/email_notifier_test.rb +11 -5
- data/test/exception_notifier/google_chat_notifier_test.rb +15 -11
- data/test/exception_notifier/hipchat_notifier_test.rb +8 -2
- data/test/exception_notifier/irc_notifier_test.rb +2 -0
- data/test/exception_notifier/mattermost_notifier_test.rb +73 -24
- data/test/exception_notifier/modules/error_grouping_test.rb +2 -0
- data/test/exception_notifier/modules/formatter_test.rb +2 -0
- data/test/exception_notifier/sidekiq_test.rb +3 -11
- data/test/exception_notifier/slack_notifier_test.rb +12 -10
- data/test/exception_notifier/sns_notifier_test.rb +64 -7
- data/test/exception_notifier/teams_notifier_test.rb +2 -0
- data/test/exception_notifier/webhook_notifier_test.rb +6 -4
- data/test/exception_notifier_test.rb +112 -6
- data/test/support/exception_notifier_helper.rb +14 -0
- data/test/test_helper.rb +5 -1
- metadata +45 -56
- data/gemfiles/rails4_0.gemfile +0 -7
- data/gemfiles/rails4_1.gemfile +0 -7
- data/gemfiles/rails4_2.gemfile +0 -7
- data/gemfiles/rails5_0.gemfile +0 -7
- data/gemfiles/rails5_1.gemfile +0 -7
- data/lib/exception_notifier/campfire_notifier.rb +0 -39
- data/test/exception_notifier/campfire_notifier_test.rb +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f671fa31cec6dbf437c5e31ab10136a00f3ef5450fc13d9de2887296390451ba
|
4
|
+
data.tar.gz: 20f146f16e31e91c456cb08f5598b2714dec47ef1efc41741c7cfea761a8176f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3c4f84bef2faccc2a66306349b983843a1542895d13e8cb141e50e8c610dc525087f8f86fc4c40654140e128c5378b224851c888086b0b32a6cb4753011717e
|
7
|
+
data.tar.gz: 5aa30cabeb47f39f89d13c904bdd36da33bf7a598cdb24f14ff6882e90826e3985b1bfb19c55a250bdfc3edae343ec56a72887a5bdbd195bbe4251738a65d1b2
|
data/Appraisals
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
rails_versions = ['~> 5.2.0', '~> 6.0.0', '~> 6.1.0', '~> 7.0.0']
|
2
4
|
|
3
5
|
rails_versions.each do |rails_version|
|
4
6
|
appraise "rails#{rails_version.slice(/\d+\.\d+/).tr('.', '_')}" do
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
== 4.5.0
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Added Rails 7 compatibility (by @fwininger)
|
5
|
+
* Added support for the optional `data` attribute to the SNS notifier (@TomK32)
|
6
|
+
* Addressed a deprecation warning for `module_parent_name` which was thrown for users
|
7
|
+
using Rails > 6.x (@quorak)
|
8
|
+
* Restored the hash separator for `controller#action` in the email notifier (@garethrees)
|
9
|
+
|
10
|
+
* removals
|
11
|
+
* Dropped support for Tinder (gem is no longer maintained) (by @fwininger)
|
12
|
+
* Dropped support for Ruby on Rails versions below 5.2
|
13
|
+
|
14
|
+
== 4.4.3
|
15
|
+
|
16
|
+
* big fixes
|
17
|
+
* Remove using configured default from address from custom mailer_parent class
|
18
|
+
|
19
|
+
== 4.4.2 (yanked)
|
20
|
+
|
21
|
+
* bug fixes
|
22
|
+
* Fix `sender_address` being overwritten
|
23
|
+
|
24
|
+
== 4.4.1
|
25
|
+
|
26
|
+
* enhancements
|
27
|
+
* Enhance `ignore_if` option to allow by-notifier customization (by @fursich)
|
28
|
+
* Ignore extended modules of ignored exceptions (by @elengine)
|
29
|
+
* Add `exception_data` to Mattermost notifier (by @camillof)
|
30
|
+
|
31
|
+
* bug fixes
|
32
|
+
* Fix Rubocop offenses (by @nicolasferraro)
|
33
|
+
|
1
34
|
== 4.4.0
|
2
35
|
|
3
36
|
* enhancements
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Exception Notification
|
2
2
|
|
3
|
-
[![Gem Version](https://
|
4
|
-
[![
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/smartinez87/exception_notification/badge.
|
6
|
-
[![
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/exception_notification.svg)](https://badge.fury.io/rb/exception_notification)
|
4
|
+
[![Build Status](https://github.com/smartinez87/exception_notification/actions/workflows/main.yml/badge.svg)](https://github.com/smartinez87/exception_notification/actions/workflows/main.yml)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/smartinez87/exception_notification/badge.svg?branch=master)](https://coveralls.io/github/smartinez87/exception_notification?branch=master)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/78a9a12be00a6d305136/maintainability)](https://codeclimate.com/github/smartinez87/exception_notification/maintainability)
|
7
7
|
|
8
8
|
**THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF EXCEPTION NOTIFICATION, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.**
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
|
-
The Exception Notification gem provides a set of [notifiers](#notifiers) for sending notifications when errors occur in a Rack/Rails application. The built-in notifiers can deliver notifications by [email](docs/notifiers/email.md), [
|
12
|
+
The Exception Notification gem provides a set of [notifiers](#notifiers) for sending notifications when errors occur in a Rack/Rails application. The built-in notifiers can deliver notifications by [email](docs/notifiers/email.md), [HipChat](docs/notifiers/hipchat.md), [Slack](docs/notifiers/slack.md), [Mattermost](docs/notifiers/mattermost.md), [Teams](docs/notifiers/teams.md), [IRC](docs/notifiers/irc.md), [Amazon SNS](docs/notifiers/sns.md), [Google Chat](docs/notifiers/google_chat.md), [Datadog](docs/notifiers/datadog.md) or via custom [WebHooks](docs/notifiers/webhook.md).
|
13
13
|
|
14
14
|
There's a great [Railscast about Exception Notification](http://railscasts.com/episodes/104-exception-notifications-revised) you can see that may help you getting started.
|
15
15
|
|
@@ -17,10 +17,8 @@ There's a great [Railscast about Exception Notification](http://railscasts.com/e
|
|
17
17
|
|
18
18
|
## Requirements
|
19
19
|
|
20
|
-
* Ruby 2.
|
21
|
-
* Rails
|
22
|
-
|
23
|
-
For previous releases, please checkout [this](#versions).
|
20
|
+
* Ruby 2.5 or greater
|
21
|
+
* Rails 5.2 or greater, Sinatra or another Rack-based application.
|
24
22
|
|
25
23
|
## Getting Started
|
26
24
|
|
@@ -37,7 +35,6 @@ ExceptionNotification is used as a rack middleware, or in the environment you wa
|
|
37
35
|
```ruby
|
38
36
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
39
37
|
email: {
|
40
|
-
deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now
|
41
38
|
email_prefix: '[PREFIX] ',
|
42
39
|
sender_address: %{"notifier" <notifier@example.com>},
|
43
40
|
exception_recipients: %w{exceptions@example.com}
|
@@ -86,7 +83,6 @@ Options -> sections" below.
|
|
86
83
|
|
87
84
|
ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default, 8 notifiers are available:
|
88
85
|
|
89
|
-
* [Campfire notifier](docs/notifiers/campfire.md)
|
90
86
|
* [Datadog notifier](docs/notifiers/datadog.md)
|
91
87
|
* [Email notifier](docs/notifiers/email.md)
|
92
88
|
* [HipChat notifier](docs/notifiers/hipchat.md)
|
@@ -138,6 +134,8 @@ You can choose to ignore certain exceptions, which will make ExceptionNotificati
|
|
138
134
|
|
139
135
|
* `:ignore_if` - Custom (i.e. ignore exceptions that satisfy some condition)
|
140
136
|
|
137
|
+
* `:ignore_notifer_if` - Custom (i.e. let each notifier ignore exceptions if by-notifier condition is satisfied)
|
138
|
+
|
141
139
|
|
142
140
|
### :ignore_exceptions
|
143
141
|
|
@@ -177,7 +175,7 @@ Rails.application.config.middleware.use ExceptionNotification::Rack,
|
|
177
175
|
|
178
176
|
*Lambda, default: nil*
|
179
177
|
|
180
|
-
|
178
|
+
You can ignore exceptions based on a condition. Take a look:
|
181
179
|
|
182
180
|
```ruby
|
183
181
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
@@ -191,6 +189,32 @@ Rails.application.config.middleware.use ExceptionNotification::Rack,
|
|
191
189
|
|
192
190
|
You can make use of both the environment and the exception inside the lambda to decide wether to avoid or not sending the notification.
|
193
191
|
|
192
|
+
### :ignore_notifier_if
|
193
|
+
|
194
|
+
* Hash of Lambda, default: nil*
|
195
|
+
|
196
|
+
In case you want a notifier to ignore certain exceptions, but don't want other notifiers to skip them, you can set by-notifier ignore options.
|
197
|
+
By setting below, each notifier will ignore exceptions when its corresponding condition is met.
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
201
|
+
ignore_notifier_if: {
|
202
|
+
email: ->(env, exception) { !Rails.env.production? },
|
203
|
+
slack: ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ }
|
204
|
+
}
|
205
|
+
|
206
|
+
email: {
|
207
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
208
|
+
exception_recipients: %w{exceptions@example.com}
|
209
|
+
},
|
210
|
+
slack: {
|
211
|
+
webhook_url: '[Your webhook url]',
|
212
|
+
channel: '#exceptions',
|
213
|
+
}
|
214
|
+
```
|
215
|
+
|
216
|
+
To customize each condition, you can make use of environment and the exception object inside the lambda.
|
217
|
+
|
194
218
|
## Rack X-Cascade Header
|
195
219
|
|
196
220
|
Some rack apps (Rails in particular) utilize the "X-Cascade" header to pass the request-handling responsibility to the next middleware in the stack.
|
@@ -245,7 +269,6 @@ def server_error(exception)
|
|
245
269
|
end
|
246
270
|
```
|
247
271
|
|
248
|
-
|
249
272
|
## Extras
|
250
273
|
|
251
274
|
### Rails
|
data/Rakefile
CHANGED
data/examples/sample_app.rb
CHANGED
data/examples/sinatra/Gemfile
CHANGED
data/examples/sinatra/config.ru
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
require 'bundler/setup'
|
3
5
|
require 'sinatra/base'
|
@@ -5,7 +7,8 @@ require 'exception_notification'
|
|
5
7
|
|
6
8
|
class SinatraApp < Sinatra::Base
|
7
9
|
use Rack::Config do |env|
|
8
|
-
|
10
|
+
# This is highly recommended. It will prevent the ExceptionNotification email from including your users' passwords
|
11
|
+
env['action_dispatch.parameter_filter'] = [:password]
|
9
12
|
end
|
10
13
|
|
11
14
|
use ExceptionNotification::Rack,
|
@@ -22,7 +25,8 @@ class SinatraApp < Sinatra::Base
|
|
22
25
|
get '/' do
|
23
26
|
raise StandardError, "ERROR: #{params[:error]}" unless params[:error].blank?
|
24
27
|
|
25
|
-
'Everything is fine! Now, lets break things clicking <a href="/?error=ops"> here </a>.
|
28
|
+
'Everything is fine! Now, lets break things clicking <a href="/?error=ops"> here </a>.' \
|
29
|
+
'Dont forget to see the emails at <a href="http://localhost:1080">mailcatcher</a> !'
|
26
30
|
end
|
27
31
|
|
28
32
|
get '/background_notification' do
|
@@ -1,16 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/exception_notification/version', __dir__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
4
6
|
s.name = 'exception_notification'
|
5
7
|
s.version = ExceptionNotification::VERSION
|
6
8
|
s.authors = ['Jamis Buck', 'Josh Peek']
|
7
|
-
s.date = '
|
9
|
+
s.date = '2022-01-20'
|
8
10
|
s.summary = 'Exception notification for Rails apps'
|
9
11
|
s.homepage = 'https://smartinez87.github.io/exception_notification/'
|
10
12
|
s.email = 'smartinez87@gmail.com'
|
11
13
|
s.license = 'MIT'
|
12
14
|
|
13
|
-
s.required_ruby_version = '>= 2.
|
15
|
+
s.required_ruby_version = '>= 2.3'
|
14
16
|
s.required_rubygems_version = '>= 1.8.11'
|
15
17
|
|
16
18
|
s.files = `git ls-files`.split("\n")
|
@@ -18,8 +20,8 @@ Gem::Specification.new do |s|
|
|
18
20
|
s.test_files = `git ls-files -- test`.split("\n")
|
19
21
|
s.require_path = 'lib'
|
20
22
|
|
21
|
-
s.add_dependency('actionmailer', '>=
|
22
|
-
s.add_dependency('activesupport', '>=
|
23
|
+
s.add_dependency('actionmailer', '>= 5.2', '< 8')
|
24
|
+
s.add_dependency('activesupport', '>= 5.2', '< 8')
|
23
25
|
|
24
26
|
s.add_development_dependency 'appraisal', '~> 2.2.0'
|
25
27
|
s.add_development_dependency 'aws-sdk-sns', '~> 1'
|
@@ -28,14 +30,13 @@ Gem::Specification.new do |s|
|
|
28
30
|
s.add_development_dependency 'dogapi', '>= 1.23.0'
|
29
31
|
s.add_development_dependency 'hipchat', '>= 1.0.0'
|
30
32
|
s.add_development_dependency 'httparty', '~> 0.10.2'
|
31
|
-
s.add_development_dependency 'mock_redis', '~> 0.18.0'
|
32
33
|
s.add_development_dependency 'mocha', '>= 0.13.0'
|
33
|
-
s.add_development_dependency '
|
34
|
+
s.add_development_dependency 'mock_redis', '~> 0.19.0'
|
35
|
+
s.add_development_dependency 'net-smtp'
|
36
|
+
s.add_development_dependency 'rails', '>= 5.2', '< 8'
|
34
37
|
s.add_development_dependency 'resque', '~> 1.8.0'
|
35
|
-
s.add_development_dependency 'rubocop', '0.
|
36
|
-
|
37
|
-
s.add_development_dependency 'sidekiq', '~> 3.0.0', '< 3.2.2'
|
38
|
+
s.add_development_dependency 'rubocop', '0.78.0'
|
39
|
+
s.add_development_dependency 'sidekiq', '>= 5.0.4'
|
38
40
|
s.add_development_dependency 'slack-notifier', '>= 1.0.0'
|
39
|
-
s.add_development_dependency 'timecop', '~>0.9.0'
|
40
|
-
s.add_development_dependency 'tinder', '~> 1.8'
|
41
|
+
s.add_development_dependency 'timecop', '~> 0.9.0'
|
41
42
|
end
|
data/gemfiles/rails5_2.gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ExceptionNotification
|
2
4
|
class Rack
|
3
5
|
class CascadePassException < RuntimeError; end
|
@@ -5,15 +7,17 @@ module ExceptionNotification
|
|
5
7
|
def initialize(app, options = {})
|
6
8
|
@app = app
|
7
9
|
|
8
|
-
ExceptionNotifier.
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
ExceptionNotifier.tap do |en|
|
11
|
+
en.ignored_exceptions = options.delete(:ignore_exceptions) if options.key?(:ignore_exceptions)
|
12
|
+
en.error_grouping = options.delete(:error_grouping) if options.key?(:error_grouping)
|
13
|
+
en.error_grouping_period = options.delete(:error_grouping_period) if options.key?(:error_grouping_period)
|
14
|
+
en.notification_trigger = options.delete(:notification_trigger) if options.key?(:notification_trigger)
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
if options.key?(:error_grouping_cache)
|
17
|
+
en.error_grouping_cache = options.delete(:error_grouping_cache)
|
18
|
+
elsif defined?(Rails) && Rails.respond_to?(:cache)
|
19
|
+
en.error_grouping_cache = Rails.cache
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
if options.key?(:ignore_if)
|
@@ -23,6 +27,15 @@ module ExceptionNotification
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
30
|
+
if options.key?(:ignore_notifier_if)
|
31
|
+
rack_ignore_by_notifier = options.delete(:ignore_notifier_if)
|
32
|
+
rack_ignore_by_notifier.each do |notifier, proc|
|
33
|
+
ExceptionNotifier.ignore_notifier_if(notifier) do |exception, opts|
|
34
|
+
opts.key?(:env) && proc.call(opts[:env], exception)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
26
39
|
ExceptionNotifier.ignore_crawlers(options.delete(:ignore_crawlers)) if options.key?(:ignore_crawlers)
|
27
40
|
|
28
41
|
@ignore_cascade_pass = options.delete(:ignore_cascade_pass) { true }
|
@@ -42,12 +55,10 @@ module ExceptionNotification
|
|
42
55
|
end
|
43
56
|
|
44
57
|
response
|
45
|
-
rescue Exception =>
|
46
|
-
if ExceptionNotifier.notify_exception(
|
47
|
-
env['exception_notifier.delivered'] = true
|
48
|
-
end
|
58
|
+
rescue Exception => e
|
59
|
+
env['exception_notifier.delivered'] = true if ExceptionNotifier.notify_exception(e, env: env)
|
49
60
|
|
50
|
-
raise
|
61
|
+
raise e unless e.is_a?(CascadePassException)
|
51
62
|
|
52
63
|
response
|
53
64
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sidekiq'
|
2
4
|
|
3
5
|
# Note: this class is only needed for Sidekiq version < 3.
|
@@ -5,9 +7,9 @@ module ExceptionNotification
|
|
5
7
|
class Sidekiq
|
6
8
|
def call(_worker, msg, _queue)
|
7
9
|
yield
|
8
|
-
rescue Exception =>
|
9
|
-
ExceptionNotifier.notify_exception(
|
10
|
-
raise
|
10
|
+
rescue Exception => e
|
11
|
+
ExceptionNotifier.notify_exception(e, data: { sidekiq: msg })
|
12
|
+
raise e
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ExceptionNotifier
|
2
4
|
class BaseNotifier
|
3
5
|
attr_accessor :base_options
|
@@ -14,11 +16,15 @@ module ExceptionNotifier
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def _pre_callback(exception, options, message, message_opts)
|
17
|
-
|
19
|
+
return unless @base_options[:pre_callback].respond_to?(:call)
|
20
|
+
|
21
|
+
@base_options[:pre_callback].call(options, self, exception.backtrace, message, message_opts)
|
18
22
|
end
|
19
23
|
|
20
24
|
def _post_callback(exception, options, message, message_opts)
|
21
|
-
|
25
|
+
return unless @base_options[:post_callback].respond_to?(:call)
|
26
|
+
|
27
|
+
@base_options[:post_callback].call(options, self, exception.backtrace, message, message_opts)
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'action_dispatch'
|
2
4
|
|
3
5
|
module ExceptionNotifier
|
@@ -30,7 +32,7 @@ module ExceptionNotifier
|
|
30
32
|
MAX_TITLE_LENGTH = 120
|
31
33
|
MAX_VALUE_LENGTH = 300
|
32
34
|
MAX_BACKTRACE_SIZE = 3
|
33
|
-
ALERT_TYPE = 'error'
|
35
|
+
ALERT_TYPE = 'error'
|
34
36
|
|
35
37
|
attr_reader :exception,
|
36
38
|
:options
|
@@ -74,11 +76,8 @@ module ExceptionNotifier
|
|
74
76
|
end
|
75
77
|
|
76
78
|
def formatted_title
|
77
|
-
title =
|
78
|
-
|
79
|
-
title << "#{controller.controller_name} #{controller.action_name}" if controller
|
80
|
-
title << " (#{exception.class})"
|
81
|
-
title << " #{exception.message.inspect}"
|
79
|
+
title =
|
80
|
+
"#{title_prefix}#{controller_subtitle} (#{exception.class}) #{exception.message.inspect}"
|
82
81
|
|
83
82
|
truncate(title, MAX_TITLE_LENGTH)
|
84
83
|
end
|
@@ -108,9 +107,7 @@ module ExceptionNotifier
|
|
108
107
|
text << formatted_key_value('Parameters', request.filtered_parameters.inspect)
|
109
108
|
text << formatted_key_value('Timestamp', Time.current)
|
110
109
|
text << formatted_key_value('Server', Socket.gethostname)
|
111
|
-
if defined?(Rails) && Rails.respond_to?(:root)
|
112
|
-
text << formatted_key_value('Rails root', Rails.root)
|
113
|
-
end
|
110
|
+
text << formatted_key_value('Rails root', Rails.root) if defined?(Rails) && Rails.respond_to?(:root)
|
114
111
|
text << formatted_key_value('Process', $PROCESS_ID)
|
115
112
|
text << '___'
|
116
113
|
text.join("\n")
|
@@ -148,6 +145,12 @@ module ExceptionNotifier
|
|
148
145
|
object.to_s
|
149
146
|
end
|
150
147
|
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
def controller_subtitle
|
152
|
+
"#{controller.controller_name} #{controller.action_name}" if controller
|
153
|
+
end
|
151
154
|
end
|
152
155
|
end
|
153
156
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/time'
|
2
4
|
require 'action_mailer'
|
3
5
|
require 'action_dispatch'
|
@@ -74,13 +76,17 @@ module ExceptionNotifier
|
|
74
76
|
def compose_subject
|
75
77
|
subject = @options[:email_prefix].to_s.dup
|
76
78
|
subject << "(#{@options[:accumulated_errors_count]} times)" if @options[:accumulated_errors_count].to_i > 1
|
77
|
-
subject << "#{@kontroller.controller_name}
|
79
|
+
subject << "#{@kontroller.controller_name}##{@kontroller.action_name}" if include_controller?
|
78
80
|
subject << " (#{@exception.class})"
|
79
81
|
subject << " #{@exception.message.inspect}" if @options[:verbose_subject]
|
80
82
|
subject = EmailNotifier.normalize_digits(subject) if @options[:normalize_subject]
|
81
83
|
subject.length > 120 ? subject[0...120] + '...' : subject
|
82
84
|
end
|
83
85
|
|
86
|
+
def include_controller?
|
87
|
+
@kontroller && @options[:include_controller_and_action_names_in_subject]
|
88
|
+
end
|
89
|
+
|
84
90
|
def set_data_variables
|
85
91
|
@data.each do |name, value|
|
86
92
|
instance_variable_set("@#{name}", value)
|
@@ -137,7 +143,9 @@ module ExceptionNotifier
|
|
137
143
|
end
|
138
144
|
|
139
145
|
def load_custom_views
|
140
|
-
|
146
|
+
return unless defined?(Rails) && Rails.respond_to?(:root)
|
147
|
+
|
148
|
+
prepend_view_path Rails.root.nil? ? 'app/views' : "#{Rails.root}/app/views"
|
141
149
|
end
|
142
150
|
|
143
151
|
def maybe_call(maybe_proc)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ExceptionNotifier
|
2
4
|
class IrcNotifier < BaseNotifier
|
3
5
|
def initialize(options)
|
@@ -9,9 +11,8 @@ module ExceptionNotifier
|
|
9
11
|
def call(exception, options = {})
|
10
12
|
errors_count = options[:accumulated_errors_count].to_i
|
11
13
|
|
12
|
-
|
13
|
-
message
|
14
|
-
|
14
|
+
occurrences = "(#{errors_count} times)" if errors_count > 1
|
15
|
+
message = "#{occurrences}'#{exception.message}'"
|
15
16
|
message += " on '#{exception.backtrace.first}'" if exception.backtrace
|
16
17
|
|
17
18
|
return unless active?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'httparty'
|
2
4
|
|
3
5
|
module ExceptionNotifier
|
@@ -10,6 +12,8 @@ module ExceptionNotifier
|
|
10
12
|
|
11
13
|
@gitlab_url = options[:git_url]
|
12
14
|
|
15
|
+
@env = options[:env] || {}
|
16
|
+
|
13
17
|
payload = {
|
14
18
|
text: message_text.compact.join("\n"),
|
15
19
|
username: options[:username] || 'Exception Notifier'
|
@@ -52,6 +56,12 @@ module ExceptionNotifier
|
|
52
56
|
text << backtrace
|
53
57
|
end
|
54
58
|
|
59
|
+
if (exception_data = @env['exception_notifier.exception_data'])
|
60
|
+
text << '### Data'
|
61
|
+
data_string = exception_data.map { |k, v| "* #{k} : #{v}" }.join("\n")
|
62
|
+
text << "```\n#{data_string}\n```"
|
63
|
+
end
|
64
|
+
|
55
65
|
text << message_issue_link if @gitlab_url
|
56
66
|
|
57
67
|
text
|