honeybadger 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/Appraisals +25 -1
  2. data/CHANGELOG.md +47 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +7 -8
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +117 -6
  7. data/Rakefile +15 -0
  8. data/features/rack.feature +2 -2
  9. data/features/rails.feature +79 -15
  10. data/features/step_definitions/metal_steps.rb +4 -4
  11. data/features/step_definitions/rack_steps.rb +0 -4
  12. data/features/step_definitions/rails_steps.rb +49 -32
  13. data/features/support/honeybadger_failure_shim.rb.template +5 -0
  14. data/features/support/rails.rb +17 -5
  15. data/gemfiles/rack.gemfile +8 -0
  16. data/gemfiles/rack.gemfile.lock +92 -0
  17. data/gemfiles/rails2.3.gemfile +1 -1
  18. data/gemfiles/rails2.3.gemfile.lock +6 -2
  19. data/gemfiles/rails3.0.gemfile +2 -1
  20. data/gemfiles/rails3.0.gemfile.lock +12 -3
  21. data/gemfiles/rails3.1.gemfile +2 -1
  22. data/gemfiles/rails3.1.gemfile.lock +12 -3
  23. data/gemfiles/rails3.2.gemfile +3 -2
  24. data/gemfiles/rails3.2.gemfile.lock +45 -36
  25. data/gemfiles/rails4.gemfile +9 -0
  26. data/gemfiles/rails4.gemfile.lock +174 -0
  27. data/gemfiles/rake.gemfile +8 -0
  28. data/gemfiles/rake.gemfile.lock +91 -0
  29. data/gemfiles/sinatra.gemfile +8 -0
  30. data/gemfiles/sinatra.gemfile.lock +91 -0
  31. data/generators/honeybadger/honeybadger_generator.rb +5 -5
  32. data/honeybadger.gemspec +12 -3
  33. data/lib/honeybadger.rb +7 -14
  34. data/lib/honeybadger/configuration.rb +10 -1
  35. data/lib/honeybadger/notice.rb +38 -20
  36. data/lib/honeybadger/rack.rb +0 -1
  37. data/lib/honeybadger/rails/controller_methods.rb +5 -4
  38. data/lib/honeybadger/rails3_tasks.rb +16 -4
  39. data/lib/honeybadger/sender.rb +10 -19
  40. data/lib/honeybadger/shared_tasks.rb +2 -3
  41. data/lib/honeybadger/tasks.rb +16 -9
  42. data/lib/honeybadger_tasks.rb +2 -3
  43. data/lib/rails/generators/honeybadger/honeybadger_generator.rb +5 -5
  44. data/test/test_helper.rb +2 -7
  45. data/test/unit/backtrace_test.rb +19 -19
  46. data/test/unit/configuration_test.rb +11 -5
  47. data/test/unit/notice_test.rb +21 -3
  48. data/test/unit/rails/action_controller_catcher_test.rb +250 -241
  49. data/test/unit/sender_test.rb +22 -2
  50. metadata +13 -19
data/Appraisals CHANGED
@@ -7,14 +7,38 @@ end
7
7
  appraise 'rails3.0' do
8
8
  gem 'rails', '3.0.17'
9
9
  gem 'honeybadger', :path => '../'
10
+ gem 'better_errors', :require => false
10
11
  end
11
12
 
12
13
  appraise 'rails3.1' do
13
14
  gem 'rails', '3.1.8'
14
15
  gem 'honeybadger', :path => '../'
16
+ gem 'better_errors', :require => false
15
17
  end
16
18
 
17
19
  appraise 'rails3.2' do
18
- gem 'rails', '3.2.11'
20
+ gem 'rails', '3.2.12'
21
+ gem 'honeybadger', :path => '../'
22
+ gem 'better_errors', :require => false
23
+ end
24
+
25
+ appraise 'rails4' do
26
+ gem 'rails', '4.0.0.beta', :git => 'git://github.com/rails/rails.git'
27
+ gem 'honeybadger', :path => '../'
28
+ gem 'better_errors', :require => false
29
+ end
30
+
31
+ appraise 'rake' do
32
+ gem 'sinatra'
33
+ gem 'honeybadger', :path => '../'
34
+ end
35
+
36
+ appraise 'rack' do
37
+ gem 'rack'
38
+ gem 'honeybadger', :path => '../'
39
+ end
40
+
41
+ appraise 'sinatra' do
42
+ gem 'sinatra'
19
43
  gem 'honeybadger', :path => '../'
