airbrake 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/CHANGELOG +56 -0
  2. data/Gemfile +0 -9
  3. data/README.md +71 -3
  4. data/SUPPORTED_RAILS_VERSIONS +15 -0
  5. data/TESTING.md +8 -0
  6. data/airbrake.gemspec +10 -5
  7. data/features/rack.feature +4 -0
  8. data/features/rails.feature +66 -5
  9. data/features/step_definitions/rails_application_steps.rb +52 -7
  10. data/features/support/airbrake_shim.rb.template +5 -0
  11. data/generators/airbrake/lib/rake_commands.rb +1 -1
  12. data/generators/airbrake/templates/airbrake_tasks.rake +1 -1
  13. data/lib/airbrake.rb +14 -10
  14. data/lib/airbrake/backtrace.rb +8 -0
  15. data/lib/airbrake/capistrano.rb +0 -1
  16. data/lib/airbrake/configuration.rb +31 -4
  17. data/lib/airbrake/notice.rb +51 -9
  18. data/lib/airbrake/rack.rb +0 -1
  19. data/lib/airbrake/rails/controller_methods.rb +18 -7
  20. data/lib/airbrake/rails/javascript_notifier.rb +0 -1
  21. data/lib/airbrake/rails/middleware/exceptions_catcher.rb +10 -6
  22. data/lib/airbrake/rails3_tasks.rb +1 -2
  23. data/lib/airbrake/rake_handler.rb +3 -4
  24. data/lib/airbrake/sender.rb +35 -23
  25. data/lib/airbrake/shared_tasks.rb +2 -1
  26. data/lib/airbrake/version.rb +1 -1
  27. data/test/{airbrake_2_2.xsd → airbrake_2_3.xsd} +11 -1
  28. data/test/airbrake_tasks_test.rb +3 -3
  29. data/test/backtrace_test.rb +2 -2
  30. data/test/capistrano_test.rb +6 -6
  31. data/test/catcher_test.rb +2 -2
  32. data/test/configuration_test.rb +17 -2
  33. data/test/helper.rb +14 -14
  34. data/test/javascript_notifier_test.rb +1 -2
  35. data/test/logger_test.rb +8 -2
  36. data/test/notice_test.rb +98 -76
  37. data/test/notifier_test.rb +34 -4
  38. data/test/rack_test.rb +1 -1
  39. data/test/rails_initializer_test.rb +1 -1
  40. data/test/recursion_test.rb +1 -1
  41. data/test/sender_test.rb +22 -21
  42. data/test/user_informer_test.rb +1 -1
  43. metadata +176 -31
data/CHANGELOG CHANGED
@@ -1,3 +1,58 @@
1
+ Version 3.1.3 - 2012-09-05 18:58:27 +0200
2
+ ===============================================================================
3
+
4
+ Ben Arent (1):
5
+ Removed old mailing list.
6
+
7
+ Dylan Smith (1):
8
+ Use debug log level for verbose log messages.
9
+
10
+ Hrvoje Šimić (21):
11
+ add a note for testing against different frameworks
12
+ add a scenario to make sure 404s are ignored by default
13
+ failing scenario for #100
14
+ remove unnecessary bundler/setup requirement
15
+ move dependencies from Gemfile to gemspec
16
+ send info about the current logged in user
17
+ add async notifications
18
+ use async? instead of asnyc
19
+ add info about logger
20
+ prefer provided error message over original exception message
21
+ don't load entire environment for deploy task
22
+ safely handle render exception
23
+ remove unnecessary AirbrakeError
24
+ update XML schema
25
+ test fixes
26
+ clean whitespace
27
+ print the failed notice details
28
+ update supported rails versions
29
+ update scenarios
30
+ stop converting notice to xml before passing it to sender
31
+ remove logger from rack handler
32
+ update supported rails versions
33
+
34
+ John Pignata (1):
35
+ Cherry-pick Object#blank? extension
36
+
37
+ Joshua Wood (2):
38
+ rbenv support
39
+ Fixes outdated rake feature.
40
+
41
+ Matt Colyer (1):
42
+ Fix Airbrake so it actually reports data.
43
+
44
+ Morgan Mikel McDaris (1):
45
+ changed notify to notify_or_ignore
46
+
47
+ Sergii Boiko (2):
48
+ Refactor config.async to provide custom asynchronous delivery way
49
+ Simplify config.async to use only notice param
50
+
51
+ grosser (2):
52
+ fix exceeded available parameter key space breaks notification, fixes #99
53
+ make all tests runnable via ruby test_file.rb by loading the helper absolutely
54
+
55
+
1
56
  Version 3.1.2 - 2012-06-23 02:27:01 +0200
