rollbar 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -1
- data/README.md +15 -0
- data/lib/generators/rollbar/templates/initializer.rb +10 -5
- data/lib/rollbar.rb +4 -0
- data/lib/rollbar/configuration.rb +2 -0
- data/lib/rollbar/version.rb +1 -1
- data/spec/rollbar_spec.rb +56 -3
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
**0.9.14**
|
4
|
+
- Added `custom_data_method` config option. If set, it should be a lambda that returns a hash.
|
5
|
+
- Changed initializer template to disable reporting from the 'test' environment.
|
6
|
+
|
3
7
|
**0.9.13**
|
4
8
|
- Add test for PUT params
|
5
9
|
- Parse json params when content-type is application/json
|
6
|
-
-
|
10
|
+
- Fix concurrency issue
|
7
11
|
- Remove redundant `GET` and `POST` keys from request payload (they're already included in `params`)
|
8
12
|
|
9
13
|
**0.9.12**
|
data/README.md
CHANGED
@@ -99,6 +99,21 @@ If the methods to extract the `id`, `username`, and `email` from the object retu
|
|
99
99
|
```
|
100
100
|
|
101
101
|
|
102
|
+
## Including additional runtime data
|
103
|
+
|
104
|
+
You can provide a lambda that will be called for each exception or message report. `custom_data_method` should be a lambda that takes no arguments and returns a hash.
|
105
|
+
|
106
|
+
Add the following in `config/initializers/rollbar.rb`:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
config.custom_data_method = lambda {
|
110
|
+
{ :some_key => :some_value, :complex_key => {:a => 1, :b => [2, 3, 4]} }
|
111
|
+
}
|
112
|
+
```
|
113
|
+
|
114
|
+
This data will appear in the Occurrences tab and on the Occurrence Detail pages in the Rollbar interface.
|
115
|
+
|
116
|
+
|
102
117
|
## Exception level filters
|
103
118
|
|
104
119
|
By default, all exceptions reported through `Rollbar.report_exception()` are reported at the "error" level, except for the following, which are reported at "warning" level:
|
@@ -2,11 +2,12 @@ require 'rollbar/rails'
|
|
2
2
|
Rollbar.configure do |config|
|
3
3
|
config.access_token = <%= access_token_expr %>
|
4
4
|
|
5
|
-
# Rollbar is enabled by
|
6
|
-
# environments
|
7
|
-
#
|
8
|
-
|
9
|
-
|
5
|
+
# Without configuration, Rollbar is enabled by in all environments.
|
6
|
+
# To disable in specific environments, set config.enabled=false.
|
7
|
+
# Here we'll disable in 'test':
|
8
|
+
if Rails.env.test?
|
9
|
+
config.enabled = false
|
10
|
+
end
|
10
11
|
|
11
12
|
# By default, Rollbar will try to call the `current_user` controller method
|
12
13
|
# to fetch the logged-in user object, and then call that object's `id`,
|
@@ -16,6 +17,10 @@ Rollbar.configure do |config|
|
|
16
17
|
# config.person_username_method = "my_username"
|
17
18
|
# config.person_email_method = "my_email"
|
18
19
|
|
20
|
+
# If you want to attach custom data to all exception and message reports,
|
21
|
+
# provide a lambda like the following. It should return a hash.
|
22
|
+
# config.custom_data_method = lambda { {:some_key => "some_value" } }
|
23
|
+
|
19
24
|
# Add exception class names to the exception_level_filters hash to
|
20
25
|
# change the level that exception is reported at. Note that if an exception
|
21
26
|
# has already been reported and logged the level will need to be changed
|
data/lib/rollbar.rb
CHANGED
@@ -6,6 +6,7 @@ module Rollbar
|
|
6
6
|
attr_accessor :access_token
|
7
7
|
attr_accessor :async_handler
|
8
8
|
attr_accessor :branch
|
9
|
+
attr_accessor :custom_data_method
|
9
10
|
attr_accessor :default_logger
|
10
11
|
attr_accessor :enabled
|
11
12
|
attr_accessor :endpoint
|
@@ -32,6 +33,7 @@ module Rollbar
|
|
32
33
|
|
33
34
|
def initialize
|
34
35
|
@async_handler = nil
|
36
|
+
@custom_data_method = nil
|
35
37
|
@default_logger = lambda { Logger.new(STDERR) }
|
36
38
|
@enabled = nil # set to true when configure is called
|
37
39
|
@endpoint = DEFAULT_ENDPOINT
|
data/lib/rollbar/version.rb
CHANGED
data/spec/rollbar_spec.rb
CHANGED
@@ -303,6 +303,7 @@ describe Rollbar do
|
|
303
303
|
data = Rollbar.send(:message_data, @message_body, @level, {})
|
304
304
|
data[:body][:message][:body].should == @message_body
|
305
305
|
data[:level].should == @level
|
306
|
+
data[:custom].should be_nil
|
306
307
|
end
|
307
308
|
|
308
309
|
it 'should accept extra_data' do
|
@@ -312,11 +313,30 @@ describe Rollbar do
|
|
312
313
|
data = Rollbar.send(:message_data, @message_body, 'info',
|
313
314
|
:user_id => user_id, :name => name)
|
314
315
|
|
316
|
+
data[:level].should == 'info'
|
315
317
|
message = data[:body][:message]
|
316
318
|
message[:body].should == @message_body
|
317
319
|
message[:user_id].should == user_id
|
318
320
|
message[:name].should == name
|
319
321
|
end
|
322
|
+
|
323
|
+
it 'should build a message with custom data when configured' do
|
324
|
+
Rollbar.configure do |config|
|
325
|
+
config.custom_data_method = lambda { {:foo => "bar", :hello => [1, 2, 3]} }
|
326
|
+
end
|
327
|
+
|
328
|
+
data = Rollbar.send(:message_data, @message_body, @level, {})
|
329
|
+
|
330
|
+
data[:level].should == @level
|
331
|
+
data[:body][:message][:body].should == @message_body
|
332
|
+
data[:custom].should_not be_nil
|
333
|
+
data[:custom][:foo].should == "bar"
|
334
|
+
data[:custom][:hello][2].should == 3
|
335
|
+
|
336
|
+
Rollbar.configure do |config|
|
337
|
+
config.custom_data_method = nil
|
338
|
+
end
|
339
|
+
end
|
320
340
|
end
|
321
341
|
|
322
342
|
context 'exception_data' do
|
@@ -339,6 +359,7 @@ describe Rollbar do
|
|
339
359
|
data = Rollbar.send(:exception_data, @exception)
|
340
360
|
|
341
361
|
data[:level].should_not be_nil
|
362
|
+
data[:custom].should be_nil
|
342
363
|
|
343
364
|
trace = data[:body][:trace]
|
344
365
|
|
@@ -357,6 +378,22 @@ describe Rollbar do
|
|
357
378
|
trace[:exception][:class].should match(/^(NameError|NoMethodError)$/)
|
358
379
|
trace[:exception][:message].should match(/^(undefined local variable or method `bar'|undefined method `bar' on an instance of)/)
|
359
380
|
end
|
381
|
+
|
382
|
+
it 'should include custom data when configured' do
|
383
|
+
Rollbar.configure do |config|
|
384
|
+
config.custom_data_method = lambda { {:foo => "baz", :hello => [4, 5, 6]} }
|
385
|
+
end
|
386
|
+
|
387
|
+
data = Rollbar.send(:exception_data, @exception)
|
388
|
+
data[:body][:trace].should_not be_nil
|
389
|
+
data[:custom][:foo].should == "baz"
|
390
|
+
data[:custom][:hello][2].should == 6
|
391
|
+
|
392
|
+
Rollbar.configure do |config|
|
393
|
+
config.custom_data_method = nil
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
360
397
|
end
|
361
398
|
|
362
399
|
context 'logger' do
|
@@ -421,11 +458,27 @@ describe Rollbar do
|
|
421
458
|
|
422
459
|
it 'should have an overridden environment' do
|
423
460
|
Rollbar.configure do |config|
|
424
|
-
config.environment = '
|
461
|
+
config.environment = 'overridden'
|
425
462
|
end
|
426
463
|
|
427
464
|
data = Rollbar.send(:base_data)
|
428
|
-
data[:environment].should == '
|
465
|
+
data[:environment].should == 'overridden'
|
466
|
+
end
|
467
|
+
|
468
|
+
it 'should not have custom data under default configuration' do
|
469
|
+
data = Rollbar.send(:base_data)
|
470
|
+
data[:custom].should be_nil
|
471
|
+
end
|
472
|
+
|
473
|
+
it 'should have custom data when custom_data_method is configured' do
|
474
|
+
Rollbar.configure do |config|
|
475
|
+
config.custom_data_method = lambda { {:a => 1, :b => [2, 3, 4]} }
|
476
|
+
end
|
477
|
+
|
478
|
+
data = Rollbar.send(:base_data)
|
479
|
+
data[:custom].should_not be_nil
|
480
|
+
data[:custom][:a].should == 1
|
481
|
+
data[:custom][:b][2].should == 4
|
429
482
|
end
|
430
483
|
end
|
431
484
|
|
@@ -446,7 +499,7 @@ describe Rollbar do
|
|
446
499
|
data[:branch].should == 'master'
|
447
500
|
end
|
448
501
|
end
|
449
|
-
|
502
|
+
|
450
503
|
context "project_gems" do
|
451
504
|
it "should include gem paths for specified project gems in the payload" do
|
452
505
|
gems = ['rack', 'rspec-rails']
|