20
44
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,47 @@
1
+ ## Honeybadger 1.6.0 ##
2
+
3
+ * Rescue from load error when application_controller.rb is missing.
4
+
5
+ *Joshua Wood*
6
+
7
+ * Default to debug log level instead of info for general logging.
8
+
9
+ *Joshua Wood*
10
+
11
+ * Ignore error classes by regexp, ignore subclasses of ignored classes
12
+
13
+ *Joshua Wood*
14
+
15
+ * Detect and disable better_errors gem in Rails 3 test task
16
+
17
+ *Joshua Wood*
18
+
19
+ * Add option to send session data (or not)
20
+
21
+ *Joshua Wood*
22
+
23
+ * Send language in notice payload
24
+
25
+ *Joshua Wood*
26
+
27
+ * Disable Rack::SSL middleware in Rails 3 test task. Rails'
28
+ config.force_ssl setting otherwise prevents the request from reaching
29
+ the controller.
30
+
31
+ *Joshua Wood*
32
+
33
+ * Added a Changelog :)
34
+
35
+ *Joshua Wood*
36
+
37
+ * Added deploy tracking documentation
38
+
39
+ *Joshua Wood*
40
+
41
+ * Remove dependency on ActiveSupport
42
+
43
+ *Pieter van de Bruggen*
44
+
45
+ * Rails 4 support
46
+
47
+ *Joshua Wood*
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,16 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeybadger (1.5.0)
5
- activesupport
4
+ honeybadger (1.6.0)
6
5
  json
7
6
 
8
7
  GEM
9
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
10
9
  specs:
11
- activesupport (3.2.11)
12
- i18n (~> 0.6)
13
- multi_json (~> 1.0)
14
10
  appraisal (0.5.1)
15
11
  bundler
16
12
  rake
@@ -37,15 +33,17 @@ GEM
37
33
  diff-lcs (1.1.3)
38
34
  fakeweb (1.3.0)
39
35
  ffi (1.2.0)
36
+ ffi (1.2.0-java)
40
37
  gherkin (2.11.5)
41
38
  json (>= 1.4.6)
39
+ gherkin (2.11.5-java)
40
+ json (>= 1.4.6)
42
41
  highline (1.6.13)
43
- i18n (0.6.1)
44
42
  json (1.7.3)
43
+ json (1.7.3-java)
45
44
  metaclass (0.0.1)
46
45
  mocha (0.10.5)
47
46
  metaclass (~> 0.0.1)
48
- multi_json (1.5.0)
49
47
  net-scp (1.0.4)
50
48
  net-ssh (>= 1.99.1)
51
49
  net-sftp (2.0.5)
@@ -70,6 +68,7 @@ GEM
70
68
  rack (>= 1.0)
71
69
 
72
70
  PLATFORMS
71
+ java
73
72
  ruby
74
73
 
75
74
  DEPENDENCIES
data/MIT-LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2007 - 2012, Exceptional DBA Airbrake.io
2
- Portions Copyright (c) 2012, Honeybadger Industries LLC
2
+ Portions Copyright (c) 2012-2013, Honeybadger Industries LLC
3
3
 
4
4
  NOTE: All code contained herein that is copyright Exceptional DBA Airbrake.io was available
5
5
  under the MIT license (listed below) on or before November 6, 2012.
