exception_notification 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +2 -2
- data/CHANGELOG.rdoc +14 -0
- data/CONTRIBUTING.md +18 -0
- data/Gemfile +1 -1
- data/README.md +64 -935
- data/Rakefile +2 -2
- 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 +6 -6
- data/examples/sinatra/config.ru +1 -1
- data/examples/sinatra/sinatra_app.rb +14 -10
- data/exception_notification.gemspec +27 -22
- data/gemfiles/rails4_0.gemfile +3 -3
- data/gemfiles/rails4_1.gemfile +3 -3
- data/gemfiles/rails4_2.gemfile +3 -3
- data/gemfiles/rails5_0.gemfile +3 -3
- data/gemfiles/rails5_1.gemfile +3 -3
- data/gemfiles/rails5_2.gemfile +7 -0
- data/gemfiles/rails6_0.gemfile +7 -0
- data/lib/exception_notification.rb +1 -0
- data/lib/exception_notification/rack.rb +8 -21
- data/lib/exception_notification/resque.rb +8 -10
- data/lib/exception_notification/sidekiq.rb +8 -12
- data/lib/exception_notification/version.rb +3 -0
- data/lib/exception_notifier.rb +20 -3
- data/lib/exception_notifier/base_notifier.rb +2 -3
- data/lib/exception_notifier/campfire_notifier.rb +12 -13
- data/lib/exception_notifier/datadog_notifier.rb +153 -0
- data/lib/exception_notifier/email_notifier.rb +64 -87
- data/lib/exception_notifier/google_chat_notifier.rb +25 -119
- data/lib/exception_notifier/hipchat_notifier.rb +11 -12
- data/lib/exception_notifier/irc_notifier.rb +32 -30
- data/lib/exception_notifier/mattermost_notifier.rb +47 -140
- data/lib/exception_notifier/modules/backtrace_cleaner.rb +0 -2
- data/lib/exception_notifier/modules/error_grouping.rb +5 -5
- data/lib/exception_notifier/modules/formatter.rb +118 -0
- data/lib/exception_notifier/notifier.rb +5 -6
- data/lib/exception_notifier/slack_notifier.rb +63 -40
- data/lib/exception_notifier/sns_notifier.rb +17 -11
- data/lib/exception_notifier/teams_notifier.rb +58 -44
- data/lib/exception_notifier/views/exception_notifier/_backtrace.html.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/_environment.text.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/_request.text.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +2 -2
- data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +2 -2
- data/lib/exception_notifier/webhook_notifier.rb +14 -11
- data/lib/generators/exception_notification/install_generator.rb +5 -5
- data/lib/generators/exception_notification/templates/{exception_notification.rb → exception_notification.rb.erb} +13 -11
- data/test/exception_notification/rack_test.rb +27 -11
- data/test/exception_notification/resque_test.rb +52 -0
- data/test/exception_notifier/campfire_notifier_test.rb +42 -42
- data/test/exception_notifier/datadog_notifier_test.rb +151 -0
- data/test/exception_notifier/email_notifier_test.rb +269 -153
- data/test/exception_notifier/google_chat_notifier_test.rb +154 -101
- data/test/exception_notifier/hipchat_notifier_test.rb +78 -81
- data/test/exception_notifier/irc_notifier_test.rb +34 -34
- data/test/exception_notifier/mattermost_notifier_test.rb +164 -67
- data/test/exception_notifier/modules/error_grouping_test.rb +39 -40
- data/test/exception_notifier/modules/formatter_test.rb +150 -0
- data/test/exception_notifier/sidekiq_test.rb +6 -6
- data/test/exception_notifier/slack_notifier_test.rb +61 -60
- data/test/exception_notifier/sns_notifier_test.rb +27 -32
- data/test/exception_notifier/teams_notifier_test.rb +23 -26
- data/test/exception_notifier/webhook_notifier_test.rb +48 -46
- data/test/exception_notifier_test.rb +41 -38
- 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 +11 -14
- metadata +136 -166
- data/test/dummy/.gitignore +0 -4
- 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 -17
- data/test/dummy/config/environments/development.rb +0 -25
- data/test/dummy/config/environments/production.rb +0 -50
- 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 -8
- 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/functional/posts_controller_test.rb +0 -237
- data/test/dummy/test/test_helper.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f61027914f50eed12ef3c115cca8ba7a3f4f3b1e
|
4
|
+
data.tar.gz: 1a63465348250221f3a7d2171979a8d6b35639c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62cf62e3500f7edb53940bbe458a5b2e1936469033c4c643ad47d4ac9d3a913bd406fb7ca37cbf0d27b4f862b5487bd5736abdd37288aaaa904a125a00bd72bf
|
7
|
+
data.tar.gz: 0ffc513a9fd0ce553254665abfb6da9640a4e9eb3ff5edf39aa838b9baa3caffffd76f0ffab64417721cd7c4828fdabba8c6ab9c9f47077f800845418c38db52
|
data/Appraisals
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
rails_versions = ['~> 4.0.5', '~> 4.1.1', '~> 4.2.0', '~> 5.0.0', '~> 5.1.0']
|
1
|
+
rails_versions = ['~> 4.0.5', '~> 4.1.1', '~> 4.2.0', '~> 5.0.0', '~> 5.1.0', '~> 5.2.0']
|
2
2
|
|
3
3
|
rails_versions.each do |rails_version|
|
4
|
-
appraise "rails#{rails_version.slice(/\d+\.\d+/).
|
4
|
+
appraise "rails#{rails_version.slice(/\d+\.\d+/).tr('.', '_')}" do
|
5
5
|
gem 'rails', rails_version
|
6
6
|
end
|
7
7
|
end
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
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
|
+
|
1
15
|
== 4.3.0
|
2
16
|
|
3
17
|
* enhancements
|
data/CONTRIBUTING.md
CHANGED
@@ -18,6 +18,24 @@ 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
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
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](
|
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).
|
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
|
|
@@ -36,15 +36,15 @@ ExceptionNotification is used as a rack middleware, or in the environment you wa
|
|
36
36
|
|
37
37
|
```ruby
|
38
38
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
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
44
|
}
|
45
45
|
```
|
46
46
|
|
47
|
-
**Note**: In order to enable delivery notifications by email make sure you have [ActionMailer configured](#actionmailer-configuration).
|
47
|
+
**Note**: In order to enable delivery notifications by email make sure you have [ActionMailer configured](docs/notifiers/email.md#actionmailer-configuration).
|
48
48
|
|
49
49
|
### Rack/Sinatra
|
50
50
|
|
@@ -57,10 +57,12 @@ Save the current user in the `request` using a controller callback.
|
|
57
57
|
```ruby
|
58
58
|
class ApplicationController < ActionController::Base
|
59
59
|
before_action :prepare_exception_notifier
|
60
|
+
|
60
61
|
private
|
62
|
+
|
61
63
|
def prepare_exception_notifier
|
62
64
|
request.env["exception_notifier.exception_data"] = {
|
63
|
-
:
|
65
|
+
current_user: current_user
|
64
66
|
}
|
65
67
|
end
|
66
68
|
end
|
@@ -82,902 +84,48 @@ Options -> sections" below.
|
|
82
84
|
|
83
85
|
## Notifiers
|
84
86
|
|
85
|
-
ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default,
|
86
|
-
|
87
|
-
* [Campfire notifier](#campfire-notifier)
|
88
|
-
* [Email notifier](#email-notifier)
|
89
|
-
* [HipChat notifier](#hipchat-notifier)
|
90
|
-
* [IRC notifier](#irc-notifier)
|
91
|
-
* [Slack notifier](#slack-notifier)
|
92
|
-
* [Mattermost notifier](#mattermost-notifier)
|
93
|
-
* [Teams notifier](#teams-notifier)
|
94
|
-
* [Amazon SNS](#amazon-sns-notifier)
|
95
|
-
* [Google Chat notifier](#google-chat-notifier)
|
96
|
-
* [WebHook notifier](#webhook-notifier)
|
97
|
-
|
98
|
-
But, you also can easily implement your own [custom notifier](#custom-notifier).
|
99
|
-
|
100
|
-
### Campfire notifier
|
101
|
-
|
102
|
-
This notifier sends notifications to your Campfire room.
|
103
|
-
|
104
|
-
#### Usage
|
105
|
-
|
106
|
-
Just add the [tinder](https://github.com/collectiveidea/tinder) gem to your `Gemfile`:
|
107
|
-
|
108
|
-
```ruby
|
109
|
-
gem 'tinder'
|
110
|
-
```
|
111
|
-
|
112
|
-
To configure it, you need to set the `subdomain`, `token` and `room_name` options, like this:
|
113
|
-
|
114
|
-
```ruby
|
115
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
116
|
-
:email => {
|
117
|
-
:email_prefix => "[PREFIX] ",
|
118
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
119
|
-
:exception_recipients => %w{exceptions@example.com}
|
120
|
-
},
|
121
|
-
:campfire => {
|
122
|
-
:subdomain => 'my_subdomain',
|
123
|
-
:token => 'my_token',
|
124
|
-
:room_name => 'my_room'
|
125
|
-
}
|
126
|
-
```
|
127
|
-
|
128
|
-
#### Options
|
129
|
-
|
130
|
-
##### subdomain
|
131
|
-
|
132
|
-
*String, required*
|
133
|
-
|
134
|
-
Your subdomain at Campfire.
|
135
|
-
|
136
|
-
##### room_name
|
137
|
-
|
138
|
-
*String, required*
|
139
|
-
|
140
|
-
The Campfire room where the notifications must be published to.
|
141
|
-
|
142
|
-
##### token
|
143
|
-
|
144
|
-
*String, required*
|
145
|
-
|
146
|
-
The API token to allow access to your Campfire account.
|
147
|
-
|
148
|
-
|
149
|
-
For more options to set Campfire, like _ssl_, check [here](https://github.com/collectiveidea/tinder/blob/master/lib/tinder/campfire.rb#L17).
|
150
|
-
|
151
|
-
### Email notifier
|
152
|
-
|
153
|
-
The Email notifier sends notifications by email. The notifications/emails sent includes information about the current request, session, and environment, and also gives a backtrace of the exception.
|
154
|
-
|
155
|
-
After an exception notification has been delivered the rack environment variable `exception_notifier.delivered` will be set to true.
|
156
|
-
|
157
|
-
#### ActionMailer configuration
|
158
|
-
|
159
|
-
For the email to be sent, there must be a default ActionMailer `delivery_method` setting configured. If you do not have one, you can use the following code (assuming your app server machine has `sendmail`). Depending on the environment you want ExceptionNotification to run in, put the following code in your `config/environments/production.rb` and/or `config/environments/development.rb`:
|
160
|
-
|
161
|
-
```ruby
|
162
|
-
config.action_mailer.delivery_method = :sendmail
|
163
|
-
# Defaults to:
|
164
|
-
# config.action_mailer.sendmail_settings = {
|
165
|
-
# :location => '/usr/sbin/sendmail',
|
166
|
-
# :arguments => '-i -t'
|
167
|
-
# }
|
168
|
-
config.action_mailer.perform_deliveries = true
|
169
|
-
config.action_mailer.raise_delivery_errors = true
|
170
|
-
```
|
171
|
-
|
172
|
-
#### Options
|
173
|
-
|
174
|
-
##### sender_address
|
175
|
-
|
176
|
-
*String, default: %("Exception Notifier" <exception.notifier@example.com>)*
|
177
|
-
|
178
|
-
Who the message is from.
|
179
|
-
|
180
|
-
##### exception_recipients
|
181
|
-
|
182
|
-
*String/Array of strings/Proc, default: []*
|
183
|
-
|
184
|
-
Who the message is destined for, can be a string of addresses, an array of addresses, or it can be a proc that returns a string of addresses or an array of addresses. The proc will be evaluated when the mail is sent.
|
185
|
-
|
186
|
-
##### email_prefix
|
187
|
-
|
188
|
-
*String, default: [ERROR]*
|
189
|
-
|
190
|
-
The subject's prefix of the message.
|
191
|
-
|
192
|
-
##### sections
|
193
|
-
|
194
|
-
*Array of strings, default: %w(request session environment backtrace)*
|
195
|
-
|
196
|
-
By default, the notification email includes four parts: request, session, environment, and backtrace (in that order). You can customize how each of those sections are rendered by placing a partial named for that part in your `app/views/exception_notifier` directory (e.g., `_session.rhtml`). Each partial has access to the following variables:
|
197
|
-
|
198
|
-
```ruby
|
199
|
-
@kontroller # the controller that caused the error
|
200
|
-
@request # the current request object
|
201
|
-
@exception # the exception that was raised
|
202
|
-
@backtrace # a sanitized version of the exception's backtrace
|
203
|
-
@data # a hash of optional data values that were passed to the notifier
|
204
|
-
@sections # the array of sections to include in the email
|
205
|
-
```
|
206
|
-
|
207
|
-
You can reorder the sections, or exclude sections completely, by using `sections` option. You can even add new sections that
|
208
|
-
describe application-specific data--just add the section's name to the list (wherever you'd like), and define the corresponding partial. Like the following example with two new added sections:
|
209
|
-
|
210
|
-
```ruby
|
211
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
212
|
-
:email => {
|
213
|
-
:email_prefix => "[PREFIX] ",
|
214
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
215
|
-
:exception_recipients => %w{exceptions@example.com},
|
216
|
-
:sections => %w{my_section1 my_section2}
|
217
|
-
}
|
218
|
-
```
|
219
|
-
|
220
|
-
Place your custom sections under `./app/views/exception_notifier/` with the suffix `.text.erb`, e.g. `./app/views/exception_notifier/_my_section1.text.erb`.
|
221
|
-
|
222
|
-
If your new section requires information that isn't available by default, make sure it is made available to the email using the `exception_data` macro:
|
223
|
-
|
224
|
-
```ruby
|
225
|
-
class ApplicationController < ActionController::Base
|
226
|
-
before_action :log_additional_data
|
227
|
-
...
|
228
|
-
protected
|
229
|
-
def log_additional_data
|
230
|
-
request.env["exception_notifier.exception_data"] = {
|
231
|
-
:document => @document,
|
232
|
-
:person => @person
|
233
|
-
}
|
234
|
-
end
|
235
|
-
...
|
236
|
-
end
|
237
|
-
```
|
238
|
-
|
239
|
-
In the above case, `@document` and `@person` would be made available to the email renderer, allowing your new section(s) to access and display them. See the existing sections defined by the plugin for examples of how to write your own.
|
240
|
-
|
241
|
-
##### background_sections
|
242
|
-
|
243
|
-
*Array of strings, default: %w(backtrace data)*
|
244
|
-
|
245
|
-
When using [background notifications](#background-notifications) some variables are not available in the views, like `@kontroller` and `@request`. Thus, you may want to include different sections for background notifications:
|
246
|
-
|
247
|
-
```ruby
|
248
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
249
|
-
:email => {
|
250
|
-
:email_prefix => "[PREFIX] ",
|
251
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
252
|
-
:exception_recipients => %w{exceptions@example.com},
|
253
|
-
:background_sections => %w{my_section1 my_section2 backtrace data}
|
254
|
-
}
|
255
|
-
```
|
256
|
-
|
257
|
-
##### email_headers
|
258
|
-
|
259
|
-
*Hash of strings, default: {}*
|
260
|
-
|
261
|
-
Additionally, you may want to set customized headers on the outcoming emails. To do so, simply use the `:email_headers` option:
|
262
|
-
|
263
|
-
```ruby
|
264
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
265
|
-
:email => {
|
266
|
-
:email_prefix => "[PREFIX] ",
|
267
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
268
|
-
:exception_recipients => %w{exceptions@example.com},
|
269
|
-
:email_headers => { "X-Custom-Header" => "foobar" }
|
270
|
-
}
|
271
|
-
```
|
272
|
-
|
273
|
-
##### verbose_subject
|
274
|
-
|
275
|
-
*Boolean, default: true*
|
276
|
-
|
277
|
-
If enabled, include the exception message in the subject. Use `:verbose_subject => false` to exclude it.
|
278
|
-
|
279
|
-
##### normalize_subject
|
280
|
-
|
281
|
-
*Boolean, default: false*
|
282
|
-
|
283
|
-
If enabled, remove numbers from subject so they thread as a single one. Use `:normalize_subject => true` to enable it.
|
284
|
-
|
285
|
-
##### include_controller_and_action_names_in_subject
|
286
|
-
|
287
|
-
*Boolean, default: true*
|
288
|
-
|
289
|
-
If enabled, include the controller and action names in the subject. Use `:include_controller_and_action_names_in_subject => false` to exclude them.
|
290
|
-
|
291
|
-
##### email_format
|
292
|
-
|
293
|
-
*Symbol, default: :text*
|
294
|
-
|
295
|
-
By default, ExceptionNotification sends emails in plain text, in order to sends multipart notifications (aka HTML emails) use `:email_format => :html`.
|
296
|
-
|
297
|
-
##### delivery_method
|
298
|
-
|
299
|
-
*Symbol, default: :smtp*
|
300
|
-
|
301
|
-
By default, ExceptionNotification sends emails using the ActionMailer configuration of the application. In order to send emails by another delivery method, use the `delivery_method` option:
|
302
|
-
|
303
|
-
```ruby
|
304
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
305
|
-
:email => {
|
306
|
-
:email_prefix => "[PREFIX] ",
|
307
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
308
|
-
:exception_recipients => %w{exceptions@example.com},
|
309
|
-
:delivery_method => :postmark,
|
310
|
-
:postmark_settings => {
|
311
|
-
:api_key => ENV["POSTMARK_API_KEY"]
|
312
|
-
}
|
313
|
-
}
|
314
|
-
```
|
315
|
-
|
316
|
-
Besides the `delivery_method` option, you also can customize the mailer settings by passing a hash under an option named `DELIVERY_METHOD_settings`. Thus, you can use override specific SMTP settings for notifications using:
|
317
|
-
|
318
|
-
```ruby
|
319
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
320
|
-
:email => {
|
321
|
-
:email_prefix => "[PREFIX] ",
|
322
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
323
|
-
:exception_recipients => %w{exceptions@example.com},
|
324
|
-
:delivery_method => :smtp,
|
325
|
-
:smtp_settings => {
|
326
|
-
:user_name => "bob",
|
327
|
-
:password => "password",
|
328
|
-
}
|
329
|
-
}
|
330
|
-
```
|
331
|
-
|
332
|
-
A complete list of `smtp_settings` options can be found in the [ActionMailer Configuration documentation](http://api.rubyonrails.org/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Configuration+options).
|
333
|
-
|
334
|
-
##### mailer_parent
|
335
|
-
|
336
|
-
*String, default: ActionMailer::Base*
|
337
|
-
|
338
|
-
The parent mailer which ExceptionNotification mailer inherit from.
|
339
|
-
|
340
|
-
##### deliver_with
|
341
|
-
|
342
|
-
*Symbol, default: :deliver_now
|
343
|
-
|
344
|
-
The method name to send emalis using ActionMailer.
|
345
|
-
|
346
|
-
### HipChat notifier
|
347
|
-
|
348
|
-
This notifier sends notifications to your Hipchat room.
|
349
|
-
|
350
|
-
#### Usage
|
351
|
-
|
352
|
-
Just add the [hipchat](https://github.com/hipchat/hipchat-rb) gem to your `Gemfile`:
|
353
|
-
|
354
|
-
```ruby
|
355
|
-
gem 'hipchat'
|
356
|
-
```
|
357
|
-
|
358
|
-
To configure it, you need to set the `token` and `room_name` options, like this:
|
359
|
-
|
360
|
-
```ruby
|
361
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
362
|
-
:email => {
|
363
|
-
:email_prefix => "[PREFIX] ",
|
364
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
365
|
-
:exception_recipients => %w{exceptions@example.com}
|
366
|
-
},
|
367
|
-
:hipchat => {
|
368
|
-
:api_token => 'my_token',
|
369
|
-
:room_name => 'my_room'
|
370
|
-
}
|
371
|
-
```
|
372
|
-
|
373
|
-
#### Options
|
374
|
-
|
375
|
-
##### room_name
|
376
|
-
|
377
|
-
*String, required*
|
378
|
-
|
379
|
-
The HipChat room where the notifications must be published to.
|
380
|
-
|
381
|
-
##### api_token
|
382
|
-
|
383
|
-
*String, required*
|
384
|
-
|
385
|
-
The API token to allow access to your HipChat account.
|
386
|
-
|
387
|
-
##### notify
|
388
|
-
|
389
|
-
*Boolean, optional*
|
390
|
-
|
391
|
-
Notify users. Default : false.
|
392
|
-
|
393
|
-
##### color
|
394
|
-
|
395
|
-
*String, optional*
|
396
|
-
|
397
|
-
Color of the message. Default : 'red'.
|
398
|
-
|
399
|
-
##### from
|
400
|
-
|
401
|
-
*String, optional, maximum length : 15*
|
402
|
-
|
403
|
-
Message will appear from this nickname. Default : 'Exception'.
|
404
|
-
|
405
|
-
##### server_url
|
406
|
-
|
407
|
-
*String, optional*
|
408
|
-
|
409
|
-
Custom Server URL for self-hosted, Enterprise HipChat Server
|
410
|
-
|
411
|
-
For all options & possible values see [Hipchat API](https://www.hipchat.com/docs/api/method/rooms/message).
|
412
|
-
|
413
|
-
### IRC notifier
|
414
|
-
|
415
|
-
This notifier sends notifications to an IRC channel using the carrier-pigeon gem.
|
416
|
-
|
417
|
-
#### Usage
|
418
|
-
|
419
|
-
Just add the [carrier-pigeon](https://github.com/portertech/carrier-pigeon) gem to your `Gemfile`:
|
420
|
-
|
421
|
-
```ruby
|
422
|
-
gem 'carrier-pigeon'
|
423
|
-
```
|
424
|
-
|
425
|
-
To configure it, you need to set at least the 'domain' option, like this:
|
426
|
-
|
427
|
-
```ruby
|
428
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
429
|
-
:email => {
|
430
|
-
:email_prefix => "[PREFIX] ",
|
431
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
432
|
-
:exception_recipients => %w{exceptions@example.com}
|
433
|
-
},
|
434
|
-
:irc => {
|
435
|
-
:domain => 'irc.example.com'
|
436
|
-
}
|
437
|
-
```
|
438
|
-
|
439
|
-
There are several other options, which are described below. For example, to use ssl and a password, add a prefix, post to the '#log' channel, and include recipients in the message (so that they will be notified), your configuration might look like this:
|
440
|
-
|
441
|
-
```ruby
|
442
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
443
|
-
:irc => {
|
444
|
-
:domain => 'irc.example.com',
|
445
|
-
:nick => 'BadNewsBot',
|
446
|
-
:password => 'secret',
|
447
|
-
:port => 6697,
|
448
|
-
:channel => '#log',
|
449
|
-
:ssl => true,
|
450
|
-
:prefix => '[Exception Notification]',
|
451
|
-
:recipients => ['peter', 'michael', 'samir']
|
452
|
-
}
|
453
|
-
|
454
|
-
```
|
455
|
-
|
456
|
-
#### Options
|
457
|
-
|
458
|
-
##### domain
|
459
|
-
|
460
|
-
*String, required*
|
461
|
-
|
462
|
-
The domain name of your IRC server.
|
463
|
-
|
464
|
-
##### nick
|
465
|
-
|
466
|
-
*String, optional*
|
467
|
-
|
468
|
-
The message will appear from this nick. Default : 'ExceptionNotifierBot'.
|
469
|
-
|
470
|
-
##### password
|
471
|
-
|
472
|
-
*String, optional*
|
473
|
-
|
474
|
-
Password for your IRC server.
|
475
|
-
|
476
|
-
##### port
|
477
|
-
|
478
|
-
*String, optional*
|
479
|
-
|
480
|
-
Port your IRC server is listening on. Default : 6667.
|
481
|
-
|
482
|
-
##### channel
|
483
|
-
|
484
|
-
*String, optional*
|
485
|
-
|
486
|
-
Message will appear in this channel. Default : '#log'.
|
487
|
-
|
488
|
-
##### notice
|
489
|
-
|
490
|
-
*Boolean, optional*
|
491
|
-
|
492
|
-
Send a notice. Default : false.
|
493
|
-
|
494
|
-
##### ssl
|
495
|
-
|
496
|
-
*Boolean, optional*
|
497
|
-
|
498
|
-
Whether to use SSL. Default : false.
|
499
|
-
|
500
|
-
##### join
|
501
|
-
|
502
|
-
*Boolean, optional*
|
503
|
-
|
504
|
-
Join a channel. Default : false.
|
505
|
-
|
506
|
-
##### recipients
|
507
|
-
|
508
|
-
*Array of strings, optional*
|
509
|
-
|
510
|
-
Nicks to include in the message. Default: []
|
511
|
-
|
512
|
-
### Slack notifier
|
513
|
-
|
514
|
-
This notifier sends notifications to a slack channel using the slack-notifier gem.
|
515
|
-
|
516
|
-
#### Usage
|
517
|
-
|
518
|
-
Just add the [slack-notifier](https://github.com/stevenosloan/slack-notifier) gem to your `Gemfile`:
|
519
|
-
|
520
|
-
```ruby
|
521
|
-
gem 'slack-notifier'
|
522
|
-
```
|
523
|
-
|
524
|
-
To configure it, you need to set at least the 'webhook_url' option, like this:
|
525
|
-
|
526
|
-
```ruby
|
527
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
528
|
-
:email => {
|
529
|
-
:email_prefix => "[PREFIX] ",
|
530
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
531
|
-
:exception_recipients => %w{exceptions@example.com}
|
532
|
-
},
|
533
|
-
:slack => {
|
534
|
-
:webhook_url => "[Your webhook url]",
|
535
|
-
:channel => "#exceptions",
|
536
|
-
:additional_parameters => {
|
537
|
-
:icon_url => "http://image.jpg",
|
538
|
-
:mrkdwn => true
|
539
|
-
}
|
540
|
-
}
|
541
|
-
```
|
542
|
-
|
543
|
-
The slack notification will include any data saved under `env["exception_notifier.exception_data"]`.
|
544
|
-
|
545
|
-
An example of how to send the server name to Slack in Rails (put this code in application_controller.rb):
|
546
|
-
|
547
|
-
```ruby
|
548
|
-
before_action :set_notification
|
549
|
-
|
550
|
-
def set_notification
|
551
|
-
request.env['exception_notifier.exception_data'] = {"server" => request.env['SERVER_NAME']}
|
552
|
-
# can be any key-value pairs
|
553
|
-
end
|
554
|
-
```
|
555
|
-
|
556
|
-
If you find this too verbose, you can determine to exclude certain information by doing the following:
|
557
|
-
|
558
|
-
```ruby
|
559
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
560
|
-
:slack => {
|
561
|
-
:webhook_url => "[Your webhook url]",
|
562
|
-
:channel => "#exceptions",
|
563
|
-
:additional_parameters => {
|
564
|
-
:icon_url => "http://image.jpg",
|
565
|
-
:mrkdwn => true
|
566
|
-
},
|
567
|
-
:ignore_data_if => lambda {|key, value|
|
568
|
-
"#{key}" == 'key_to_ignore' || value.is_a?(ClassToBeIgnored)
|
569
|
-
}
|
570
|
-
}
|
571
|
-
```
|
572
|
-
|
573
|
-
Any evaluation to `true` will cause the key / value pair not be be sent along to Slack.
|
574
|
-
|
575
|
-
#### Options
|
576
|
-
|
577
|
-
##### webhook_url
|
578
|
-
|
579
|
-
*String, required*
|
580
|
-
|
581
|
-
The Incoming WebHook URL on slack.
|
582
|
-
|
583
|
-
##### channel
|
584
|
-
|
585
|
-
*String, optional*
|
586
|
-
|
587
|
-
Message will appear in this channel. Defaults to the channel you set as such on slack.
|
588
|
-
|
589
|
-
##### username
|
590
|
-
|
591
|
-
*String, optional*
|
592
|
-
|
593
|
-
Username of the bot. Defaults to the name you set as such on slack
|
594
|
-
|
595
|
-
##### custom_hook
|
596
|
-
|
597
|
-
*String, optional*
|
598
|
-
|
599
|
-
Custom hook name. See [slack-notifier](https://github.com/stevenosloan/slack-notifier#custom-hook-name) for
|
600
|
-
more information. Default: 'incoming-webhook'
|
601
|
-
|
602
|
-
##### additional_parameters
|
603
|
-
|
604
|
-
*Hash of strings, optional*
|
605
|
-
|
606
|
-
Contains additional payload for a message (e.g avatar, attachments, etc). See [slack-notifier](https://github.com/stevenosloan/slack-notifier#additional-parameters) for more information.. Default: '{}'
|
607
|
-
|
608
|
-
##### additional_fields
|
609
|
-
|
610
|
-
*Array of Hashes, optional*
|
611
|
-
|
612
|
-
Contains additional fields that will be added to the attachement. See [Slack documentation](https://api.slack.com/docs/message-attachments).
|
613
|
-
|
614
|
-
### Mattermost notifier
|
615
|
-
|
616
|
-
Post notification in a mattermost channel via [incoming webhook](http://docs.mattermost.com/developer/webhooks-incoming.html)
|
617
|
-
|
618
|
-
Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
|
619
|
-
|
620
|
-
```ruby
|
621
|
-
gem 'httparty'
|
622
|
-
```
|
623
|
-
|
624
|
-
To configure it, you **need** to set the `webhook_url` option.
|
625
|
-
You can also specify an other channel with `channel` option.
|
626
|
-
|
627
|
-
```ruby
|
628
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
629
|
-
:email => {
|
630
|
-
:email_prefix => "[PREFIX] ",
|
631
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
632
|
-
:exception_recipients => %w{exceptions@example.com}
|
633
|
-
},
|
634
|
-
:mattermost => {
|
635
|
-
:webhook_url => 'http://your-mattermost.com/hooks/blablabla',
|
636
|
-
:channel => 'my-channel'
|
637
|
-
}
|
638
|
-
```
|
639
|
-
|
640
|
-
If you are using Github or Gitlab for issues tracking, you can specify `git_url` as follow to add a *Create issue* link in you notification.
|
641
|
-
By default this will use your Rails application name to match the git repository. If yours differ you can specify `app_name`.
|
642
|
-
|
643
|
-
|
644
|
-
```ruby
|
645
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
646
|
-
:email => {
|
647
|
-
:email_prefix => "[PREFIX] ",
|
648
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
649
|
-
:exception_recipients => %w{exceptions@example.com}
|
650
|
-
},
|
651
|
-
:mattermost => {
|
652
|
-
:webhook_url => 'http://your-mattermost.com/hooks/blablabla',
|
653
|
-
:git_url => 'github.com/aschen'
|
654
|
-
}
|
655
|
-
```
|
656
|
-
|
657
|
-
You can also specify the bot name and avatar with `username` and `avatar` options.
|
658
|
-
|
659
|
-
```ruby
|
660
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
661
|
-
:email => {
|
662
|
-
:email_prefix => "[PREFIX] ",
|
663
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
664
|
-
:exception_recipients => %w{exceptions@example.com}
|
665
|
-
},
|
666
|
-
:mattermost => {
|
667
|
-
:webhook_url => 'http://your-mattermost.com/hooks/blablabla',
|
668
|
-
:avatar => 'http://example.com/your-image.png',
|
669
|
-
:username => 'Fail bot'
|
670
|
-
}
|
671
|
-
```
|
672
|
-
|
673
|
-
Finally since the notifier use HTTParty, you can include all HTTParty options, like basic_auth for example.
|
674
|
-
|
675
|
-
```ruby
|
676
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
677
|
-
:email => {
|
678
|
-
:email_prefix => "[PREFIX] ",
|
679
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
680
|
-
:exception_recipients => %w{exceptions@example.com}
|
681
|
-
},
|
682
|
-
:mattermost => {
|
683
|
-
:webhook_url => 'http://your-mattermost.com/hooks/blablabla',
|
684
|
-
:basic_auth => {
|
685
|
-
:username => 'clara',
|
686
|
-
:password => 'password'
|
687
|
-
}
|
688
|
-
}
|
689
|
-
```
|
690
|
-
|
691
|
-
#### Options
|
692
|
-
|
693
|
-
##### webhook_url
|
694
|
-
|
695
|
-
*String, required*
|
696
|
-
|
697
|
-
The Incoming WebHook URL on mattermost.
|
698
|
-
|
699
|
-
##### channel
|
700
|
-
|
701
|
-
*String, optional*
|
702
|
-
|
703
|
-
Message will appear in this channel. Defaults to the channel you set as such on mattermost.
|
704
|
-
|
705
|
-
##### username
|
706
|
-
|
707
|
-
*String, optional*
|
708
|
-
|
709
|
-
Username of the bot. Defaults to "Incoming Webhook"
|
710
|
-
|
711
|
-
##### avatar
|
712
|
-
|
713
|
-
*String, optional*
|
714
|
-
|
715
|
-
Avatar of the bot. Defaults to incoming webhook icon.
|
716
|
-
|
717
|
-
##### git_url
|
718
|
-
|
719
|
-
*String, optional*
|
720
|
-
|
721
|
-
Url of your gitlab or github with your organisation name for issue creation link (Eg: `github.com/aschen`). Defaults to nil and don't add link to the notification.
|
722
|
-
|
723
|
-
##### app_name
|
724
|
-
|
725
|
-
*String, optional*
|
726
|
-
|
727
|
-
Your application name used for issue creation link. Defaults to ``` Rails.application.class.parent_name.underscore```.
|
728
|
-
|
729
|
-
### Google Chat Notifier
|
730
|
-
|
731
|
-
Post notifications in a Google Chats channel via [incoming webhook](https://developers.google.com/hangouts/chat/how-tos/webhooks)
|
732
|
-
|
733
|
-
Add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
|
734
|
-
|
735
|
-
```ruby
|
736
|
-
gem 'httparty'
|
737
|
-
```
|
738
|
-
|
739
|
-
To configure it, you **need** to set the `webhook_url` option.
|
740
|
-
|
741
|
-
```ruby
|
742
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
743
|
-
:google_chat => {
|
744
|
-
:webhook_url => 'https://chat.googleapis.com/v1/spaces/XXXXXXXX/messages?key=YYYYYYYYYYYYY&token=ZZZZZZZZZZZZ'
|
745
|
-
}
|
746
|
-
```
|
747
|
-
|
748
|
-
##### webhook_url
|
749
|
-
|
750
|
-
*String, required*
|
751
|
-
|
752
|
-
The Incoming WebHook URL on Google Chats.
|
753
|
-
|
754
|
-
##### app_name
|
755
|
-
|
756
|
-
*String, optional*
|
757
|
-
|
758
|
-
Your application name, shown in the notification. Defaults to `Rails.application.class.parent_name.underscore`.
|
87
|
+
ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default, 8 notifiers are available:
|
759
88
|
|
760
|
-
|
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)
|
761
100
|
|
762
|
-
|
763
|
-
|
764
|
-
#### Usage
|
765
|
-
|
766
|
-
Add the [aws-sdk-sns](https://github.com/aws/aws-sdk-ruby/tree/master/gems/aws-sdk-sns) gem to your `Gemfile`:
|
767
|
-
|
768
|
-
```ruby
|
769
|
-
gem 'aws-sdk-sns', '~> 1.5'
|
770
|
-
```
|
771
|
-
|
772
|
-
To configure it, you **need** to set 3 required options for aws: `region`, `access_key_id` and `secret_access_key`, and one more option for sns: `topic_arn`.
|
773
|
-
|
774
|
-
```ruby
|
775
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
776
|
-
sns: {
|
777
|
-
region: 'us-east-x',
|
778
|
-
access_key_id: 'access_key_id',
|
779
|
-
secret_access_key: 'secret_access_key',
|
780
|
-
topic_arn: 'arn:aws:sns:us-east-x:XXXX:my-topic'
|
781
|
-
}
|
782
|
-
```
|
783
|
-
|
784
|
-
##### sns_prefix
|
785
|
-
*String, optional *
|
786
|
-
|
787
|
-
Prefix in the notification subject, by default: "[Error]"
|
788
|
-
|
789
|
-
##### backtrace_lines
|
790
|
-
*Integer, optional *
|
791
|
-
|
792
|
-
Number of backtrace lines to be displayed in the notification message. By default: 10
|
793
|
-
|
794
|
-
#### Note:
|
795
|
-
* You may need to update your previous `aws-sdk-*` gems in order to setup `aws-sdk-sns` correctly.
|
796
|
-
* If you need any further information about the available regions or any other SNS related topic consider: [SNS faqs](https://aws.amazon.com/sns/faqs/)
|
797
|
-
|
798
|
-
### Teams notifier
|
799
|
-
|
800
|
-
Post notification in a Microsoft Teams channel via [Incoming Webhook Connector](https://docs.microsoft.com/en-us/outlook/actionable-messages/actionable-messages-via-connectors)
|
801
|
-
Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
|
802
|
-
|
803
|
-
```ruby
|
804
|
-
gem 'httparty'
|
805
|
-
```
|
806
|
-
|
807
|
-
To configure it, you **need** to set the `webhook_url` option.
|
808
|
-
If you are using GitLab for issue tracking, you can specify `git_url` as follows to add a *Create issue* button in your notification.
|
809
|
-
By default this will use your Rails application name to match the git repository. If yours differs, you can specify `app_name`.
|
810
|
-
By that same notion, you may also set a `jira_url` to get a button that will send you to the New Issue screen in Jira.
|
811
|
-
|
812
|
-
```ruby
|
813
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
814
|
-
:email => {
|
815
|
-
:email_prefix => "[PREFIX] ",
|
816
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
817
|
-
:exception_recipients => %w{exceptions@example.com}
|
818
|
-
},
|
819
|
-
:teams => {
|
820
|
-
:webhook_url => 'https://outlook.office.com/webhook/your-guid/IncomingWebhook/team-guid',
|
821
|
-
:git_url => 'https://your-gitlab.com/Group/Project',
|
822
|
-
:jira_url => 'https://your-jira.com'
|
823
|
-
}
|
824
|
-
```
|
825
|
-
|
826
|
-
#### Options
|
827
|
-
|
828
|
-
##### webhook_url
|
829
|
-
|
830
|
-
*String, required*
|
831
|
-
|
832
|
-
The Incoming WebHook URL on mattermost.
|
833
|
-
|
834
|
-
##### git_url
|
835
|
-
|
836
|
-
*String, optional*
|
837
|
-
|
838
|
-
Url of your gitlab or github with your organisation name for issue creation link (Eg: `github.com/aschen`). Defaults to nil and doesn't add link to the notification.
|
839
|
-
|
840
|
-
##### jira_url
|
841
|
-
|
842
|
-
*String, optional*
|
843
|
-
|
844
|
-
Url of your Jira instance, adds button for Create Issue screen. Defaults to nil and doesn't add a button to the card.
|
845
|
-
|
846
|
-
##### app_name
|
847
|
-
|
848
|
-
*String, optional*
|
849
|
-
|
850
|
-
Your application name used for git issue creation link. Defaults to `Rails.application.class.parent_name.underscore`.
|
851
|
-
|
852
|
-
### WebHook notifier
|
853
|
-
|
854
|
-
This notifier ships notifications over the HTTP protocol.
|
855
|
-
|
856
|
-
#### Usage
|
857
|
-
|
858
|
-
Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
|
859
|
-
|
860
|
-
```ruby
|
861
|
-
gem 'httparty'
|
862
|
-
```
|
863
|
-
|
864
|
-
To configure it, you need to set the `url` option, like this:
|
865
|
-
|
866
|
-
```ruby
|
867
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
868
|
-
:email => {
|
869
|
-
:email_prefix => "[PREFIX] ",
|
870
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
871
|
-
:exception_recipients => %w{exceptions@example.com}
|
872
|
-
},
|
873
|
-
:webhook => {
|
874
|
-
:url => 'http://domain.com:5555/hubot/path'
|
875
|
-
}
|
876
|
-
```
|
877
|
-
|
878
|
-
By default, the WebhookNotifier will call the URLs using the POST method. But, you can change this using the `http_method` option.
|
879
|
-
|
880
|
-
```ruby
|
881
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
882
|
-
:email => {
|
883
|
-
:email_prefix => "[PREFIX] ",
|
884
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
885
|
-
:exception_recipients => %w{exceptions@example.com}
|
886
|
-
},
|
887
|
-
:webhook => {
|
888
|
-
:url => 'http://domain.com:5555/hubot/path',
|
889
|
-
:http_method => :get
|
890
|
-
}
|
891
|
-
```
|
892
|
-
|
893
|
-
Besides the `url` and `http_method` options, all the other options are passed directly to HTTParty. Thus, if the HTTP server requires authentication, you can include the following options:
|
894
|
-
|
895
|
-
```ruby
|
896
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
897
|
-
:email => {
|
898
|
-
:email_prefix => "[PREFIX] ",
|
899
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
900
|
-
:exception_recipients => %w{exceptions@example.com}
|
901
|
-
},
|
902
|
-
:webhook => {
|
903
|
-
:url => 'http://domain.com:5555/hubot/path',
|
904
|
-
:basic_auth => {
|
905
|
-
:username => 'alice',
|
906
|
-
:password => 'password'
|
907
|
-
}
|
908
|
-
}
|
909
|
-
```
|
910
|
-
|
911
|
-
For more HTTParty options, check out the [documentation](https://github.com/jnunemaker/httparty).
|
912
|
-
|
913
|
-
### Custom notifier
|
914
|
-
|
915
|
-
Simply put, notifiers are objects which respond to `#call(exception, options)` method. Thus, a lambda can be used as a notifier as follow:
|
916
|
-
|
917
|
-
```ruby
|
918
|
-
ExceptionNotifier.add_notifier :custom_notifier_name,
|
919
|
-
->(exception, options) { puts "Something goes wrong: #{exception.message}"}
|
920
|
-
```
|
921
|
-
|
922
|
-
More advanced users or third-party framework developers, also can create notifiers to be shipped in gems and take advantage of ExceptionNotification's Notifier API to standardize the [various](https://github.com/airbrake/airbrake) [solutions](https://www.honeybadger.io) [out](http://www.exceptional.io) [there](https://bugsnag.com). For this, beyond the `#call(exception, options)` method, the notifier class MUST BE defined under the ExceptionNotifier namespace and its name sufixed by `Notifier`, e.g: ExceptionNotifier::SimpleNotifier.
|
923
|
-
|
924
|
-
#### Example
|
925
|
-
|
926
|
-
Define the custom notifier:
|
927
|
-
|
928
|
-
```ruby
|
929
|
-
module ExceptionNotifier
|
930
|
-
class SimpleNotifier
|
931
|
-
def initialize(options)
|
932
|
-
# do something with the options...
|
933
|
-
end
|
934
|
-
|
935
|
-
def call(exception, options={})
|
936
|
-
# send the notification
|
937
|
-
end
|
938
|
-
end
|
939
|
-
end
|
940
|
-
```
|
941
|
-
|
942
|
-
Using it:
|
943
|
-
|
944
|
-
```ruby
|
945
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
946
|
-
:email => {
|
947
|
-
:email_prefix => "[PREFIX] ",
|
948
|
-
:sender_address => %{"notifier" <notifier@example.com>},
|
949
|
-
:exception_recipients => %w{exceptions@example.com}
|
950
|
-
},
|
951
|
-
:simple => {
|
952
|
-
# simple notifier options
|
953
|
-
}
|
954
|
-
```
|
101
|
+
But, you also can easily implement your own [custom notifier](docs/notifiers/custom.md).
|
955
102
|
|
956
103
|
## Error Grouping
|
957
|
-
In general, exception notification will send every notification when an error occured, which may result in a problem: if your site has a high throughput and an same error raised frequently, you will receive too many notifications during a short period time, your mail box may be full of thousands of exception mails or even your mail server will be slow. To prevent this, you can choose to error errors by using `:error_grouping` option and set it to `true`.
|
958
104
|
|
959
|
-
|
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`.
|
106
|
+
|
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.
|
960
108
|
|
961
|
-
The
|
109
|
+
The following code shows the available options to configure error grouping:
|
962
110
|
|
963
111
|
```ruby
|
964
112
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
965
|
-
:
|
966
|
-
:
|
967
|
-
:
|
968
|
-
:
|
969
|
-
:
|
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}
|
970
118
|
},
|
971
|
-
:
|
972
|
-
# :
|
973
|
-
# :
|
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
|
974
122
|
#
|
975
123
|
# notification_trigger: specify a callback to determine when a notification should be sent,
|
976
124
|
# the callback will be invoked with two arguments:
|
977
125
|
# exception: the exception raised
|
978
126
|
# count: accumulated errors count for this exception
|
979
127
|
#
|
980
|
-
# :
|
128
|
+
# notification_trigger: lambda { |exception, count| count % 10 == 0 }
|
981
129
|
```
|
982
130
|
|
983
131
|
## Ignore Exceptions
|
@@ -999,12 +147,12 @@ Ignore specified exception types. To achieve that, you should use the `:ignore_e
|
|
999
147
|
|
1000
148
|
```ruby
|
1001
149
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
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
|
+
}
|
1008
156
|
```
|
1009
157
|
|
1010
158
|
The above will make ExceptionNotifier ignore a *TemplateError* exception, plus the ones ignored by default.
|
@@ -1017,12 +165,12 @@ In some cases you may want to avoid getting notifications from exceptions made b
|
|
1017
165
|
|
1018
166
|
```ruby
|
1019
167
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
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
|
+
}
|
1026
174
|
```
|
1027
175
|
|
1028
176
|
### :ignore_if
|
@@ -1033,12 +181,12 @@ Last but not least, you can ignore exceptions based on a condition. Take a look:
|
|
1033
181
|
|
1034
182
|
```ruby
|
1035
183
|
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
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
|
+
}
|
1042
190
|
```
|
1043
191
|
|
1044
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.
|
@@ -1072,9 +220,11 @@ You can include information about the background process that created the error
|
|
1072
220
|
```ruby
|
1073
221
|
begin
|
1074
222
|
some code...
|
1075
|
-
rescue =>
|
1076
|
-
ExceptionNotifier.notify_exception(
|
1077
|
-
|
223
|
+
rescue => e
|
224
|
+
ExceptionNotifier.notify_exception(
|
225
|
+
e,
|
226
|
+
data: { worker: worker.to_s, queue: queue, payload: payload}
|
227
|
+
)
|
1078
228
|
end
|
1079
229
|
```
|
1080
230
|
|
@@ -1083,13 +233,15 @@ end
|
|
1083
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:
|
1084
234
|
|
1085
235
|
```ruby
|
1086
|
-
rescue_from Exception, :
|
236
|
+
rescue_from Exception, with: :server_error
|
1087
237
|
|
1088
238
|
def server_error(exception)
|
1089
239
|
# Whatever code that handles the exception
|
1090
240
|
|
1091
|
-
ExceptionNotifier.notify_exception(
|
1092
|
-
|
241
|
+
ExceptionNotifier.notify_exception(
|
242
|
+
exception,
|
243
|
+
env: request.env, data: { message: 'was doing something wrong' }
|
244
|
+
)
|
1093
245
|
end
|
1094
246
|
```
|
1095
247
|
|
@@ -1118,29 +270,6 @@ or
|
|
1118
270
|
|
1119
271
|
As above, make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
|
1120
272
|
|
1121
|
-
## Versions
|
1122
|
-
|
1123
|
-
For v4.2.1, see this tag:
|
1124
|
-
|
1125
|
-
http://github.com/smartinez87/exception_notification/tree/v4.2.1
|
1126
|
-
|
1127
|
-
For v4.2.0, see this tag:
|
1128
|
-
|
1129
|
-
http://github.com/smartinez87/exception_notification/tree/v4.2.0
|
1130
|
-
|
1131
|
-
For previous releases, visit:
|
1132
|
-
|
1133
|
-
https://github.com/smartinez87/exception_notification/tags
|
1134
|
-
|
1135
|
-
If you are running Rails 2.3 then see the branch for that:
|
1136
|
-
|
1137
|
-
http://github.com/smartinez87/exception_notification/tree/2-3-stable
|
1138
|
-
|
1139
|
-
If you are running pre-rack Rails then see this tag:
|
1140
|
-
|
1141
|
-
http://github.com/smartinez87/exception_notification/tree/pre-2-3
|
1142
|
-
|
1143
|
-
|
1144
273
|
## Support and tickets
|
1145
274
|
|
1146
275
|
Here's the list of [issues](https://github.com/smartinez87/exception_notification/issues) we're currently working on.
|