2
57
  ===============================================================================
3
58
 
@@ -833,3 +888,4 @@ Nick Quaranto (3):
833
888
 
834
889
 
835
890
 
891
+
data/Gemfile CHANGED
@@ -1,12 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
-
5
- if true
6
- group :test do
7
- gem 'pry'
8
- gem 'guard'
9
- gem 'guard-test'
10
- gem 'simplecov'
11
- end
12
- end
data/README.md CHANGED
@@ -11,8 +11,6 @@ Help
11
11
 
12
12
  For help with using Airbrake and this notifier visit [our support site](http://help.airbrake.io).
13
13
 
14
- For discussion of Airbrake development check out the [mailing list](http://groups.google.com/group/hoptoad-notifier-dev).
15
-
16
14
  For SSL verification see the [Resources](https://github.com/airbrake/airbrake/blob/master/resources/README.md).
17
15
 
18
16
  Rails Installation
@@ -239,6 +237,65 @@ automatically in a controller, Airbrake sets that value. If you're, however, cal
239
237
  `Airbrake#notify` or `Airbrake#notify_or_ignore`, please make sure you set that value. So the proper way of calling the
240
238
  "manual" methods would be `env['airbrake.error_id'] = Airbrake.notify_or_ignore(...)`.
241
239
 
240
+ Current user information
241
+ ------------------------
242
+ Airbrake provides information about the current logged in user, so you
243
+ could easily determine the user who experienced the error in your app.
244
+
245
+ It uses `current_user` and `current_member` to identify the
246
+ authenticated user, where `current_user` takes precendence.
247
+
248
+ If you use different naming, please add the following lines to your
249
+ controller:
250
+
251
+ alias_method :current_duck, :current_user
252
+ helper_method :current_duck
253
+
254
+ Voila! You'll get information about a duck that experienced crash about
255
+ your app.
256
+
257
+ Asynchronous notifications with Airbrake
258
+ ----------------------------------------
259
+ When your user experiences error using your application, it gets sent to
260
+ Airbrake server. This introduces a considerable latency in the response.
261
+
262
+ Asynchronous notification sending deals with this problem. Airbrake uses
263
+ [girl_friday](https://github.com/mperham/girl_friday) to achieve this
264
+ . (thanks Mike)
265
+
266
+ It's disabled by default and you can enable it in your Airbrake
267
+ configuration.
268
+
269
+ Airbrake.configure do |config|
270
+ ...
271
+ config.async = true
272
+ end
273
+
274
+ *Note that this feature is enabled with JRuby 1.6+, Rubinius 2.0+ and*
275
+ *Ruby 1.9+. It does not support Ruby 1.8 because of its poor threading*
276
+ *support.*
277
+
278
+ For implementing custom asynchronous notice delivery, send a block to `config.async`. It
279
+ receives `notice` param. Pass it to `Airbrake.sender.send_to_airbrake` method
280
+ to do actual delivery. In this way it's possible to move Airbrake notification
281
+ even in background worker(e.g. Resque or Sidekiq).
282
+
283
+ # Thread-based asynchronous send
284
+ Airbrake.configure do |config|
285
+ ...
286
+ config.async do |notice|
287
+ Thread.new { Airbrake.sender.send_to_airbrake(notice) }
288
+ end
289
+ end
290
+
291
+ # Resque-like configuration
292
+ Airbrake.configure do |config|
293
+ ...
294
+ config.async do |notice|
295
+ Resque.enqueue(AirbrakeDeliveryWorker, notice)
296
+ end
297
+ end
298
+
242
299
  Tracking deployments in Airbrake
243
300
  --------------------------------
244
301
 
@@ -272,7 +329,7 @@ controllers:
272
329
  }
273
330
  my_unpredicable_method(params)
274
331
  rescue => e
275
- Airbrake.notify(
332
+ Airbrake.notify_or_ignore(
276
333
  :error_class => "Special Error",
277
334
  :error_message => "Special Error: #{e.message}",
278
335
  :parameters => params
@@ -396,6 +453,17 @@ The notifier supports using a proxy, if your server is not able to directly reac
396
453
  config.proxy_port = 4038
397
454
  config.proxy_user = foo # optional
398
455
  config.proxy_pass = bar # optional
456
+
457
+ Logging
458
+ ------------
459
+
460
+ Airbrake uses the logger from your Rails application by default, presumably STDOUT. If you don't like Airbrake scribbling to your
461
+ standard output, just pass another `Logger` instance inside your configuration:
462
+
463
+ Airbrake.configure do |config|
464
+ ...
465
+ config.logger = Logger.new("path/to/your/log/file")
466
+ end
399
467
 
400
468
  Supported Rails versions
401
469
  ------------------------
@@ -12,12 +12,27 @@
12
12
  3.0.10
13
13
  3.0.11
14
14
  3.0.12
15
+ 3.0.13
16
+ 3.0.14
17
+ 3.0.15
18
+ 3.0.16
19
+ 3.0.17
15
20
  3.1.0
16
21
  3.1.1
17
22
  3.1.2
18
23
  3.1.3
19
24
  3.1.4
25
+ 3.1.5
26
+ 3.1.6
27
+ 3.1.7
28
+ 3.1.8
29
+ 3.1.4
20
30
  3.2.0
21
31
  3.2.1
22
32
  3.2.2
23
33
  3.2.3
34
+ 3.2.4
35
+ 3.2.5
36
+ 3.2.6
37
+ 3.2.7
38
+ 3.2.8
data/TESTING.md CHANGED
@@ -22,6 +22,14 @@ prefer to run it against specific version hit
22
22
 
23
23
  rake cucumber:rails:<VERSION>
24
24
 
25
+ You can also specify to test only against the certain frameworks we
26
+ support (rack, rake and sinatra) by executing
27
+
28
+ rake cucumber:<FRAMEWORK>
29
+
30
+ This tasks are not printed out with `rake -T` since they're added
31
+ dynamically in the Rakefile.
32
+
25
33
 
26
34
  For Maintainers
27
35
  ================
@@ -11,21 +11,26 @@ Gem::Specification.new do |s|
11
11
  s.files = Dir["{generators/**/*,lib/**/*,rails/**/*,resources/*,script/*}"] +
12
12
  %w(airbrake.gemspec CHANGELOG Gemfile Guardfile INSTALL MIT-LICENSE Rakefile README_FOR_HEROKU_ADDON.md README.md TESTING.md SUPPORTED_RAILS_VERSIONS install.rb)
13
13
  s.test_files = Dir.glob("{test,spec,features}/**/*")
14
-
14
+
15
15
  s.add_runtime_dependency("builder")
16
16
  s.add_runtime_dependency("activesupport")
17
+ s.add_runtime_dependency("girl_friday")
17
18
 
18
19
  s.add_development_dependency("actionpack", "~> 2.3.8")
19
20
  s.add_development_dependency("activerecord", "~> 2.3.8")
20
21
  s.add_development_dependency("activesupport", "~> 2.3.8")
21
- s.add_development_dependency("bourne", ">= 1.0")
22
- s.add_development_dependency("cucumber", "~> 0.10.6")
22
+ s.add_development_dependency("mocha", "0.10.5")
23
+ s.add_development_dependency("bourne", ">= 1.0")
24
+ s.add_development_dependency("cucumber", "~> 0.10.6")
23
25
  s.add_development_dependency("fakeweb", "~> 1.3.0")
24
- s.add_development_dependency("nokogiri", "~> 1.4.3.1")
26
+ s.add_development_dependency("nokogiri", "~> 1.4.3.1")
25
27
  s.add_development_dependency("rspec", "~> 2.6.0")
26
28
  s.add_development_dependency("sham_rack", "~> 1.3.0")
27
- s.add_development_dependency("shoulda", "~> 2.11.3")
29
+ s.add_development_dependency("shoulda", "~> 2.11.3")
28
30
  s.add_development_dependency("capistrano", "~> 2.8.0")
31
+ s.add_development_dependency("guard" )
32
+ s.add_development_dependency("guard-test" )
33
+ s.add_development_dependency("simplecov" )
29
34
 
30
35
  s.authors = ["Airbrake"]
31
36
  s.email = %q{support@airbrake.io}
@@ -6,11 +6,13 @@ Feature: Use the notifier in a plain Rack app
6
6
  Scenario: Rescue and exception in a Rack app
7
7
  Given the following Rack app:
8
8
  """
9
+ require 'logger'
9
10
  require 'rack'
10
11
  require 'airbrake'
11
12
 
12
13
  Airbrake.configure do |config|
13
14
  config.api_key = 'my_api_key'
15
+ config.logger = Logger.new STDOUT
14
16
  end
15
17
 
16
18
  app = Rack::Builder.app do
@@ -24,12 +26,14 @@ Feature: Use the notifier in a plain Rack app
24
26
  Scenario: Ignore user agents
25
27
  Given the following Rack app:
26
28
  """
29
+ require 'logger'
27
30
  require 'rack'
28
31
  require 'airbrake'
29
32
 
30
33
  Airbrake.configure do |config|
31
34
  config.api_key = 'my_api_key'
32
35
  config.ignore_user_agent << /ignore/
36
+ config.logger = Logger.new STDOUT
33
37
  end
34
38
 
35
39
  class Mock
@@ -94,6 +94,7 @@ Feature: Install the Gem in a Rails application
94
94
  And I route "/test/index" to "test#index"
95
95
  And I perform a request to "http://example.com:123/test/index?param=value"
96
96
  Then I should receive a Airbrake notification
97
+ Then I should see "test"
97
98
 
98
99
  Scenario: The gem should not be considered a framework gem
99
100
  When I configure the Airbrake shim
@@ -154,6 +155,8 @@ Feature: Install the Gem in a Rails application
154
155
  And I route "/test/index" to "test#index"
155
156
  And I perform a request to "http://example.com:123/test/index?param=value"
156
157
  Then I should receive a Airbrake notification
158
+ Then I should not see "red23"
159
+ And I should see "FILTERED"
157
160
 
158
161
  Scenario: Filtering session in a controller
159
162
  When I configure the Airbrake shim
@@ -171,6 +174,8 @@ Feature: Install the Gem in a Rails application
171
174
  And I route "/test/index" to "test#index"
172
175
  And I perform a request to "http://example.com:123/test/index?param=value"
173
176
  Then I should receive a Airbrake notification
177
+ Then I should not see "blue42"
178
+ And I should see "FILTERED"
174
179
 
175
180
  Scenario: Filtering session and params based on Rails parameter filters
176
181
  When I configure the Airbrake shim
@@ -185,6 +190,9 @@ Feature: Install the Gem in a Rails application
185
190
  And I route "/test/index" to "test#index"
186
191
  And I perform a request to "http://example.com:123/test/index?param=value"
187
192
  Then I should receive a Airbrake notification
193
+ And I should not see "red23"
194
+ And I should not see "blue42"
195
+ And I should see "FILTERED"
188
196
 
189
197
  Scenario: Notify airbrake within the controller
190
198
  When I configure the Airbrake shim
@@ -198,14 +206,67 @@ Feature: Install the Gem in a Rails application
198
206
  And I route "/test/index" to "test#index"
199
207
  And I perform a request to "http://example.com:123/test/index?param=value"
200
208
  Then I should receive a Airbrake notification
209
+ And I should see "test"
201
210
 
202
- Scenario: Reporting 404s
211
+ Scenario: Reporting 404s should be disabled by default
203
212
  When I configure the Airbrake shim
204
213
  And I configure usage of Airbrake
205
- And I configure the notifier to use the following configuration lines:
206
- """
207
- config.ignore_only = []
208
- """
214
+ And I perform a request to "http://example.com:123/this/route/does/not/exist"
215
+ Then I should see "The page you were looking for doesn't exist."
216
+ And I should not receive a Airbrake notification
217
+
218
+ Scenario: Reporting 404s should work when configured properly
219
+ When I configure the Airbrake shim
220
+ And I configure usage of Airbrake
221
+ When I configure the notifier to use the following configuration lines:
222
+ """
223
+ config.ignore_only = []
224
+ """
209
225
  And I perform a request to "http://example.com:123/this/route/does/not/exist"
210
226
  Then I should see "The page you were looking for doesn't exist."
211
227
  And I should receive a Airbrake notification
228
+
229
+ Scenario: reporting over SSL with utf8 check should work
230
+ Given PENDING I fix this one
231
+ When I configure the Airbrake shim
232
+ And I configure usage of Airbrake
233
+ When I configure the notifier to use the following configuration lines:
234
+ """
235
+ config.secure = true
236
+ """
237
+ And I define a response for "TestController#index":
238
+ """
239
+ raise RuntimeError, "some message"
240
+ """
241
+ And I route "/test/index" to "test#index"
242
+ And I perform a request to "http://example.com:123/test/index?utf8=✓"
243
+ Then I should receive a Airbrake notification
244
+
245
+ Scenario: It should also send the user details
246
+ When I configure the Airbrake shim
247
+ And I configure usage of Airbrake
248
+ And I define a response for "TestController#index":
249
+ """
250
+ raise RuntimeError, "some message"
251
+ """
252
+ And I route "/test/index" to "test#index"
253
+ And I have set up authentication system in my app that uses "current_user"
254
+ And I perform a request to "http://example.com:123/test/index"
255
+ Then I should receive a Airbrake notification
256
+ And the Airbrake notification should contain user details
257
+ When I have set up authentication system in my app that uses "current_member"
258
+ And I perform a request to "http://example.com:123/test/index"
259
+ Then I should receive a Airbrake notification
260
+ And the Airbrake notification should contain user details
261
+
262
+ Scenario: It should log the notice when failure happens
263
+ When Airbrake server is not responding
264
+ And I configure usage of Airbrake
265
+ And I define a response for "TestController#index":
266
+ """
267
+ raise RuntimeError, "some message"
268
+ """
269
+ And I route "/test/index" to "test#index"
270
+ And I perform a request to "http://example.com:123/test/index?param=value"
271
+ Then I should see "Notice details:"
272
+ And I should see "some message"
@@ -5,6 +5,24 @@ Given /^I have built and installed the "([^\"]*)" gem$/ do |gem_name|
5
5
  @terminal.build_and_install_gem(File.join(PROJECT_ROOT, "#{gem_name}.gemspec"))
6
6
  end
7
7
 
8
+ Given /^PENDING/ do
9
+ pending
10
+ end
11
+
12
+ Given /^Airbrake server is not responding$/ do
13
+ bundle_gem("sham_rack")
14
+ content = <<-CONTENT
15
+ require 'sham_rack'
16
+
17
+ Airbrake.configuration.logger = Logger.new STDOUT
18
+
19
+ ShamRack.at("api.airbrake.io") {["500", { "Content-type" => "text/xml" }, ["Internal server error"]]}
20
+
21
+ CONTENT
22
+ target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb')
23
+ File.open(target,"w") { |f| f.write content }
24
+ end
25
+
8
26
  When /^I generate a new Rails application$/ do
9
27
  @terminal.cd(TEMP_DIR)
10
28
 
@@ -23,14 +41,14 @@ When /^I generate a new Rails application$/ do
23
41
 
24
42
  @terminal.run(%{ruby -rrubygems -rthread -e "#{load_rails.strip!}" #{rails_create_command} rails_root})
25
43
  if rails_root_exists?
26
- @terminal.echo("Generated a Rails #{version_string} application")
44
+ @terminal.echo("Generated a Rails #{version_string.strip} application")
27
45
  else
28
46
  raise "Unable to generate a Rails application:\n#{@terminal.output}"
29
47
  end
30
48
  require_thread
31
49
  if version_string >= "3.1.0"
32
50
  When %{I configure my application to require the "therubyracer" gem with version "0.10.1"}
33
- elsif version_string == "2.3.14"
51
+ elsif version_string =~ /2.3.14/
34
52
  monkeypatch_old_version
35
53
  end
36
54
  config_gem_dependencies unless rails3
@@ -80,10 +98,10 @@ When /^I run "([^\"]*)"$/ do |command|
80
98
  @terminal.run(command)
81
99
  end
82
100
 
83
- Then /^I should receive a Airbrake notification$/ do
84
- Then %{I should see "** [Airbrake] Response from Airbrake:"}
85
- And %{I should see "b6817316-9c45-ed26-45eb-780dbb86aadb"}
86
- And %{I should see "http://airbrake.io/locate/b6817316-9c45-ed26-45eb-780dbb86aadb"}
101
+ Then /^I should( not)? receive a Airbrake notification$/ do |or_should_not|
102
+ Then %{I should#{or_should_not} see "** [Airbrake] Response from Airbrake:"}
103
+ And %{I should#{or_should_not} see "b6817316-9c45-ed26-45eb-780dbb86aadb"}
104
+ And %{I should#{or_should_not} see "http://airbrake.io/locate/b6817316-9c45-ed26-45eb-780dbb86aadb"}
87
105
  end
88
106
 
89
107
  Then /^I should receive two Airbrake notifications$/ do
@@ -94,7 +112,6 @@ When /^I configure the Airbrake shim$/ do
94
112
  if bundler_manages_gems?
95
113
  bundle_gem("sham_rack")
96
114
  end
97
-
98
115
  shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'airbrake_shim.rb.template')
99
116
  if rails_supports_initializers?
100
117
  target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb')
@@ -105,6 +122,8 @@ When /^I configure the Airbrake shim$/ do
105
122
  file.write IO.read(shim_file)
106
123
  end
107
124
  end
125
+ target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb')
126
+ FileUtils.cp(shim_file, target)
108
127
  end
109
128
 
110
129
  When /^I configure the notifier to use "([^\"]*)" as an API key$/ do |api_key|
@@ -431,3 +450,29 @@ When /^I configure usage of Airbrake$/ do
431
450
  When %{I run the airbrake generator with "-k myapikey"}
432
451
  @terminal.flush! # flush the results of setting up Airbrake (generates notification)
433
452
  end
453
+
454
+
455
+ When /^I have set up authentication system in my app that uses "([^\"]*)"$/ do |current_user|
456
+ application_controller = File.join(rails_root, 'app', 'controllers', "application_controller.rb")
457
+ definition =
458
+ """
459
+ class ApplicationController < ActionController::Base
460
+ def consider_all_requests_local; false; end
461
+ def local_request?; false; end
462
+
463
+ # this is the ultimate authentication system, devise is history
464
+ def #{current_user}
465
+ Struct.new(:attributes).new({:id => 1,:name => 'Bender',:email => 'bender@beer.com',:username => 'b3nd0r'})
466
+ end
467
+ end
468
+ """
469
+ File.open(application_controller, "w") {|file| file.puts definition }
470
+ end
471
+
472
+ Then /^the Airbrake notification should contain user details$/ do
473
+ Then %{I should see "Bender"}
474
+ And %{I should see "bender@beer.com"}
475
+ And %{I should see "<id>1</id>"}
476
+ And %{I should see "b3nd0r"}
477
+ end
478
+