data/README.md CHANGED
@@ -2,8 +2,9 @@ Honeybadger
2
2
  ===============
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/honeybadger-io/honeybadger-ruby.png?branch=master)](http://travis-ci.org/honeybadger-io/honeybadger-ruby)
5
+ [![Gem Version](https://badge.fury.io/rb/honeybadger.png)](http://badge.fury.io/rb/honeybadger)
5
6
 
6
- This is the notifier gem for integrating apps with the :zap: [Honeybadger Rails Error Notifier](http://honeybadger.io).
7
+ This is the notifier gem for integrating apps with the :zap: [Honeybadger Exception Notifier for Ruby and Rails](http://honeybadger.io).
7
8
 
8
9
  When an uncaught exception occurs, Honeybadger will POST the relevant data
9
10
  to the Honeybadger server specified in your environment.
@@ -21,8 +22,6 @@ Then generate the initializer:
21
22
  If you prefer to manually create the initializer, that's simple enough.
22
23
  Just put the code below in config/initializers/honeybadger.rb
23
24
 
24
- # Uncomment the following line if running lower than Rails 3.2
25
- # require 'honeybadger/rails'
26
25
  Honeybadger.configure do |config|
27
26
  config.api_key = '[your-api-key]'
28
27
  end
@@ -92,6 +91,11 @@ Using honeybadger in a Sinatra app is just like a Rack app:
92
91
  raise "Sinatra has left the building"
93
92
  end
94
93
 
94
+ ## Additional integrations:
95
+
96
+ * [Catch exceptions in Resque jobs](https://github.com/henrik/resque-honeybadger)
97
+ * [Sidekiq - Simple, efficient message processing for Ruby](https://github.com/mperham/sidekiq) (supports Honeybadger natively)
98
+
95
99
  ## Usage
96
100
 
97
101
  For the most part, Honeybadger works for itself.
@@ -124,6 +128,27 @@ this rake task (from RAILS_ROOT):
124
128
  If everything is configured properly, that task will send a notice to Honeybadger
125
129
  which will be visible immediately.
126
130
 
131
+ ## Ignored environments
132
+
133
+ Please note that in development mode, Honeybadger will **not** be
134
+ notified of exceptions that occur, except when running the test rake
135
+ task. The following environments are ignored by default: *development*,
136
+ *test*, and *cucumber*. You can modify which environments are ignored by
137
+ setting the `development_environments` option in your Honeybadger
138
+ initializer:
139
+
140
+ Honeybadger.configure do |config|
141
+ ...
142
+ # To add an additional environment to be ignored:
143
+ config.development_environments << 'staging'
144
+
145
+ # To override the default environments completely:
146
+ config.development_environments = ['test', 'cucumber']
147
+ end
148
+
149
+ If you choose to override the `development_environments` option for
150
+ whatever reason, please make sure your test environments are ignored.
151
+
127
152
  ## Sending custom data
128
153
 
129
154
  Honeybadger allows you to send custom data using `Honeybadger.context`.
@@ -146,6 +171,64 @@ request's life cycle. Honeybadger will discard the data when a
146
171
  request completes, so that the next request will start with a blank
147
172
  slate.
148
173
 
174
+ ## Tracking deploys
175
+
176
+ Honeybadger has an API to keep track of project deployments. Whenever
177
+ you deploy, all errors for that environment will be resolved
178
+ automatically. You can choose to enable or disable the auto-resolve
179
+ feature from your Honeybadger project settings page.
180
+
181
+ We officially support deploy tracking using Capistrano and Heroku:
182
+
183
+ ### Capistrano
184
+
185
+ In order to track deployments using Capistrano, simply require
186
+ Honeybadger's Capistrano task in your `config/deploy.rb` file:
187
+
188
+ require 'honeybadger/capistrano'
189
+
190
+ If you ran the Honeybadger install generator in a project that was
191
+ previously configured with Capistrano, we already added this for you.
192
+
193
+ The Capistrano task will run our `rake honeybadger:deploy` task on
194
+ the server you are deploying to, so that it can correctly report
195
+ environment-related information. If you would prefer to notify
196
+ Honeybadger locally without using rake, check out our blog post:
197
+ [Honeybadger and Capistrano: the metal way](http://honeybadger.io/blog/2012/10/06/honeybadger-and-capistrano/).
198
+
199
+ ### Heroku
200
+
201
+ Deploy tracking via Heroku is implemented using Heroku's free [deploy
202
+ hooks](https://devcenter.heroku.com/articles/deploy-hooks) addon. To
203
+ install the addon and configure it for Honeybadger, run the following
204
+ rake task from your project root:
205
+
206
+ rake honeybadger:heroku:add_deploy_notification APP=app-name
207
+
208
+ Don't forget to replace "app-name" with the name of your app on
209
+ Heroku. Or, if you want to add the deploy hook manually, run:
210
+
211
+ heroku addons:add deployhooks:http --url="https://api.honeybadger.io/v1/deploys?deploy[environment]=production&api_key=asdf" --app app-name
212
+
213
+ You should replace the api key and app-name with your own values. You
214
+ may also want to change the environment (set to production by default).
215
+
216
+ ### Via Rake
217
+
218
+ If you are using other frameworks/platforms, you can still notify us of
219
+ a deploy. We provide a rake task that uses ENV variables to report
220
+ environment information:
221
+
222
+ rake honeybadger:deploy TO=production
223
+
224
+ You can optionally add:
225
+
226
+ * REPO=[scm repo url]
227
+ * REVISION=[scm sha]
228
+ * USER=[local user's name]
229
+ * API_KEY=[a different api key]
230
+ * DRY_RUN=true (simulates notification)
231
+
149
232
  ## Notifying Honeybadger asynchronously
150
233
 
151
234
  Want to send notices in a thread, or even use Resque or Sidekiq to
@@ -295,11 +378,13 @@ Honeybadger ignores the following exceptions by default:
295
378
  Mongoid::Errors::DocumentNotFound
296
379
 
297
380
  To ignore errors in addition to those, specify their names in your Honeybadger
298
- configuration block.
381
+ configuration block. You may use a string, regexp, or class:
299
382
 
300
383
  Honeybadger.configure do |config|
301
384
  config.api_key = '1234567890abcdef'
385
+ config.ignore << /IgnoredError$/
302
386
  config.ignore << "ActiveRecord::IgnoreThisError"
387
+ config.ignore << OtherException
303
388
  end
304
389
 
305
390
  To ignore *only* certain errors (and override the defaults), use the #ignore_only attribute.
@@ -309,6 +394,9 @@ To ignore *only* certain errors (and override the defaults), use the #ignore_onl
309
394
  config.ignore_only = ["ActiveRecord::IgnoreThisError"] # or [] to ignore no exceptions.
310
395
  end
311
396
 
397
+ Subclasses of ignored classes will also be ignored, while strings and
398
+ regexps are compared with the error class name only.
399
+
312
400
  To ignore certain user agents, add in the #ignore_user_agent attribute as a
313
401
  string or regexp:
314
402
 
@@ -337,6 +425,13 @@ To replace sensitive information sent to the Honeybadger service with [FILTERED]
337
425
  Note that, when rescuing exceptions within an ActionController method,
338
426
  honeybadger will reuse filters specified by #filter_parameter_logging.
339
427
 
428
+ To disable sending session data:
429
+
430
+ Honeybadger.configure do |config|
431
+ config.api_key = '1234567890abcdef'
432
+ config.send_request_session = false
433
+ end
434
+
340
435
  ## Testing
341
436
 
342
437
  When you run your tests, you might notice that the Honeybadger service is recording
@@ -363,9 +458,25 @@ added the following information to your Honeybadger configuration block.
363
458
  config.proxy_pass = bar # optional
364
459
  end
365
460
 
461
+ ## Troubleshooting
462
+
463
+ By default, Honeybadger is quiet when your log level is set to INFO
464
+ (most production environments). If you would like to be notified via
465
+ logs when Honeybadger completes a successful notification, set the
466
+ `config.debug` option to true:
467
+
468
+ Honeybadger.configure do |config|
469
+ ...
470
+ config.debug = true
471
+ end
472
+
473
+ ## Supported Ruby versions
474
+
475
+ Honeybadger supports Ruby 1.8.7 through 2.0.
476
+
366
477
  ## Supported Rails versions
367
478
 
368
- Honeybadger supports Rails 2.3.14 through rails 3.2.9.
479
+ Honeybadger supports Rails 2.3.14 through Rails 4.0.0.beta1.
369
480
 
370
481
  ## Contributing
371
482
 
@@ -397,5 +508,5 @@ The nifty custom data (`Honeybadger.context()`) feature was inspired by Exceptio
397
508
 
398
509
  ## License
399
510
 
400
- Honeybadger is Copyright 2012 © Honeybadger Industries LLC. It is free software, and
511
+ Honeybadger is Copyright 2013 © Honeybadger Industries LLC. It is free software, and
401
512
  may be redistributed under the terms specified in the MIT-LICENSE file.
data/Rakefile CHANGED
@@ -62,6 +62,21 @@ end
62
62
  Cucumber::Rake::Task.new(:cucumber) do |t|
63
63
  t.fork = true
64
64
  t.cucumber_opts = ['--format', 'progress', '--tags', '~@pending']
65
+
66
+ unless ENV['BUNDLE_GEMFILE'] =~ /rails(3|4)/
67
+ t.cucumber_opts << '--tags ~@rails_3'
68
+ end
69
+
70
+ case ENV['BUNDLE_GEMFILE']
71
+ when /rails/
72
+ t.cucumber_opts << 'features/rails.feature features/metal.feature'
73
+ when /rack/
74
+ t.cucumber_opts << 'features/rack.feature'
75
+ when /rake/
76
+ t.cucumber_opts << 'features/rake.feature'
77
+ when /sinatra/
78
+ t.cucumber_opts << 'features/sinatra.feature'
79
+ end unless ENV['FEATURE']
65
80
  end
66
81
 
67
82
  desc "Generate RCov test coverage and open in your browser"
@@ -8,7 +8,7 @@ Feature: Use the notifier in a plain Rack app
8
8
 
9
9
  Honeybadger.configure do |config|
10
10
  config.api_key = 'my_api_key'
11
- config.logger = Logger.new(STDOUT)
11
+ config.logger = Logger.new STDOUT
12
12
  end
13
13
 
14
14
  app = Rack::Builder.app do
@@ -27,8 +27,8 @@ Feature: Use the notifier in a plain Rack app
27
27
 
28
28
  Honeybadger.configure do |config|
29
29
  config.api_key = 'my_api_key'
30
- config.logger = Logger.new(STDOUT)
31
30
  config.ignore_user_agent << /ignore/
31
+ config.logger = Logger.new STDOUT
32
32
  end
33
33
 
34
34
  class Mock
@@ -45,6 +45,29 @@ Feature: Install the Gem in a Rails application
45
45
  And I run the honeybadger generator with ""
46
46
  Then the output should contain "You must first remove the honeybadger plugin. Please run: script/plugin remove honeybadger"
47
47
 
48
+ @rails_3
49
+ Scenario: Running the test task with config.force_ssl enabled
50
+ When I configure Rails with:
51
+ """
52
+ config.force_ssl = true
53
+ """
54
+ And I configure the notifier to use "myapikey" as an API key
55
+ And I configure my application to require Honeybadger
56
+ And I run `rake honeybadger:test`
57
+ Then I should receive a Honeybadger notification
58
+
59
+ @rails_3
60
+ Scenario: Running the test task with better_errors installed
61
+ When I configure Rails with:
62
+ """
63
+ require 'better_errors'
64
+ """
65
+ And I configure the notifier to use "myapikey" as an API key
66
+ And I configure my application to require Honeybadger
67
+ And I run `rake honeybadger:test`
68
+ Then the output should contain "Better Errors detected"
69
+ And I should receive a Honeybadger notification
70
+
48
71
  Scenario: Rescue an exception in a controller
49
72
  When I configure my application to require Honeybadger
50
73
  And I configure Honeybadger with:
@@ -61,6 +84,59 @@ Feature: Install the Gem in a Rails application
61
84
  And I perform a request to "http://example.com:123/test/index?param=value"
62
85
  Then I should receive a Honeybadger notification
63
86
 
87
+ Scenario: Rescue an exception in a metal controller
88
+ When I configure my application to require Honeybadger
89
+ And I configure Honeybadger with:
90
+ """
91
+ config.api_key = 'myapikey'
92
+ config.logger = Logger.new(STDOUT)
93
+ """
94
+ And I define a metal response for "TestController#index":
95
+ """
96
+ raise RuntimeError, "some message"
97
+ """
98
+ And I route "/test/index" to "test#index"
99
+ And I perform a request to "http://example.com:123/test/index?param=value"
100
+ Then I should receive a Honeybadger notification
101
+
102
+ Scenario: Log output in production environments
103
+ When I configure my application to require Honeybadger
104
+ And I configure Honeybadger with:
105
+ """
106
+ config.api_key = 'myapikey'
107
+ config.logger = Logger.new(STDOUT)
108
+ config.logger.level = Logger::INFO
109
+ """
110
+ And I define a response for "TestController#index":
111
+ """
112
+ raise RuntimeError, "some message"
113
+ """
114
+ And I route "/test/index" to "test#index"
115
+ And I perform a request to "http://example.com:123/test/index?param=value"
116
+ Then the output should match /\[Honeybadger\] Notifier (?:[\d\.]+) ready to catch errors/
117
+ Then the output should not contain "[Honeybadger] Success"
118
+ Then the output should not contain "[Honeybadger] Environment Info"
119
+ Then the output should not contain "[Honeybadger] Response from Honeybadger"
120
+ Then the output should not contain "[Honeybadger] Notice"
121
+
122
+ Scenario: Failure to notify Honeybadger in production environments
123
+ When I configure the Honeybadger failure shim
124
+ And I configure my application to require Honeybadger
125
+ And I configure Honeybadger with:
126
+ """
127
+ config.api_key = 'myapikey'
128
+ config.logger = Logger.new(STDOUT)
129
+ config.logger.level = Logger::INFO
130
+ """
131
+ And I define a response for "TestController#index":
132
+ """
133
+ raise RuntimeError, "some message"
134
+ """
135
+ And I route "/test/index" to "test#index"
136
+ And I perform a request to "http://example.com:123/test/index?param=value"
137
+ Then the output should contain "[Honeybadger] Failure"
138
+ Then the output should not contain "Honeybadger::Sender#send_to_honeybadger"
139
+
64
140
  Scenario: The app uses Vlad instead of Capistrano
65
141
  When I configure my application to require Honeybadger
66
142
  And I run `touch config/deploy.rb`
@@ -97,6 +173,7 @@ Feature: Install the Gem in a Rails application
97
173
  config.api_key = "myapikey"
98
174
  config.logger = Logger.new(STDOUT)
99
175
  config.params_filters << "credit_card_number"
176
+ config.debug = true
100
177
  """
101
178
  And I define a response for "TestController#index":
102
179
  """
@@ -116,6 +193,7 @@ Feature: Install the Gem in a Rails application
116
193
  config.api_key = "myapikey"
117
194
  config.logger = Logger.new(STDOUT)
118
195
  config.params_filters << "secret"
196
+ config.debug = true
119
197
  """
120
198
  And I define a response for "TestController#index":
121
199
  """
@@ -134,6 +212,7 @@ Feature: Install the Gem in a Rails application
134
212
  """
135
213
  config.api_key = 'myapikey'
136
214
  config.logger = Logger.new(STDOUT)
215
+ config.debug = true
137
216
  """
138
217
  And I configure the application to filter parameter "secret"
139
218
  And I define a response for "TestController#index":
@@ -167,21 +246,6 @@ Feature: Install the Gem in a Rails application
167
246
  And I perform a request to "http://example.com:123/test/index?param=value"
168
247
  Then I should receive a Honeybadger notification
169
248
 
170
- Scenario: Notify honeybadger within a metal controller
171
- When I configure my application to require Honeybadger
172
- And I configure Honeybadger with:
173
- """
174
- config.api_key = 'myapikey'
175
- config.logger = Logger.new(STDOUT)
176
- """
177
- And I define a metal response for "TestController#index":
178
- """
179
- raise RuntimeError, "some message"
180
- """
181
- And I route "/test/index" to "test#index"
182
- And I perform a request to "http://example.com:123/test/index?param=value"
183
- Then I should receive a Honeybadger notification
184
-
185
249
  Scenario: Reporting 404s
186
250
  When I configure my application to require Honeybadger
187
251
  And I configure Honeybadger with: