exception_notification 3.0.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Appraisals +7 -0
- data/CHANGELOG.rdoc +129 -1
- data/CODE_OF_CONDUCT.md +22 -0
- data/CONTRIBUTING.md +29 -1
- data/Gemfile +1 -1
- data/MIT-LICENSE +23 -0
- data/README.md +168 -222
- data/Rakefile +5 -11
- data/docs/notifiers/campfire.md +50 -0
- data/docs/notifiers/custom.md +42 -0
- data/docs/notifiers/datadog.md +51 -0
- data/docs/notifiers/email.md +195 -0
- data/docs/notifiers/google_chat.md +31 -0
- data/docs/notifiers/hipchat.md +66 -0
- data/docs/notifiers/irc.md +97 -0
- data/docs/notifiers/mattermost.md +115 -0
- data/docs/notifiers/slack.md +161 -0
- data/docs/notifiers/sns.md +37 -0
- data/docs/notifiers/teams.md +54 -0
- data/docs/notifiers/webhook.md +60 -0
- data/examples/sample_app.rb +54 -0
- data/examples/sinatra/Gemfile +8 -0
- data/examples/sinatra/Gemfile.lock +95 -0
- data/examples/sinatra/Procfile +2 -0
- data/examples/sinatra/README.md +11 -0
- data/examples/sinatra/config.ru +3 -0
- data/examples/sinatra/sinatra_app.rb +36 -0
- data/exception_notification.gemspec +32 -11
- data/gemfiles/rails4_0.gemfile +7 -0
- data/gemfiles/rails4_1.gemfile +7 -0
- data/gemfiles/rails4_2.gemfile +7 -0
- data/gemfiles/rails5_0.gemfile +7 -0
- data/gemfiles/rails5_1.gemfile +7 -0
- data/gemfiles/rails5_2.gemfile +7 -0
- data/gemfiles/rails6_0.gemfile +7 -0
- data/lib/exception_notification.rb +11 -0
- data/lib/exception_notification/rack.rb +55 -0
- data/lib/exception_notification/rails.rb +9 -0
- data/lib/exception_notification/resque.rb +22 -0
- data/lib/exception_notification/sidekiq.rb +27 -0
- data/lib/exception_notification/version.rb +3 -0
- data/lib/exception_notifier.rb +137 -61
- data/lib/exception_notifier/base_notifier.rb +24 -0
- data/lib/exception_notifier/campfire_notifier.rb +16 -11
- data/lib/exception_notifier/datadog_notifier.rb +153 -0
- data/lib/exception_notifier/email_notifier.rb +196 -0
- data/lib/exception_notifier/google_chat_notifier.rb +42 -0
- data/lib/exception_notifier/hipchat_notifier.rb +49 -0
- data/lib/exception_notifier/irc_notifier.rb +57 -0
- data/lib/exception_notifier/mattermost_notifier.rb +72 -0
- data/lib/exception_notifier/modules/backtrace_cleaner.rb +11 -0
- data/lib/exception_notifier/modules/error_grouping.rb +77 -0
- data/lib/exception_notifier/modules/formatter.rb +118 -0
- data/lib/exception_notifier/notifier.rb +9 -179
- data/lib/exception_notifier/slack_notifier.rb +111 -0
- data/lib/exception_notifier/sns_notifier.rb +85 -0
- data/lib/exception_notifier/teams_notifier.rb +193 -0
- data/lib/exception_notifier/views/exception_notifier/_backtrace.html.erb +3 -1
- data/lib/exception_notifier/views/exception_notifier/_data.html.erb +6 -1
- data/lib/exception_notifier/views/exception_notifier/_environment.html.erb +8 -6
- data/lib/exception_notifier/views/exception_notifier/_environment.text.erb +1 -4
- data/lib/exception_notifier/views/exception_notifier/_request.html.erb +36 -5
- data/lib/exception_notifier/views/exception_notifier/_request.text.erb +10 -5
- data/lib/exception_notifier/views/exception_notifier/_session.html.erb +10 -2
- data/lib/exception_notifier/views/exception_notifier/_session.text.erb +2 -2
- data/lib/exception_notifier/views/exception_notifier/_title.html.erb +3 -3
- data/lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb +38 -11
- data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb +10 -11
- data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +38 -22
- data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +2 -3
- data/lib/exception_notifier/webhook_notifier.rb +51 -0
- data/lib/generators/exception_notification/install_generator.rb +15 -0
- data/lib/generators/exception_notification/templates/exception_notification.rb.erb +55 -0
- data/test/exception_notification/rack_test.rb +60 -0
- data/test/exception_notification/resque_test.rb +52 -0
- data/test/exception_notifier/campfire_notifier_test.rb +120 -0
- data/test/exception_notifier/datadog_notifier_test.rb +151 -0
- data/test/exception_notifier/email_notifier_test.rb +351 -0
- data/test/exception_notifier/google_chat_notifier_test.rb +181 -0
- data/test/exception_notifier/hipchat_notifier_test.rb +218 -0
- data/test/exception_notifier/irc_notifier_test.rb +137 -0
- data/test/exception_notifier/mattermost_notifier_test.rb +202 -0
- data/test/exception_notifier/modules/error_grouping_test.rb +165 -0
- data/test/exception_notifier/modules/formatter_test.rb +150 -0
- data/test/exception_notifier/sidekiq_test.rb +38 -0
- data/test/exception_notifier/slack_notifier_test.rb +227 -0
- data/test/exception_notifier/sns_notifier_test.rb +121 -0
- data/test/exception_notifier/teams_notifier_test.rb +90 -0
- data/test/exception_notifier/webhook_notifier_test.rb +96 -0
- data/test/exception_notifier_test.rb +182 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.html.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.text.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_section.html.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_section.text.erb +0 -0
- data/test/test_helper.rb +12 -8
- metadata +333 -164
- data/.gemtest +0 -0
- data/Gemfile.lock +0 -122
- data/test/background_exception_notification_test.rb +0 -82
- data/test/campfire_test.rb +0 -53
- data/test/dummy/.gitignore +0 -4
- data/test/dummy/Gemfile +0 -33
- data/test/dummy/Gemfile.lock +0 -118
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/controllers/posts_controller.rb +0 -30
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/models/post.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/posts/_form.html.erb +0 -0
- data/test/dummy/app/views/posts/new.html.erb +0 -0
- data/test/dummy/app/views/posts/show.html.erb +0 -0
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -42
- data/test/dummy/config/boot.rb +0 -6
- data/test/dummy/config/database.yml +0 -22
- data/test/dummy/config/environment.rb +0 -13
- data/test/dummy/config/environments/development.rb +0 -24
- data/test/dummy/config/environments/production.rb +0 -49
- data/test/dummy/config/environments/test.rb +0 -35
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/db/migrate/20110729022608_create_posts.rb +0 -15
- data/test/dummy/db/schema.rb +0 -24
- data/test/dummy/db/seeds.rb +0 -7
- data/test/dummy/lib/tasks/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/images/rails.png +0 -0
- data/test/dummy/public/index.html +0 -239
- data/test/dummy/public/javascripts/application.js +0 -2
- data/test/dummy/public/javascripts/controls.js +0 -965
- data/test/dummy/public/javascripts/dragdrop.js +0 -974
- data/test/dummy/public/javascripts/effects.js +0 -1123
- data/test/dummy/public/javascripts/prototype.js +0 -6001
- data/test/dummy/public/javascripts/rails.js +0 -191
- data/test/dummy/public/robots.txt +0 -5
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/public/stylesheets/scaffold.css +0 -56
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/fixtures/posts.yml +0 -11
- data/test/dummy/test/functional/posts_controller_test.rb +0 -239
- data/test/dummy/test/test_helper.rb +0 -13
- data/test/exception_notification_test.rb +0 -73
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f61027914f50eed12ef3c115cca8ba7a3f4f3b1e
|
4
|
+
data.tar.gz: 1a63465348250221f3a7d2171979a8d6b35639c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62cf62e3500f7edb53940bbe458a5b2e1936469033c4c643ad47d4ac9d3a913bd406fb7ca37cbf0d27b4f862b5487bd5736abdd37288aaaa904a125a00bd72bf
|
7
|
+
data.tar.gz: 0ffc513a9fd0ce553254665abfb6da9640a4e9eb3ff5edf39aa838b9baa3caffffd76f0ffab64417721cd7c4828fdabba8c6ab9c9f47077f800845418c38db52
|
data/Appraisals
ADDED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,131 @@
|
|
1
|
+
== 4.4.0
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Rails 6 compatibility (by @shanecav)
|
5
|
+
* Add Datadog notifier (by @ajain0184)
|
6
|
+
* Use backtrace cleaner for Slack notifications (by @pomier)
|
7
|
+
* Add slack channel name override option (by @chaadow)
|
8
|
+
* Addition of sample application for testing purposes (by @ampeigonet)
|
9
|
+
|
10
|
+
* bug fixes
|
11
|
+
* Fix error in Resque failure backend (by @EmilioCristalli)
|
12
|
+
* Remove sqlite dependency (by @EmilioCristalli)
|
13
|
+
* Configure ignore_crawlers from Rails initializer (by @EmilioCristalli)
|
14
|
+
|
15
|
+
== 4.3.0
|
16
|
+
|
17
|
+
* enhancements
|
18
|
+
* Add Microsoft Teams Notifier (by @phaelin)
|
19
|
+
* Add SNS notifier (by @FLarra)
|
20
|
+
* Add Google Chats notifier (by @renatolond)
|
21
|
+
* Align output of section-headers consistently (by @kronn)
|
22
|
+
* ExceptionNotifier.notify_exception receives block & pass it to each notifier (by @pocke)
|
23
|
+
* Update Travis to latest rubies (by @lostapathy)
|
24
|
+
|
25
|
+
* bug fixes
|
26
|
+
* Replace all before_filter to before_action on readme (by @pastullo)
|
27
|
+
* Fix error when using error grouping outside of rails (by @garethcokell)
|
28
|
+
* Fix missing MissingController Mattermost class (by @n-rodriguez)
|
29
|
+
|
30
|
+
== 4.2.2
|
31
|
+
|
32
|
+
* enhancements
|
33
|
+
* Error grouping (by @Martin91)
|
34
|
+
* Additional fields for Slack support (by @schurig)
|
35
|
+
* Enterprise HipChat support (by @seanhuber)
|
36
|
+
|
37
|
+
== 4.2.1
|
38
|
+
|
39
|
+
* enhancements
|
40
|
+
* Allow customizable backtrace for Slack (by @aried3r)
|
41
|
+
* Add `Mongoid::Errors::DocumentNotFound` to ignored_exceptions (by @nazarok)
|
42
|
+
* Improved text in Slack notifier (by @vojtad)
|
43
|
+
|
44
|
+
* bug fixes
|
45
|
+
* Fix data being sent on webhook notifier
|
46
|
+
|
47
|
+
== 4.2.0
|
48
|
+
|
49
|
+
* enhancements
|
50
|
+
* update URL in gemspec (by @ktdreyer)
|
51
|
+
* Add `hostname` to Slack notifier (by @juanazam)
|
52
|
+
* Allow `exception_recipients` to be a proc (by @kellyjosephprice)
|
53
|
+
* Add Mattermost integration (by @Aschen)
|
54
|
+
* Rails 5 compatible
|
55
|
+
|
56
|
+
* bug fixes
|
57
|
+
* Fix error when showing timestamp on non Rails apps
|
58
|
+
* Fix delivery failure when deliver_with specified (by @grzuy)
|
59
|
+
|
60
|
+
== 4.1.4
|
61
|
+
|
62
|
+
* bug fixes
|
63
|
+
* HTML-escape exception messages sent to hipchat (by @gburt)
|
64
|
+
* Send the correct options in send_notice (by @pcboy)
|
65
|
+
|
66
|
+
== 4.1.3
|
67
|
+
|
68
|
+
* enhancements
|
69
|
+
* Add a way to have a backtrace callback on notifiers (by @pcboy)
|
70
|
+
|
71
|
+
* bug fixes
|
72
|
+
* Fix incompatible character encodings error (by @san650)
|
73
|
+
|
74
|
+
== 4.1.2
|
75
|
+
* enhancements
|
76
|
+
* Change format of Slack notifications (by @eldano)
|
77
|
+
|
78
|
+
== 4.1.1
|
79
|
+
|
80
|
+
* bug fixes
|
81
|
+
* Alternate way to monkeypatch (by @joshco)
|
82
|
+
* Fix BacktraceCleaner namespacing (by @esdlocomb)
|
83
|
+
|
84
|
+
== 4.1.0
|
85
|
+
|
86
|
+
* enhancements
|
87
|
+
* Add support for Sidekiq 3.0 (by @mbrictson)
|
88
|
+
* Add IRC notifier (by @nathanjsharpe)
|
89
|
+
* Add ActionController::UnknownFormat to default ignored exceptions (by @rezwyi)
|
90
|
+
* Add message_template option to HipChat notifier (by @makimoto)
|
91
|
+
* Add support for HipChat APIv2 (by @michaelherold)
|
92
|
+
* Add Slack notifier (by @martin1keogh)
|
93
|
+
* Add option for notifying on `X-Cascade` header (by @etipton)
|
94
|
+
* Improve backtrace data (by @munkius)
|
95
|
+
|
96
|
+
* bug fixes
|
97
|
+
* Fix `Rails.root` exception (by @hovatterz)
|
98
|
+
* Fix email notifier in Sinatra (by @betesh)
|
99
|
+
|
100
|
+
== 4.0.1
|
101
|
+
|
102
|
+
* enhancements
|
103
|
+
* Add HipChat notifier (by @j15e)
|
104
|
+
* Log backtrace when notification fails
|
105
|
+
* Send more info in Webhook notifier
|
106
|
+
* Add HTTP method to request section
|
107
|
+
|
108
|
+
== 4.0.0
|
109
|
+
|
110
|
+
* enhancements
|
111
|
+
* Be able to override delivery_method (by @jweslley)
|
112
|
+
* Add logger to log when notifications cannot be shiped (by @jweslley)
|
113
|
+
* Add Rails generator to create an initializer file (by @jweslley)
|
114
|
+
* Add rails engine (by @jweslley)
|
115
|
+
* Add sidekiq support (by @jweslley)
|
116
|
+
* Add resque support (by @jweslley)
|
117
|
+
* Better style for html views (by @jweslley)
|
118
|
+
* Support customizable Mailer class (by @Bishop)
|
119
|
+
* Turn ExceptionNotification Rails agnostic (by @jweslley)
|
120
|
+
* Support custom ignore exceptions for background notifications (by @jweslley)
|
121
|
+
* Be able to implement custom notifiers (by @jweslley)
|
122
|
+
* Add Webhook notifier (by @jweslley)
|
123
|
+
* Rails 4 compatible
|
124
|
+
|
125
|
+
* bug fixes
|
126
|
+
* Don't error if Rails isn't defined. (by @dpogue)
|
127
|
+
* Fix call to #normalize_digits (by @ghiculescu)
|
128
|
+
|
1
129
|
== 3.0.1
|
2
130
|
|
3
131
|
* enhancements
|
@@ -32,7 +160,7 @@
|
|
32
160
|
* Add normalize_subject option to remove numbers from email so that they thread (by @jjb)
|
33
161
|
* Allow the user to provide a custom message and hash of data (by @jjb)
|
34
162
|
* Add support for configurable background sections and a data partial (by @jeffrafter)
|
35
|
-
* Include timestamp of exception in notification body
|
163
|
+
* Include timestamp of exception in notification body
|
36
164
|
* Add support for rack based session management (by @phoet)
|
37
165
|
* Add ignore_crawlers option to ignore exceptions generated by crawlers
|
38
166
|
* Add verbode_subject option to exclude exception message from subject (by @amishyn)
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include:
|
8
|
+
|
9
|
+
* The use of sexualized language or imagery
|
10
|
+
* Personal attacks
|
11
|
+
* Trolling or insulting/derogatory comments
|
12
|
+
* Public or private harassment
|
13
|
+
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
|
14
|
+
* Other unethical or unprofessional conduct.
|
15
|
+
|
16
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
17
|
+
|
18
|
+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
19
|
+
|
20
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
21
|
+
|
22
|
+
This Code of Conduct is adapted from the [Contributor Covenant, version 1.2.0](http://contributor-covenant.org/version/1/2/0/).
|
data/CONTRIBUTING.md
CHANGED
@@ -18,16 +18,44 @@ need contributors to follow:
|
|
18
18
|
like OS version, gem versions, etc...
|
19
19
|
* Even better, provide a failing test case for it.
|
20
20
|
|
21
|
+
To help you add information to an issue, you can use the sample_app.
|
22
|
+
Steps to use sample_app:
|
23
|
+
|
24
|
+
1) Add your configuration to (ex. with webhook):
|
25
|
+
```ruby
|
26
|
+
config.middleware.use ExceptionNotification::Rack,
|
27
|
+
# -----------------------------------
|
28
|
+
# Change this with your configuration
|
29
|
+
# https://github.com/smartinez87/exception_notification#notifiers
|
30
|
+
webhook: {
|
31
|
+
url: 'http://domain.com:5555/hubot/path'
|
32
|
+
}
|
33
|
+
# -----------------------------------
|
34
|
+
```
|
35
|
+
|
36
|
+
2) Run `ruby examples/sample_app.rb`
|
37
|
+
If exception notification is working OK, the test should pass and trigger a notification as configured above. If it's not, you can copy the information printed on the terminal related to exception notification and report an issue with more info!
|
38
|
+
|
21
39
|
## Pull Requests
|
22
40
|
|
23
41
|
If you've gone the extra mile and have a patch that fixes the issue, you
|
24
42
|
should submit a Pull Request!
|
25
43
|
|
26
44
|
* Fork the repo on Github.
|
45
|
+
* Run Bundler and setup your test database
|
46
|
+
|
47
|
+
```
|
48
|
+
bundle
|
49
|
+
cd test/dummy
|
50
|
+
bundle
|
51
|
+
bundle exec rake db:reset db:test:prepare
|
52
|
+
cd ../..
|
53
|
+
bundle exec rake test
|
54
|
+
```
|
27
55
|
* Create a topic branch from where you want to base your work.
|
28
56
|
* Add a test for your change. Only refactoring and documentation changes
|
29
57
|
require no new tests. If you are adding functionality or fixing a bug,
|
30
58
|
we need a test!
|
31
|
-
* Run _all_ the tests to assure
|
59
|
+
* Run _all_ the tests to assure nothing else was broken. We only take pull requests with passing tests.
|
32
60
|
* Check for unnecessary whitespace with `git diff --check` before committing.
|
33
61
|
* Push to your fork and submit a pull request.
|
data/Gemfile
CHANGED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2011-2016 Sebastian Martinez
|
2
|
+
Copyright (c) 2005-2010 Jamis Buck
|
3
|
+
|
4
|
+
The MIT License (MIT)
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,339 +1,285 @@
|
|
1
|
-
Exception
|
2
|
-
====
|
1
|
+
# Exception Notification
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
[![Gem Version](https://fury-badge.herokuapp.com/rb/exception_notification.png)](http://badge.fury.io/rb/exception_notification)
|
4
|
+
[![Travis](https://api.travis-ci.org/smartinez87/exception_notification.png)](http://travis-ci.org/smartinez87/exception_notification)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/smartinez87/exception_notification/badge.png?branch=master)](https://coveralls.io/r/smartinez87/exception_notification)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/smartinez87/exception_notification.png)](https://codeclimate.com/github/smartinez87/exception_notification)
|
7
7
|
|
8
|
-
|
9
|
-
environment, and also gives a backtrace of the exception.
|
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.**
|
10
9
|
|
11
|
-
There's a great [Railscast about Exception Notifications](http://railscasts.com/episodes/104-exception-notifications-revised)
|
12
|
-
you can see that may help you getting started.
|
13
|
-
|
14
|
-
[Follow us on Twitter](https://twitter.com/exception_notif) to get updates and notices about new releases.
|
15
|
-
|
16
|
-
Installation
|
17
10
|
---
|
18
11
|
|
19
|
-
|
20
|
-
the following line in your Gemfile
|
21
|
-
|
22
|
-
```ruby
|
23
|
-
gem 'exception_notification'
|
24
|
-
```
|
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), [Campfire](docs/notifiers/campfire.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).
|
25
13
|
|
26
|
-
|
27
|
-
configure its options on your config.ru file, or in the environment you
|
28
|
-
want it to run. In most cases you would want ExceptionNotification to
|
29
|
-
run on production. You can make it work by
|
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.
|
30
15
|
|
31
|
-
|
32
|
-
Whatever::Application.config.middleware.use ExceptionNotifier,
|
33
|
-
:email_prefix => "[Whatever] ",
|
34
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
35
|
-
:exception_recipients => %w{exceptions@example.com}
|
36
|
-
```
|
16
|
+
[Follow us on Twitter](https://twitter.com/exception_notif) to get updates and notices about new releases.
|
37
17
|
|
38
|
-
|
39
|
-
---
|
18
|
+
## Requirements
|
40
19
|
|
41
|
-
|
42
|
-
|
20
|
+
* Ruby 2.0 or greater
|
21
|
+
* Rails 4.0 or greater, Sinatra or another Rack-based application.
|
43
22
|
|
44
|
-
|
45
|
-
to your `Gemfile`:
|
23
|
+
For previous releases, please checkout [this](#versions).
|
46
24
|
|
47
|
-
|
48
|
-
gem 'tinder'
|
49
|
-
```
|
25
|
+
## Getting Started
|
50
26
|
|
51
|
-
|
52
|
-
like this:
|
27
|
+
Add the following line to your application's Gemfile:
|
53
28
|
|
54
29
|
```ruby
|
55
|
-
|
56
|
-
:email_prefix => "[Whatever] ",
|
57
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
58
|
-
:exception_recipients => %w{exceptions@example.com},
|
59
|
-
:campfire => {:subdomain => 'my_subdomain', :token => 'my_token', :room_name => 'my_room'}
|
30
|
+
gem 'exception_notification'
|
60
31
|
```
|
61
32
|
|
62
|
-
|
63
|
-
[here](https://github.com/collectiveidea/tinder/blob/master/lib/tinder/campfire.rb#L17).
|
64
|
-
|
65
|
-
Customization
|
66
|
-
---
|
67
|
-
|
68
|
-
### Sections
|
33
|
+
### Rails
|
69
34
|
|
70
|
-
|
71
|
-
environment, and backtrace (in that order). You can customize how each of those
|
72
|
-
sections are rendered by placing a partial named for that part in your
|
73
|
-
app/views/exception_notifier directory (e.g., _session.rhtml). Each partial has
|
74
|
-
access to the following variables:
|
35
|
+
ExceptionNotification is used as a rack middleware, or in the environment you want it to run. In most cases you would want ExceptionNotification to run on production. Thus, you can make it work by putting the following lines in your `config/environments/production.rb`:
|
75
36
|
|
76
37
|
```ruby
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
@
|
38
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
39
|
+
email: {
|
40
|
+
deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now
|
41
|
+
email_prefix: '[PREFIX] ',
|
42
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
43
|
+
exception_recipients: %w{exceptions@example.com}
|
44
|
+
}
|
83
45
|
```
|
84
46
|
|
85
|
-
|
47
|
+
**Note**: In order to enable delivery notifications by email make sure you have [ActionMailer configured](docs/notifiers/email.md#actionmailer-configuration).
|
86
48
|
|
87
|
-
|
88
|
-
ExceptionNotifier.sections variable. You can even add new sections that
|
89
|
-
describe application-specific data--just add the section's name to the list
|
90
|
-
(wherever you'd like), and define the corresponding partial.
|
49
|
+
### Rack/Sinatra
|
91
50
|
|
92
|
-
|
93
|
-
#Example with two new added sections
|
94
|
-
Whatever::Application.config.middleware.use ExceptionNotifier,
|
95
|
-
:email_prefix => "[Whatever] ",
|
96
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
97
|
-
:exception_recipients => %w{exceptions@example.com},
|
98
|
-
:sections => %w{my_section1 my_section2} + ExceptionNotifier::Notifier.default_sections
|
99
|
-
```
|
51
|
+
In order to use ExceptionNotification with Sinatra, please take a look in the [example application](https://github.com/smartinez87/exception_notification/tree/master/examples/sinatra).
|
100
52
|
|
101
|
-
|
102
|
-
`./app/views/exception_notifier/_my_section1.text.erb`.
|
53
|
+
### Custom Data, e.g. Current User
|
103
54
|
|
104
|
-
|
105
|
-
it is made available to the email using the exception_data macro:
|
55
|
+
Save the current user in the `request` using a controller callback.
|
106
56
|
|
107
57
|
```ruby
|
108
58
|
class ApplicationController < ActionController::Base
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
...
|
59
|
+
before_action :prepare_exception_notifier
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def prepare_exception_notifier
|
64
|
+
request.env["exception_notifier.exception_data"] = {
|
65
|
+
current_user: current_user
|
66
|
+
}
|
67
|
+
end
|
119
68
|
end
|
120
69
|
```
|
121
70
|
|
122
|
-
|
123
|
-
renderer, allowing your new section(s) to access and display them. See the
|
124
|
-
existing sections defined by the plugin for examples of how to write your own.
|
71
|
+
The current user will show up in your email, in a new section titled "Data".
|
125
72
|
|
126
|
-
|
73
|
+
```
|
74
|
+
------------------------------- Data:
|
127
75
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
133
|
-
:exception_recipients => %w{exceptions@example.com},
|
134
|
-
:background_sections => %w{my_section1 my_section2} + ExceptionNotifier::Notifier.default_background_sections
|
76
|
+
* data: {:current_user=>
|
77
|
+
#<User:0x007ff03c0e5860
|
78
|
+
id: 3,
|
79
|
+
email: "jane.doe@example.com", # etc...
|
135
80
|
```
|
136
81
|
|
137
|
-
|
138
|
-
|
82
|
+
For more control over the display of custom data, see "Email notifier ->
|
83
|
+
Options -> sections" below.
|
139
84
|
|
140
|
-
|
85
|
+
## Notifiers
|
141
86
|
|
142
|
-
|
143
|
-
ExceptionNotifier avoid sending notifications for those specified.
|
144
|
-
There are three ways of specifying which exceptions to ignore:
|
87
|
+
ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default, 8 notifiers are available:
|
145
88
|
|
146
|
-
|
89
|
+
* [Campfire notifier](docs/notifiers/campfire.md)
|
90
|
+
* [Datadog notifier](docs/notifiers/datadog.md)
|
91
|
+
* [Email notifier](docs/notifiers/email.md)
|
92
|
+
* [HipChat notifier](docs/notifiers/hipchat.md)
|
93
|
+
* [IRC notifier](docs/notifiers/irc.md)
|
94
|
+
* [Slack notifier](docs/notifiers/slack.md)
|
95
|
+
* [Mattermost notifier](docs/notifiers/mattermost.md)
|
96
|
+
* [Teams notifier](docs/notifiers/teams.md)
|
97
|
+
* [Amazon SNS](docs/notifiers/sns.md)
|
98
|
+
* [Google Chat notifier](docs/notifiers/google_chat.md)
|
99
|
+
* [WebHook notifier](docs/notifiers/webhook.md)
|
147
100
|
|
148
|
-
|
101
|
+
But, you also can easily implement your own [custom notifier](docs/notifiers/custom.md).
|
149
102
|
|
150
|
-
|
103
|
+
## Error Grouping
|
151
104
|
|
152
|
-
|
105
|
+
In general, ExceptionNotification will send a notification when every error occurs, which may result in a problem: if your site has a high throughput and a particular error is raised frequently, you will receive too many notifications. During a short period of time, your mail box may be filled with thousands of exception mails, or your mail server may even become slow. To prevent this, you can choose to group errors by setting the `:error_grouping` option to `true`.
|
153
106
|
|
154
|
-
|
107
|
+
Error grouping uses a default formula of `log2(errors_count)` to determine whether to send the notification, based on the accumulated error count for each specific exception. This makes the notifier only send a notification when the count is: 1, 2, 4, 8, 16, 32, 64, 128, ..., (2**n). You can use `:notification_trigger` to override this default formula.
|
155
108
|
|
156
|
-
|
157
|
-
To achieve that, you should use the _:ignore_exceptions_ option, like this:
|
109
|
+
The following code shows the available options to configure error grouping:
|
158
110
|
|
159
111
|
```ruby
|
160
|
-
|
161
|
-
:
|
162
|
-
:
|
163
|
-
|
164
|
-
|
112
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
113
|
+
ignore_exceptions: ['ActionView::TemplateError'] + ExceptionNotifier.ignored_exceptions,
|
114
|
+
email: {
|
115
|
+
email_prefix: '[PREFIX] ',
|
116
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
117
|
+
exception_recipients: %w{exceptions@example.com}
|
118
|
+
},
|
119
|
+
error_grouping: true,
|
120
|
+
# error_grouping_period: 5.minutes, # the time before an error is regarded as fixed
|
121
|
+
# error_grouping_cache: Rails.cache, # for other applications such as Sinatra, use one instance of ActiveSupport::Cache::Store
|
122
|
+
#
|
123
|
+
# notification_trigger: specify a callback to determine when a notification should be sent,
|
124
|
+
# the callback will be invoked with two arguments:
|
125
|
+
# exception: the exception raised
|
126
|
+
# count: accumulated errors count for this exception
|
127
|
+
#
|
128
|
+
# notification_trigger: lambda { |exception, count| count % 10 == 0 }
|
165
129
|
```
|
166
130
|
|
167
|
-
|
168
|
-
exception, plus the ones ignored by default.
|
169
|
-
By default, ExceptionNotifier ignores _ActiveRecord::RecordNotFound_,
|
170
|
-
_AbstractController::ActionNotFound_ and
|
171
|
-
_ActionController::RountingError_.
|
131
|
+
## Ignore Exceptions
|
172
132
|
|
173
|
-
|
133
|
+
You can choose to ignore certain exceptions, which will make ExceptionNotification avoid sending notifications for those specified. There are three ways of specifying which exceptions to ignore:
|
174
134
|
|
175
|
-
|
176
|
-
|
135
|
+
* `:ignore_exceptions` - By exception class (i.e. ignore RecordNotFound ones)
|
136
|
+
|
137
|
+
* `:ignore_crawlers` - From crawler (i.e. ignore ones originated by Googlebot)
|
138
|
+
|
139
|
+
* `:ignore_if` - Custom (i.e. ignore exceptions that satisfy some condition)
|
140
|
+
|
141
|
+
|
142
|
+
### :ignore_exceptions
|
143
|
+
|
144
|
+
*Array of strings, default: %w{ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat}*
|
145
|
+
|
146
|
+
Ignore specified exception types. To achieve that, you should use the `:ignore_exceptions` option, like this:
|
177
147
|
|
178
148
|
```ruby
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
149
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
150
|
+
ignore_exceptions: ['ActionView::TemplateError'] + ExceptionNotifier.ignored_exceptions,
|
151
|
+
email: {
|
152
|
+
email_prefix: '[PREFIX] ',
|
153
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
154
|
+
exception_recipients: %w{exceptions@example.com}
|
155
|
+
}
|
184
156
|
```
|
185
157
|
|
186
|
-
will
|
158
|
+
The above will make ExceptionNotifier ignore a *TemplateError* exception, plus the ones ignored by default.
|
187
159
|
|
188
|
-
|
160
|
+
### :ignore_crawlers
|
189
161
|
|
190
|
-
|
162
|
+
*Array of strings, default: []*
|
163
|
+
|
164
|
+
In some cases you may want to avoid getting notifications from exceptions made by crawlers. To prevent sending those unwanted notifications, use the `:ignore_crawlers` option like this:
|
191
165
|
|
192
166
|
```ruby
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
167
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
168
|
+
ignore_crawlers: %w{Googlebot bingbot},
|
169
|
+
email: {
|
170
|
+
email_prefix: '[PREFIX] ',
|
171
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
172
|
+
exception_recipients: %w{exceptions@example.com}
|
173
|
+
}
|
198
174
|
```
|
199
175
|
|
200
|
-
|
201
|
-
avoid or not sending the notification.
|
176
|
+
### :ignore_if
|
202
177
|
|
203
|
-
|
178
|
+
*Lambda, default: nil*
|
204
179
|
|
205
|
-
|
206
|
-
emails. To do so, simply use the _:email_headers_ option:
|
180
|
+
Last but not least, you can ignore exceptions based on a condition. Take a look:
|
207
181
|
|
208
182
|
```ruby
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
183
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
184
|
+
ignore_if: ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ },
|
185
|
+
email: {
|
186
|
+
email_prefix: '[PREFIX] ',
|
187
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
188
|
+
exception_recipients: %w{exceptions@example.com},
|
189
|
+
}
|
215
190
|
```
|
216
191
|
|
217
|
-
|
192
|
+
You can make use of both the environment and the exception inside the lambda to decide wether to avoid or not sending the notification.
|
218
193
|
|
219
|
-
|
220
|
-
Use _:verbose_subject => false_ to exclude it.
|
194
|
+
## Rack X-Cascade Header
|
221
195
|
|
222
|
-
|
196
|
+
Some rack apps (Rails in particular) utilize the "X-Cascade" header to pass the request-handling responsibility to the next middleware in the stack.
|
223
197
|
|
224
|
-
|
225
|
-
This is disabled by default.
|
226
|
-
Use _:normalize_subject => true_ to enable it.
|
198
|
+
Rails' routing middleware uses this strategy, rather than raising an exception, to handle routing errors (e.g. 404s); to be notified whenever a 404 occurs, set this option to "false."
|
227
199
|
|
228
|
-
###
|
200
|
+
### :ignore_cascade_pass
|
229
201
|
|
230
|
-
|
231
|
-
You can do so by adding this to the configuration: _:email_format => :html_.
|
202
|
+
*Boolean, default: true*
|
232
203
|
|
204
|
+
Set to false to trigger notifications when another rack middleware sets the "X-Cascade" header to "pass."
|
233
205
|
|
234
|
-
Background Notifications
|
235
|
-
---
|
206
|
+
## Background Notifications
|
236
207
|
|
237
|
-
If you want to send notifications from a background process like
|
238
|
-
DelayedJob, you should use the background_exception_notification method
|
239
|
-
like this:
|
208
|
+
If you want to send notifications from a background process like DelayedJob, you should use the `notify_exception` method like this:
|
240
209
|
|
241
210
|
```ruby
|
242
211
|
begin
|
243
212
|
some code...
|
244
213
|
rescue => e
|
245
|
-
ExceptionNotifier
|
214
|
+
ExceptionNotifier.notify_exception(e)
|
246
215
|
end
|
247
216
|
```
|
248
217
|
|
249
|
-
You can include information about the background process that created
|
250
|
-
the error by including a data parameter:
|
218
|
+
You can include information about the background process that created the error by including a data parameter:
|
251
219
|
|
252
220
|
```ruby
|
253
221
|
begin
|
254
222
|
some code...
|
255
|
-
rescue =>
|
256
|
-
ExceptionNotifier
|
257
|
-
|
223
|
+
rescue => e
|
224
|
+
ExceptionNotifier.notify_exception(
|
225
|
+
e,
|
226
|
+
data: { worker: worker.to_s, queue: queue, payload: payload}
|
227
|
+
)
|
258
228
|
end
|
259
229
|
```
|
260
230
|
|
231
|
+
### Manually notify of exception
|
261
232
|
|
262
|
-
|
263
|
-
---
|
264
|
-
|
265
|
-
If your controller action manually handles an error, the notifier will never be
|
266
|
-
run. To manually notify of an error you can do something like the following:
|
233
|
+
If your controller action manually handles an error, the notifier will never be run. To manually notify of an error you can do something like the following:
|
267
234
|
|
268
235
|
```ruby
|
269
|
-
rescue_from Exception, :
|
236
|
+
rescue_from Exception, with: :server_error
|
270
237
|
|
271
238
|
def server_error(exception)
|
272
239
|
# Whatever code that handles the exception
|
273
240
|
|
274
|
-
ExceptionNotifier
|
275
|
-
|
241
|
+
ExceptionNotifier.notify_exception(
|
242
|
+
exception,
|
243
|
+
env: request.env, data: { message: 'was doing something wrong' }
|
244
|
+
)
|
276
245
|
end
|
277
246
|
```
|
278
247
|
|
279
|
-
Notification
|
280
|
-
---
|
281
|
-
|
282
|
-
After an exception notification has been delivered the rack environment variable
|
283
|
-
'exception_notifier.delivered' will be set to `true`.
|
284
|
-
|
285
|
-
|
286
|
-
Override SMTP settings
|
287
|
-
---
|
288
|
-
|
289
|
-
You can use specific SMTP settings for notifications:
|
290
248
|
|
291
|
-
|
292
|
-
Whatever::Application.config.middleware.use ExceptionNotifier,
|
293
|
-
:email_prefix => "[Whatever] ",
|
294
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
295
|
-
:exception_recipients => %w{exceptions@example.com},
|
296
|
-
:smtp_settings => {
|
297
|
-
:user_name => "bob",
|
298
|
-
:password => "password",
|
299
|
-
}
|
300
|
-
```
|
249
|
+
## Extras
|
301
250
|
|
302
|
-
|
303
|
-
---
|
251
|
+
### Rails
|
304
252
|
|
305
|
-
|
253
|
+
Since his first version, ExceptionNotification was just a simple rack middleware. But, the version 4.0.0 introduced the option to use it as a Rails engine. In order to use ExceptionNotification as an engine, just run the following command from the terminal:
|
306
254
|
|
307
|
-
|
255
|
+
rails g exception_notification:install
|
308
256
|
|
309
|
-
|
257
|
+
This command generates an initialize file (`config/initializers/exception_notification.rb`) where you can customize your configurations.
|
310
258
|
|
311
|
-
|
259
|
+
Make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
|
312
260
|
|
313
|
-
|
261
|
+
### Resque/Sidekiq
|
314
262
|
|
315
|
-
|
263
|
+
Instead of manually calling background notifications foreach job/worker, you can configure ExceptionNotification to do this automatically. For this, run:
|
316
264
|
|
317
|
-
|
265
|
+
rails g exception_notification:install --resque
|
318
266
|
|
319
|
-
|
267
|
+
or
|
320
268
|
|
321
|
-
|
269
|
+
rails g exception_notification:install --sidekiq
|
322
270
|
|
323
|
-
|
271
|
+
As above, make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
|
324
272
|
|
325
|
-
|
273
|
+
## Support and tickets
|
326
274
|
|
327
|
-
|
275
|
+
Here's the list of [issues](https://github.com/smartinez87/exception_notification/issues) we're currently working on.
|
328
276
|
|
329
|
-
|
277
|
+
To contribute, please read first the [Contributing Guide](https://github.com/smartinez87/exception_notification/blob/master/CONTRIBUTING.md).
|
330
278
|
|
331
|
-
|
332
|
-
---
|
279
|
+
## Code of Conduct
|
333
280
|
|
334
|
-
|
281
|
+
Everyone interacting in this project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow our [code of conduct](https://github.com/smartinez87/exception_notification/blob/master/CODE_OF_CONDUCT.md).
|
335
282
|
|
336
|
-
|
337
|
-
Guide](https://github.com/smartinez87/exception_notification/blob/master/CONTRIBUTING.md).
|
283
|
+
## License
|
338
284
|
|
339
|
-
Copyright (c) 2005 Jamis Buck, released under the MIT license
|
285
|
+
Copyright (c) 2005 Jamis Buck, released under the [MIT license](http://www.opensource.org/licenses/MIT).
|