bugsnag 2.8.12 → 2.8.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +85 -546
- data/VERSION +1 -1
- data/docs/Configuration.md +239 -0
- data/docs/Notification Options.md +269 -0
- data/docs/README.md +14 -0
- data/lib/bugsnag/configuration.rb +2 -0
- data/lib/bugsnag/delivery/thread_queue.rb +6 -8
- data/lib/bugsnag/deploy.rb +0 -1
- data/lib/bugsnag/notification.rb +13 -2
- data/lib/bugsnag/railtie.rb +2 -2
- data/lib/bugsnag/tasks/bugsnag.rake +1 -1
- data/spec/notification_spec.rb +13 -0
- data/spec/spec_helper.rb +5 -5
- metadata +26 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d6aa2d47b176056a2296c83ed021e60535d8500
|
4
|
+
data.tar.gz: 993b3197a9a58242cc35f27ee6e89144c0a5bc56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42e61fc1a225f0428fe20357d0af38f022e9fecd835b0c414651f2873e26f00165beee2059920002185db91e082896fa225b68024bad6b74d5d6c20452c2eb46
|
7
|
+
data.tar.gz: 4d55d3468985cc4a7b6b7b2275b26af66ae0b39d200b2063a9db687990e67f927d2fd663034484dfe4db6fb898f3ec66009c2eba1624846d68b590c6ae86fecf
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
2.8.13
|
5
|
+
------
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
* Fix crash during heroku Rake task when an environment variable was empty
|
10
|
+
| [#261](https://github.com/bugsnag/bugsnag-ruby/issues/261)
|
11
|
+
|
12
|
+
### Enhancements
|
13
|
+
|
14
|
+
* Various warning fixes
|
15
|
+
| [Taylor Fausak](https://github.com/tfausak)
|
16
|
+
| [#254](https://github.com/bugsnag/bugsnag-ruby/pull/254)
|
17
|
+
* Make the list of vendor paths configurable
|
18
|
+
| [Jean Boussier](https://github.com/byroot)
|
19
|
+
| [#253](https://github.com/bugsnag/bugsnag-ruby/pull/253)
|
20
|
+
|
4
21
|
2.8.12
|
5
22
|
------
|
6
23
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Bugsnag Notifier for Ruby
|
1
|
+
Bugsnag Notifier for Ruby <img src="https://travis-ci.org/bugsnag/bugsnag-ruby.svg?branch=master" alt="build status" class="build-status">
|
2
2
|
=========================
|
3
3
|
|
4
4
|
The Bugsnag Notifier for Ruby gives you instant notification of exceptions
|
@@ -15,17 +15,31 @@ capturing exceptions from your applications.
|
|
15
15
|
Contents
|
16
16
|
--------
|
17
17
|
|
18
|
-
- [
|
19
|
-
- [
|
20
|
-
- [
|
21
|
-
- [
|
22
|
-
- [
|
23
|
-
- [
|
24
|
-
- [
|
18
|
+
- [Getting Started](#getting-started)
|
19
|
+
- [Installation](#installation)
|
20
|
+
- [Rake Integration](#rake-integration)
|
21
|
+
- [Sending a Test Notification](#sending-a-test-notification)
|
22
|
+
- [Usage](#usage)
|
23
|
+
- [Catching and Reporting Exceptions](#catching-and-reporting-exceptions)
|
24
|
+
- [Sending Non-fatal Exceptions](#sending-non-fatal-exceptions)
|
25
|
+
- [Deploy Tracking](#deploy-tracking)
|
26
|
+
- [Callbacks](#callbacks)
|
25
27
|
- [Demo Applications](#demo-applications)
|
28
|
+
- [Support](#support)
|
29
|
+
- [Contributing](#contributing)
|
30
|
+
- [License](#license)
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
- [Additional Documentation](https://github.com/bugsnag/bugsnag-ruby/tree/master/docs)
|
33
|
+
- [Configuration](docs/Configuration.md)
|
34
|
+
- [Notification Options](docs/Notification Options.md)
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
Getting Started
|
39
|
+
---------------
|
40
|
+
|
41
|
+
|
42
|
+
### Installation
|
29
43
|
|
30
44
|
1. Add the `bugsnag` gem to your `Gemfile`
|
31
45
|
|
@@ -58,247 +72,7 @@ How to Install
|
|
58
72
|
The Bugsnag module will read the `BUGSNAG_API_KEY` environment variable if you
|
59
73
|
do not configure one automatically.
|
60
74
|
|
61
|
-
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
use Bugsnag::Rack
|
65
|
-
```
|
66
|
-
|
67
|
-
**Sinatra**: Note that `raise_errors` must be enabled. If you are using custom
|
68
|
-
error handlers, then you will need to notify Bugsnag explicitly:
|
69
|
-
|
70
|
-
```ruby
|
71
|
-
error 500 do
|
72
|
-
Bugsnag.auto_notify($!)
|
73
|
-
erb :"errors/500"
|
74
|
-
end
|
75
|
-
```
|
76
|
-
|
77
|
-
Sending Custom Data With Exceptions
|
78
|
-
-----------------------------------
|
79
|
-
|
80
|
-
It is often useful to send additional meta-data about your app, such as
|
81
|
-
information about the currently logged in user, along with any
|
82
|
-
exceptions, to help debug problems.
|
83
|
-
|
84
|
-
### Rails Apps
|
85
|
-
|
86
|
-
By default Bugsnag includes some information automatically. For example, we
|
87
|
-
send all the HTTP headers for requests. Additionally if you're using Warden or
|
88
|
-
Devise, the id, name and email of the current user are sent.
|
89
|
-
|
90
|
-
To send additional information, in any rails controller you can define a `before_bugsnag_notify` callback, which allows you to add this additional data by calling `add_tab` on the exception notification object. Please see the [Notification Object](#notification-object) for details on the notification parameter.
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
class MyController < ApplicationController
|
94
|
-
# Define the filter
|
95
|
-
before_bugsnag_notify :add_user_info_to_bugsnag
|
96
|
-
|
97
|
-
# Your controller code here
|
98
|
-
|
99
|
-
private
|
100
|
-
def add_user_info_to_bugsnag(notif)
|
101
|
-
# Set the user that this bug affected
|
102
|
-
# Email, name and id are searchable on bugsnag.com
|
103
|
-
notif.user = {
|
104
|
-
email: current_user.email,
|
105
|
-
name: current_user.name,
|
106
|
-
id: current_user.id
|
107
|
-
}
|
108
|
-
|
109
|
-
# Add some app-specific data which will be displayed on a custom
|
110
|
-
# "Diagnostics" tab on each error page on bugsnag.com
|
111
|
-
notif.add_tab(:diagnostics, {
|
112
|
-
product: current_product.name
|
113
|
-
})
|
114
|
-
end
|
115
|
-
end
|
116
|
-
```
|
117
|
-
|
118
|
-
### Rails API Apps
|
119
|
-
|
120
|
-
If you are building an API using the [rails-api](https://github.com/rails-api/rails-api) gem, your controllers will inherit from `ActionController::API` instead of `ActionController::Base`.
|
121
|
-
|
122
|
-
In this case, the `before_bugsnag_notify` filter will not be automatically available in your controllers. In order to use it, you will need to include the module `Bugsnag::Rails::ControllerMethods`.
|
123
|
-
|
124
|
-
```ruby
|
125
|
-
class ApplicationController < ActionController::API
|
126
|
-
|
127
|
-
# Include module which defines the before_bugsnag_notify filter
|
128
|
-
include Bugsnag::Rails::ControllerMethods
|
129
|
-
|
130
|
-
# Other code here
|
131
|
-
end
|
132
|
-
```
|
133
|
-
|
134
|
-
### Other Ruby Apps
|
135
|
-
|
136
|
-
In other ruby apps, you can provide lambda functions to execute before any `Bugsnag.notify` calls as follows. Don't forget to clear the callbacks at the end of each request or session. In Rack applications like Sinatra, this is automatically done for you.
|
137
|
-
|
138
|
-
```ruby
|
139
|
-
# Set a before notify callback
|
140
|
-
Bugsnag.before_notify_callbacks << lambda {|notif|
|
141
|
-
notif.add_tab(:user_info, {
|
142
|
-
name: current_user.name
|
143
|
-
})
|
144
|
-
}
|
145
|
-
|
146
|
-
# Your app code here
|
147
|
-
|
148
|
-
# Clear the callbacks
|
149
|
-
Bugsnag.before_notify_callbacks.clear
|
150
|
-
```
|
151
|
-
|
152
|
-
### Notification Object
|
153
|
-
|
154
|
-
The notification object is passed to all [before bugsnag notify](#sending-custom-data-with-exceptions) callbacks and is used to manipulate the error report before it is transmitted.
|
155
|
-
|
156
|
-
#### add_tab
|
157
|
-
|
158
|
-
Call add_tab on a notification object to add a tab to the error report so that it would appear on your dashboard.
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
notif.add_tab(:user_info, {
|
162
|
-
name: current_user.name
|
163
|
-
})
|
164
|
-
```
|
165
|
-
|
166
|
-
The first parameter is the tab name that will appear in the error report and the second is the key, value list that will be displayed in the tab.
|
167
|
-
|
168
|
-
#### remove_tab
|
169
|
-
|
170
|
-
Removes a tab completely from the error report
|
171
|
-
|
172
|
-
```ruby
|
173
|
-
notif.remove_tab(:request)
|
174
|
-
```
|
175
|
-
|
176
|
-
#### ignore!
|
177
|
-
|
178
|
-
Calling ignore! on a notification object will cause the notification to not be sent to bugsnag. This means that you can choose dynamically not to send an error depending on application state or the error itself.
|
179
|
-
|
180
|
-
```ruby
|
181
|
-
notif.ignore! if foo == 'bar'
|
182
|
-
```
|
183
|
-
|
184
|
-
#### grouping_hash
|
185
|
-
|
186
|
-
Sets the grouping hash of the error report. All errors with the same grouping hash are grouped together. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.
|
187
|
-
|
188
|
-
```ruby
|
189
|
-
notif.grouping_hash = "#{exception.message}#{exception.class}"
|
190
|
-
```
|
191
|
-
|
192
|
-
#### severity
|
193
|
-
|
194
|
-
Set the severity of the error. Severity can be `error`, `warning` or `info`.
|
195
|
-
|
196
|
-
```ruby
|
197
|
-
notif.severity = "error"
|
198
|
-
```
|
199
|
-
|
200
|
-
#### context
|
201
|
-
|
202
|
-
Set the context of the error report. This is notionally the location of the error and should be populated automatically. Context is displayed in the dashboard prominently.
|
203
|
-
|
204
|
-
```ruby
|
205
|
-
notif.context = "billing"
|
206
|
-
```
|
207
|
-
|
208
|
-
#### user
|
209
|
-
|
210
|
-
You can set or read the user with the user property of the notification. The user will be a hash of `email`, `id` and `name`.
|
211
|
-
|
212
|
-
```ruby
|
213
|
-
notif.user = {
|
214
|
-
id: current_user.id,
|
215
|
-
email: current_user.email,
|
216
|
-
name: current_user.name
|
217
|
-
}
|
218
|
-
```
|
219
|
-
|
220
|
-
#### exceptions
|
221
|
-
|
222
|
-
Allows you to read the exceptions that will be combined into the report.
|
223
|
-
|
224
|
-
```ruby
|
225
|
-
puts "#{notif.exceptions.first.message} found!"
|
226
|
-
```
|
227
|
-
|
228
|
-
#### meta_data
|
229
|
-
|
230
|
-
Provides access to the meta_data in the error report.
|
231
|
-
|
232
|
-
```ruby
|
233
|
-
notif.ignore! if notif.meta_data[:sidekiq][:retry_count] > 2
|
234
|
-
```
|
235
|
-
|
236
|
-
### Exceptions with Meta Data
|
237
|
-
|
238
|
-
If you include the `Bugsnag::MetaData` module into your own exceptions, you can
|
239
|
-
associate meta data with a particular exception.
|
240
|
-
|
241
|
-
```ruby
|
242
|
-
class MyCustomException < Exception
|
243
|
-
include Bugsnag::MetaData
|
244
|
-
end
|
245
|
-
|
246
|
-
exception = MyCustomException.new("It broke!")
|
247
|
-
exception.bugsnag_meta_data = {
|
248
|
-
:user_info => {
|
249
|
-
name: current_user.name
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
|
-
raise exception
|
254
|
-
```
|
255
|
-
|
256
|
-
You can read more about how callbacks work in the
|
257
|
-
[Bugsnag Middleware](#bugsnag-middleware) documentation below.
|
258
|
-
|
259
|
-
|
260
|
-
Sending Handled Exceptions
|
261
|
-
----------------------------
|
262
|
-
|
263
|
-
If you would like to send non-fatal exceptions to Bugsnag, you can call
|
264
|
-
`Bugsnag.notify`:
|
265
|
-
|
266
|
-
```ruby
|
267
|
-
Bugsnag.notify(RuntimeError.new("Something broke"))
|
268
|
-
```
|
269
|
-
|
270
|
-
### Custom Data
|
271
|
-
|
272
|
-
You can also send additional meta-data with your exception:
|
273
|
-
|
274
|
-
```ruby
|
275
|
-
Bugsnag.notify(RuntimeError.new("Something broke"), {
|
276
|
-
:user => {
|
277
|
-
:username => "bob-hoskins",
|
278
|
-
:registered_user => true
|
279
|
-
}
|
280
|
-
})
|
281
|
-
```
|
282
|
-
|
283
|
-
### Severity
|
284
|
-
|
285
|
-
You can set the severity of an error in Bugsnag by including the severity option when
|
286
|
-
notifying bugsnag of the error,
|
287
|
-
|
288
|
-
```ruby
|
289
|
-
Bugsnag.notify(RuntimeError.new("Something broke"), {
|
290
|
-
:severity => "error",
|
291
|
-
})
|
292
|
-
```
|
293
|
-
|
294
|
-
Valid severities are `error`, `warning` and `info`.
|
295
|
-
|
296
|
-
Severity is displayed in the dashboard and can be used to filter the error list.
|
297
|
-
By default all crashes (or unhandled exceptions) are set to `error` and all
|
298
|
-
`Bugsnag.notify` calls default to `warning`.
|
299
|
-
|
300
|
-
Rake Integration
|
301
|
-
----------------
|
75
|
+
### Rake Integration
|
302
76
|
|
303
77
|
Rake integration is automatically enabled in Rails 3/4 apps, so providing you load the environment
|
304
78
|
in your Rake tasks you dont need to do anything to get Rake support. If you choose not to load
|
@@ -322,24 +96,9 @@ YourApp::Application.load_tasks
|
|
322
96
|
> Note: We also configure Bugsnag in the Rakefile, so the tasks that do not load the full
|
323
97
|
environment can still notify Bugsnag.
|
324
98
|
|
325
|
-
|
326
|
-
---------------------
|
327
|
-
|
328
|
-
If you are running a standard ruby script, you can ensure that all exceptions are sent to Bugsnag by
|
329
|
-
adding the following code to your app:
|
330
|
-
|
331
|
-
```ruby
|
332
|
-
at_exit do
|
333
|
-
if $!
|
334
|
-
Bugsnag.notify($!)
|
335
|
-
end
|
336
|
-
end
|
337
|
-
```
|
99
|
+
### Sending a Test Notification
|
338
100
|
|
339
|
-
|
340
|
-
-------------------
|
341
|
-
|
342
|
-
To test that bugsnag is properly configured, you can use the test_exception rake task like this,
|
101
|
+
To test that bugsnag is properly configured, you can use the `test_exception` rake task:
|
343
102
|
|
344
103
|
```bash
|
345
104
|
rake bugsnag:test_exception
|
@@ -347,244 +106,91 @@ rake bugsnag:test_exception
|
|
347
106
|
|
348
107
|
A test exception will be sent to your bugsnag dashboard if everything is configured correctly.
|
349
108
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
To configure additional Bugsnag settings, use the block syntax and set any
|
354
|
-
settings you need on the `config` block variable. For example:
|
355
|
-
|
356
|
-
```ruby
|
357
|
-
Bugsnag.configure do |config|
|
358
|
-
config.api_key = "your-api-key-here"
|
359
|
-
config.notify_release_stages = ["production", "development"]
|
360
|
-
end
|
361
|
-
```
|
362
|
-
|
363
|
-
###api_key
|
364
|
-
|
365
|
-
Your Bugsnag API key (required).
|
366
|
-
|
367
|
-
```ruby
|
368
|
-
config.api_key = "your-api-key-here"
|
369
|
-
```
|
370
|
-
|
371
|
-
###release_stage
|
372
|
-
|
373
|
-
If you would like to distinguish between errors that happen in different
|
374
|
-
stages of the application release process (development, production, etc)
|
375
|
-
you can set the `release_stage` that is reported to Bugsnag.
|
376
|
-
|
377
|
-
```ruby
|
378
|
-
config.release_stage = "development"
|
379
|
-
```
|
380
|
-
|
381
|
-
In rails apps this value is automatically set from `RAILS_ENV`, and in rack
|
382
|
-
apps it is automatically set to `RACK_ENV`. Otherwise the default is
|
383
|
-
"production".
|
109
|
+
Usage
|
110
|
+
-----
|
384
111
|
|
385
|
-
###
|
112
|
+
### Catching and Reporting Exceptions
|
386
113
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
```ruby
|
392
|
-
config.notify_release_stages = ["production", "development"]
|
393
|
-
```
|
394
|
-
|
395
|
-
###endpoint
|
396
|
-
|
397
|
-
By default, we'll send crashes to *notify.bugsnag.com* to display them on
|
398
|
-
your dashboard. If you are using *Bugsnag Enterprise* you'll need to set
|
399
|
-
this to be your *Event Server* endpoint, for example:
|
400
|
-
|
401
|
-
```ruby
|
402
|
-
config.endpoint = "bugsnag.example.com:49000"
|
403
|
-
```
|
404
|
-
|
405
|
-
###auto_notify
|
406
|
-
|
407
|
-
By default, we will automatically notify Bugsnag of any fatal exceptions
|
408
|
-
in your application. If you want to stop this from happening, you can set
|
409
|
-
`auto_notify`:
|
410
|
-
|
411
|
-
```ruby
|
412
|
-
config.auto_notify = false
|
413
|
-
```
|
414
|
-
|
415
|
-
###use_ssl
|
416
|
-
|
417
|
-
Enforces all communication with bugsnag.com be made via ssl. You can turn
|
418
|
-
this off if necessary.
|
419
|
-
|
420
|
-
```ruby
|
421
|
-
config.use_ssl = false
|
422
|
-
```
|
423
|
-
|
424
|
-
By default, `use_ssl` is set to true.
|
425
|
-
|
426
|
-
<!-- Custom anchor for linking from alerts -->
|
427
|
-
<div id="set-project-root"></div>
|
428
|
-
###project_root
|
429
|
-
|
430
|
-
We mark stacktrace lines as `inProject` if they come from files inside your
|
431
|
-
`project_root`. In rails apps this value is automatically set to `RAILS_ROOT`,
|
432
|
-
otherwise you should set it manually:
|
433
|
-
|
434
|
-
```ruby
|
435
|
-
config.project_root = "/var/www/myproject"
|
436
|
-
```
|
437
|
-
|
438
|
-
###app_version
|
439
|
-
|
440
|
-
If you want to track which versions of your application each exception
|
441
|
-
happens in, you can set `app_version`. This is set to `nil` by default.
|
442
|
-
|
443
|
-
```ruby
|
444
|
-
config.app_version = "2.5.1"
|
445
|
-
```
|
446
|
-
|
447
|
-
###params_filters
|
448
|
-
|
449
|
-
Sets which keys should be filtered out from `params` hashes before sending
|
450
|
-
them to Bugsnag. Use this if you want to ensure you don't send sensitive data
|
451
|
-
such as passwords, and credit card numbers to our servers. You can add both
|
452
|
-
strings and regular expressions to this array. When adding strings, keys which
|
453
|
-
*contain* the string will be filtered. When adding regular expressions, any
|
454
|
-
keys which *match* the regular expression will be filtered.
|
455
|
-
|
456
|
-
```ruby
|
457
|
-
config.params_filters += ["credit_card_number", /^password$/]
|
458
|
-
```
|
459
|
-
|
460
|
-
By default, `params_filters` is set to `[/authorization/i, /cookie/i,
|
461
|
-
/password/i, /secret/i]`, and for rails apps, imports all values from
|
462
|
-
`Rails.configuration.filter_parameters`.
|
463
|
-
|
464
|
-
###ignore_classes
|
465
|
-
|
466
|
-
Sets for which exception classes we should not send exceptions to bugsnag.com.
|
467
|
-
|
468
|
-
```ruby
|
469
|
-
config.ignore_classes << "ActiveRecord::StatementInvalid"
|
470
|
-
```
|
471
|
-
|
472
|
-
You can also provide a lambda function here to ignore by other exception
|
473
|
-
attributes or by a regex:
|
474
|
-
|
475
|
-
```ruby
|
476
|
-
config.ignore_classes << lambda {|ex| ex.message =~ /timeout/}
|
477
|
-
```
|
478
|
-
|
479
|
-
By default, `ignore_classes` contains the following:
|
480
|
-
|
481
|
-
```ruby
|
482
|
-
[
|
483
|
-
"ActiveRecord::RecordNotFound",
|
484
|
-
"ActionController::RoutingError",
|
485
|
-
"ActionController::InvalidAuthenticityToken",
|
486
|
-
"CGI::Session::CookieStore::TamperedWithCookie",
|
487
|
-
"ActionController::UnknownAction",
|
488
|
-
"AbstractController::ActionNotFound"
|
489
|
-
]
|
490
|
-
```
|
491
|
-
|
492
|
-
###ignore_user_agents
|
493
|
-
|
494
|
-
Sets an array of Regexps that can be used to ignore exceptions from
|
495
|
-
certain user agents.
|
496
|
-
|
497
|
-
```ruby
|
498
|
-
config.ignore_user_agents << %r{Chrome}
|
499
|
-
```
|
500
|
-
|
501
|
-
By default, `ignore_user_agents` is empty, so exceptions caused by all
|
502
|
-
user agents are reported.
|
114
|
+
Bugsnag Ruby works out of the box with Rails, Sidekiq, Resque, DelayedJob (3+), Mailman, Rake and Rack. It
|
115
|
+
should be easy to add support for other frameworks, either by sending a pull request here or adding a hook
|
116
|
+
to those projects.
|
503
117
|
|
504
|
-
|
118
|
+
#### Rack/Sinatra Apps
|
505
119
|
|
506
|
-
|
120
|
+
Activate the Bugsnag Rack middleware
|
507
121
|
|
508
122
|
```ruby
|
509
|
-
|
123
|
+
use Bugsnag::Rack
|
510
124
|
```
|
511
125
|
|
512
|
-
|
513
|
-
|
514
|
-
|
126
|
+
**Sinatra**: Note that `raise_errors` must be enabled. If you are
|
127
|
+
using custom error handlers, then you will need to notify Bugsnag
|
128
|
+
explicitly:
|
515
129
|
|
516
130
|
```ruby
|
517
|
-
|
131
|
+
error 500 do
|
132
|
+
Bugsnag.auto_notify($!)
|
133
|
+
erb :"errors/500"
|
134
|
+
end
|
518
135
|
```
|
519
136
|
|
520
|
-
|
137
|
+
#### Custom Ruby Scripts
|
521
138
|
|
522
|
-
|
139
|
+
**Custom Ruby Scripts**: If you are running a standard ruby script,
|
140
|
+
you can ensure that all exceptions are sent to Bugsnag by adding
|
141
|
+
the following code to your app:
|
523
142
|
|
524
143
|
```ruby
|
525
|
-
|
144
|
+
at_exit do
|
145
|
+
if $!
|
146
|
+
Bugsnag.notify($!)
|
147
|
+
end
|
148
|
+
end
|
526
149
|
```
|
527
150
|
|
528
|
-
|
529
|
-
|
530
|
-
Sets the password for the user that should be used to send requests to the HTTP proxy for requests to bugsnag.
|
531
|
-
|
532
|
-
```ruby
|
533
|
-
config.proxy_password = "proxy_secret_password_here"
|
534
|
-
```
|
151
|
+
#### EventMachine Apps
|
535
152
|
|
536
|
-
|
537
|
-
|
538
|
-
you
|
153
|
+
If your app uses [EventMachine](http://rubyeventmachine.com/) you'll need to
|
154
|
+
manually notify Bugsnag of errors. There are two ways to do this in your
|
155
|
+
EventMachine apps, first you should implement `EventMachine.error_handler`:
|
539
156
|
|
540
157
|
```ruby
|
541
|
-
|
158
|
+
EventMachine.error_handler{|e|
|
159
|
+
Bugsnag.notify(e)
|
160
|
+
}
|
542
161
|
```
|
543
162
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
automatically set to use `Rails.logger`, otherwise it will be set to
|
548
|
-
`Logger.new(STDOUT)`.
|
549
|
-
|
550
|
-
###middleware
|
551
|
-
|
552
|
-
Provides access to the middleware stack, see the
|
553
|
-
[Bugsnag Middleware](#bugsnag-middleware) section below for details.
|
554
|
-
|
555
|
-
###app_type
|
556
|
-
|
557
|
-
You can set the type of application executing the current code by using `app_type`:
|
163
|
+
If you want more fine-grained error handling, you can use the
|
164
|
+
[errback](http://eventmachine.rubyforge.org/EventMachine/Deferrable.html#errback-instance_method)
|
165
|
+
function, for example:
|
558
166
|
|
559
167
|
```ruby
|
560
|
-
|
168
|
+
EventMachine::run do
|
169
|
+
server = EventMachine::start_server('0.0.0.0', PORT, MyServer)
|
170
|
+
server.errback {
|
171
|
+
EM.defer do
|
172
|
+
Bugsnag.notify(RuntimeError.new("Something bad happened"))
|
173
|
+
end
|
174
|
+
}
|
175
|
+
end
|
561
176
|
```
|
562
177
|
|
563
|
-
|
564
|
-
|
178
|
+
For this to work, include [Deferrable](http://eventmachine.rubyforge.org/EventMachine/Deferrable.html)
|
179
|
+
in your `MyServer`, then whenever you want to raise an error, call `fail`.
|
565
180
|
|
566
|
-
###
|
181
|
+
### Sending Non-fatal Exceptions
|
567
182
|
|
568
|
-
|
569
|
-
|
570
|
-
send your rack environment, set the `send_environment` option to `true`.
|
183
|
+
If you would like to send non-fatal exceptions to Bugsnag, you can call
|
184
|
+
`Bugsnag.notify`:
|
571
185
|
|
572
186
|
```ruby
|
573
|
-
|
187
|
+
Bugsnag.notify(RuntimeError.new("Something broke"))
|
574
188
|
```
|
575
189
|
|
576
|
-
|
577
|
-
|
578
|
-
Bugsnag automatically sends a small snippet of the code that crashed to help you diagnose
|
579
|
-
even faster from within your dashboard. If you don't want to send this snippet you can
|
580
|
-
set the `send_code` option to `false`.
|
190
|
+
Additional data can be sent with exceptions as an options hash as detailed in the [Notification Options](docs/Notification Options.md) documentation, including some [options specific to non-fatal exceptions](docs/Notification Options.md#handled-notification-options).
|
581
191
|
|
582
|
-
```ruby
|
583
|
-
config.send_code = false
|
584
|
-
```
|
585
192
|
|
586
|
-
|
587
|
-
------------------
|
193
|
+
### Callbacks
|
588
194
|
|
589
195
|
The Bugsnag Notifier for Ruby provides its own middleware system, similar to
|
590
196
|
the one used in Rack applications. Middleware allows you to execute code
|
@@ -626,28 +232,6 @@ You can also view the order of the currently activated middleware by running `ra
|
|
626
232
|
Check out Bugsnag's [built in middleware classes](https://github.com/bugsnag/bugsnag-ruby/tree/master/lib/bugsnag/middleware)
|
627
233
|
for some real examples of middleware in action.
|
628
234
|
|
629
|
-
### Multiple projects
|
630
|
-
|
631
|
-
If you want to divide errors into multiple Bugsnag projects, you can specify the API key as a parameter to `Bugsnag.notify`:
|
632
|
-
|
633
|
-
```ruby
|
634
|
-
rescue => e
|
635
|
-
Bugsnag.notify e, api_key: "your-api-key-here"
|
636
|
-
end
|
637
|
-
```
|
638
|
-
|
639
|
-
### Grouping hash
|
640
|
-
|
641
|
-
If you want to override Bugsnag's grouping algorithm, you can specify a grouping hash key as a parameter to `Bugsnag.notify`:
|
642
|
-
|
643
|
-
```ruby
|
644
|
-
rescue => e
|
645
|
-
Bugsnag.notify e, grouping_hash: "this-is-my-grouping-hash"
|
646
|
-
end
|
647
|
-
```
|
648
|
-
|
649
|
-
All errors with the same groupingHash will be grouped together within the bugsnag dashboard.
|
650
|
-
|
651
235
|
|
652
236
|
Deploy Tracking
|
653
237
|
---------------
|
@@ -731,45 +315,6 @@ For more information, check out the [deploy tracking api](https://bugsnag.com/do
|
|
731
315
|
documentation.
|
732
316
|
|
733
317
|
|
734
|
-
EventMachine Apps
|
735
|
-
-----------------
|
736
|
-
|
737
|
-
If your app uses [EventMachine](http://rubyeventmachine.com/) you'll need to
|
738
|
-
manually notify Bugsnag of errors. There are two ways to do this in your
|
739
|
-
EventMachine apps, first you should implement `EventMachine.error_handler`:
|
740
|
-
|
741
|
-
```ruby
|
742
|
-
EventMachine.error_handler{|e|
|
743
|
-
Bugsnag.notify(e)
|
744
|
-
}
|
745
|
-
```
|
746
|
-
|
747
|
-
If you want more fine-grained error handling, you can use the
|
748
|
-
[errback](http://eventmachine.rubyforge.org/EventMachine/Deferrable.html#errback-instance_method)
|
749
|
-
function, for example:
|
750
|
-
|
751
|
-
```ruby
|
752
|
-
EventMachine::run do
|
753
|
-
server = EventMachine::start_server('0.0.0.0', PORT, MyServer)
|
754
|
-
server.errback {
|
755
|
-
EM.defer do
|
756
|
-
Bugsnag.notify(RuntimeError.new("Something bad happened"))
|
757
|
-
end
|
758
|
-
}
|
759
|
-
end
|
760
|
-
```
|
761
|
-
|
762
|
-
For this to work, include [Deferrable](http://eventmachine.rubyforge.org/EventMachine/Deferrable.html)
|
763
|
-
in your `MyServer`, then whenever you want to raise an error, call `fail`.
|
764
|
-
|
765
|
-
Integrations
|
766
|
-
------------
|
767
|
-
|
768
|
-
Bugsnag ruby works out of the box with Rails, Sidekiq, Resque, DelayedJob (3+), Mailman, Rake and Rack. It
|
769
|
-
should be easy to add support for other frameworks, either by sending a pull request here or adding a hook
|
770
|
-
to those projects.
|
771
|
-
|
772
|
-
|
773
318
|
Demo Applications
|
774
319
|
-----------------
|
775
320
|
|
@@ -777,28 +322,22 @@ Demo Applications
|
|
777
322
|
examples include Rails, Sinatra, Rack, Padrino integrations, etc.
|
778
323
|
|
779
324
|
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
Please report any bugs or feature requests on the github issues page for this
|
784
|
-
project here:
|
325
|
+
Support
|
326
|
+
-------
|
785
327
|
|
786
|
-
|
328
|
+
* [Additional Documentation](https://github.com/bugsnag/bugsnag-ruby/tree/master/docs)
|
329
|
+
* [Search open and closed issues](https://github.com/bugsnag/bugsnag-ruby/issues?utf8=✓&q=is%3Aissue) for similar problems
|
330
|
+
* [Report a bug or request a feature](https://github.com/bugsnag/bugsnag-ruby/issues/new)
|
787
331
|
|
788
332
|
|
789
333
|
Contributing
|
790
334
|
------------
|
791
335
|
|
792
|
-
We'd love you to file issues and send pull requests.
|
793
|
-
|
794
|
-
|
795
|
-
Build Status
|
796
|
-
------------
|
797
|
-
[![Build Status](https://secure.travis-ci.org/bugsnag/bugsnag-ruby.png)](http://travis-ci.org/bugsnag/bugsnag-ruby)
|
336
|
+
We'd love you to file issues and send pull requests. The [contributing guidelines](https://github.com/bugsnag/bugsnag-ruby/CONTRIBUTING.md) details the process of building and testing `bugsnag-ruby`, as well as the pull request process. Feel free to comment on [existing issues](https://github.com/bugsnag/bugsnag-ruby/issues) for clarification or starting points.
|
798
337
|
|
799
338
|
|
800
339
|
License
|
801
340
|
-------
|
802
341
|
|
803
342
|
The Bugsnag ruby notifier is free software released under the MIT License.
|
804
|
-
See [LICENSE.txt](
|
343
|
+
See [LICENSE.txt](LICENSE.txt) for details.
|