rollbar 2.11.5 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6edb7fcbd4c4ffc66f2451d062c827adefd22616
4
- data.tar.gz: 601ce3760bb0f43db2ccd5be4ab277675ff1df59
3
+ metadata.gz: c81062a0a25993cc7d6e1cb8a16d6f2f2b2faf43
4
+ data.tar.gz: ddfba1b5a84dafd6d2b2113ae383a1a1255dd1b7
5
5
  SHA512:
6
- metadata.gz: db4d227277234a877903b5c3516667428526449ca113da5703c242dce1c44156d494d8eaf5a7c01a2015c3443b2ac31e4ea89dac36cef0f992cd81bac28cb0bb
7
- data.tar.gz: a3965fdadc10b602b0d8f721bea94924f5f183ec3d346cc8dcab996d916ac13e816d38340ea8f9797dcae8d4468b80532a9f6e2318fb7c450b5c10f46ef35542
6
+ metadata.gz: 498f4e0b6509703b0c2c8044f669bf9aa60417ff198376abfbb02ac5d8e4953c0cc470d97e4f68212b38368e1d62e5bcb61783d80a078fcc7dc5735eb7408ac4
7
+ data.tar.gz: 23fa88ce1a8422d70cc6f409439a32a703321435b2a43d7c6f2eb30ecb0ba60510d1b3e2fa0a79ff493eab9be053ac8b007767c6df8d4fd741ae0d6acd3042bf
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.12.0
4
+
5
+ Features:
6
+
7
+ - Scrub sidekiq params if needed
8
+ - Prepare rake task for non Rails frameworks
9
+
10
+ Others:
11
+ - Typo on README.md
12
+ - Add documentation for plugins architecture in docs/plugins.md
13
+
14
+ ## 2.11.5
15
+
3
16
  Bugfixes:
4
17
 
5
18
  - Use require_dependency for rake and sidekiq plugins. See [#485](https://github.com/rollbar/rollbar-gem/pull/485).
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Rollbar [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.11.5)](https://travis-ci.org/rollbar/rollbar-gem/branches)
1
+ ---
2
+ layout: page
3
+ sidebar: rollbar_sidebar
4
+ permalink: /notifiers/rollbar-gem/
5
+ toc: false
6
+ ---
7
+ # Rollbar [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.12.0)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
8
 
3
9
  <!-- RemoveNext -->
4
10
  [Rollbar](https://rollbar.com) is an error tracking service for Ruby and other languages. The Rollbar service will alert you of problems with your code and help you understand them in a ways never possible before. We love it and we hope you will too.
@@ -26,7 +32,7 @@ This is the Ruby library for Rollbar. It will instrument many kinds of Ruby appl
26
32
  - [Data sanitization (scrubbing)](#data-sanitization-scrubbing)
27
33
  - [Including additional runtime data](#including-additional-runtime-data)
28
34
  - [Exception level filters](#exception-level-filters)
29
- - [Dyanmic levels](#dynamic-levels)
35
+ - [Dynamic levels](#dynamic-levels)
30
36
  - [Before process hook](#before-process-hook)
31
37
  - [Transform hook](#transform-hook)
32
38
  - [The Scope](#the-scope)
@@ -56,6 +62,7 @@ This is the Ruby library for Rollbar. It will instrument many kinds of Ruby appl
56
62
  - [SSL](#ssl)
57
63
  - [Using with Zeus](#using-with-zeus)
58
64
  - [Configuration options](#configuration-options)
65
+ - [Plugins](#plugins)
59
66
  - [Backwards Compatibility](#backwards-compatibility)
60
67
  - [Known Issues](#known-issues)
61
68
  - [Supported Language/Framework Versions](#supported-languageframework-versions)
@@ -218,6 +225,22 @@ $ rake rollbar:test
218
225
 
219
226
  This will raise an exception within a test request; if it works, you'll see a stacktrace in the console, and the exception will appear in the Rollbar dashboard.
220
227
 
228
+ If you're not using Rails, you may first need to add the following to your Rakefile:
229
+
230
+ ```ruby
231
+ require 'rollbar/rake_tasks'
232
+ ```
233
+
234
+ You may also need to add an `:environment` task to your Rakefile if you haven't already defined one. At a bare minimum, this task should call `Rollbar.configure()` and set your access token.
235
+
236
+ ```ruby
237
+ task :environment do
238
+ Rollbar.configure do |config |
239
+ config.access_token = '...'
240
+ end
241
+ end
242
+ ```
243
+
221
244
  ## Usage
222
245
 
223
246
  ### Uncaught exceptions
@@ -937,6 +960,10 @@ Some users have reported problems with Zeus when ```rake``` was not explicitly i
937
960
  For a listing of all configuration options available, see
938
961
  [configuration](https://rollbar.com/docs/notifier/rollbar-gem/configuration).
939
962
 
963
+ ## Plugins
964
+
965
+ The support for the different frameworks and libraries is organized into different plugin definitions. The plugins architecture documentation can be found in [Plugins](https://rollbar.com/docs/notifier/rollbar-gem/plugins).
966
+
940
967
  ## Backwards Compatibility
941
968
 
942
969
  You can find upgrading notes in [UPGRADING.md](UPGRADING.md).
@@ -0,0 +1,46 @@
1
+ # Plugins
2
+
3
+ The plugins architecture offers an easy way to load the wrappers for libaries or frameworks we want to send Rollbar reports from. The different plugins we've written can be found in https://github.com/rollbar/rollbar-gem/tree/master/lib/rollbar/plugins. In this document we'll explain the interface that a plugin offers.
4
+
5
+ If you'd like to open a PR in this gem in order to add a plugin for a library or framework that this gem does not yet support, create a file with the name of the framework in `lib/rollbar/plugins`. Here an example of a plugin:
6
+
7
+ ```ruby
8
+ # lib/rollbar/plugins/my_framework.rb
9
+
10
+ Rollbar.plugins.define('my-framework') do
11
+ require_dependency 'my_framework'
12
+ dependency { defined?(MyFramework::ErrorHandlers) }
13
+
14
+ execute! do
15
+ # This block is executed before Rollbar.configure is called
16
+ end
17
+
18
+ execute do
19
+ MyWramework::ErrorHandlers.add do |e| do
20
+ Rollbar.error(e)
21
+ end
22
+ end
23
+ end
24
+ ```
25
+
26
+ In the example from above you can guess we've defined a plugin called `my-framework` using the statement `Rollbar.plugins.define('my-framework')`. All the Rollbar plugins are defined under `Rollbar.plugins`, an instance of `Rollbar::Plugins`, which is the plugins manager.
27
+
28
+ ## Plugin DSL
29
+
30
+ The DSL used in the plugins architecture is quite easy:
31
+
32
+ - `dependency` recieves a block that will be executed in order to evaluate if the `execute` blocks should be executed or not. You can define any number of `dependency` blocks. If any of those return a non-truthy value, the `execute` blocks will be avoided and your plugin will not have any impact on the gem behavior.
33
+
34
+ - `require_dependency` receives a string. It calls `require` with the passed string and aborts the plugin load should the `require` call fail. This is useful when you want to ensure the library or framework gem you want to wrap really exists in the project.
35
+
36
+ - `execute` also receives a block. You can define any number of `execute` blocks that will be executed in order if all the dependencies, defined by the `dependency` blocks, are satisfied. In the block passed to `execute` you should add the error handler for the framework you are wrapping, inject a module to an existing one, monkey patch a class, or whatever you need in order to send reports to Rollbar when using that framework.
37
+
38
+ The blocks passed to `execute` are always executed after `Rollbar.configure` has been called in any of your initializer files or configuration files, so you are sure the `Rollbar.configuration` in your `execute` blocks is valid and what you expect to be.
39
+
40
+ - `execute!` is used on your plugin definition in those cases where you need to execute a block of code before `Rollbar.configure` is called. So in the moment the plugin file is read, that happens on a `require 'rollbar'` statement, the block passed to `execute!` is called.
41
+
42
+ This is useful in those cases when the framework initialization needs your plugin to be attached to some hooks or any initialization process. This is what happens for example in the Rails plugin, where we need to define our own engine and that needs to be done before the `Rollbar.configure` call.
43
+
44
+ ## Examples
45
+
46
+ The best way to understand how to build other plugins for the gem is taking a look into our existing plugins code, in https://github.com/rollbar/rollbar-gem/tree/master/lib/rollbar/plugins. If you have any doubt about how to define a new plugin, please, open an issue in the gem repository and we'll be very glad to help you!
@@ -1,3 +1,5 @@
1
+ require 'rollbar/scrubbers/params'
2
+
1
3
  module Rollbar
2
4
  class Sidekiq
3
5
  PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class]
@@ -14,8 +16,9 @@ module Rollbar
14
16
  return if skip_report?(msg_or_context, e)
15
17
 
16
18
  params = msg_or_context.reject{ |k| PARAM_BLACKLIST.include?(k) }
19
+ scrubbed_params = scrub_params(params)
17
20
  scope = {
18
- :request => { :params => params },
21
+ :request => { :params => scrubbed_params },
19
22
  :framework => "Sidekiq: #{::Sidekiq::VERSION}"
20
23
  }
21
24
  if params.is_a?(Hash)
@@ -26,6 +29,15 @@ module Rollbar
26
29
  Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
27
30
  end
28
31
 
32
+ def self.scrub_params(params)
33
+ options = {
34
+ :params => params,
35
+ :config => Rollbar.configuration.scrub_fields
36
+ }
37
+
38
+ Rollbar::Scrubbers::Params.call(options)
39
+ end
40
+
29
41
  def self.skip_report?(msg_or_context, e)
30
42
  msg_or_context.is_a?(Hash) && msg_or_context["retry"] &&
31
43
  msg_or_context["retry_count"] && msg_or_context["retry_count"] < ::Rollbar.configuration.sidekiq_threshold
@@ -1,72 +1,98 @@
1
1
  require 'rollbar'
2
+ require 'rack/mock'
2
3
  require 'logger'
3
4
 
4
5
  namespace :rollbar do
5
- desc "Verify your gem installation by sending a test exception to Rollbar"
6
+ desc 'Verify your gem installation by sending a test exception to Rollbar'
6
7
  task :test => [:environment] do
7
- Rails.logger = defined?(ActiveSupport::TaggedLogging) ?
8
- ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) :
9
- Logger.new(STDOUT)
8
+ if defined?(Rails)
9
+ Rails.logger = if defined?(ActiveSupport::TaggedLogging)
10
+ ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
11
+ else
12
+ Logger.new(STDOUT)
13
+ end
10
14
 
11
- Rails.logger.level = Logger::DEBUG
12
- Rollbar.preconfigure do |config|
13
- config.logger = Rails.logger
15
+ Rails.logger.level = Logger::DEBUG
16
+ Rollbar.preconfigure do |config|
17
+ config.logger = Rails.logger
18
+ end
14
19
  end
15
20
 
16
21
  class RollbarTestingException < RuntimeError; end
17
22
 
18
23
  unless Rollbar.configuration.access_token
19
- puts "Rollbar needs an access token configured. Check the README for instructions."
24
+ puts 'Rollbar needs an access token configured. Check the README for instructions.'
25
+
20
26
  exit
21
27
  end
22
28
 
29
+ puts 'Testing manual report...'
23
30
  Rollbar.error('Test error from rollbar:test')
24
31
 
25
- begin
26
- require './app/controllers/application_controller'
27
- rescue LoadError
28
- end
32
+ # Module to inject into the Rails controllers or
33
+ # rack apps
34
+ module RollbarTest
35
+ def test_rollbar
36
+ puts 'Raising RollbarTestingException to simulate app failure.'
29
37
 
30
- unless defined?(ApplicationController)
31
- puts "No ApplicationController found, using ActionController::Base instead"
32
- class ApplicationController < ActionController::Base; end
38
+ raise RollbarTestingException.new, 'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
39
+ end
33
40
  end
34
41
 
35
- puts "Setting up the controller."
36
- class ApplicationController
37
- prepend_before_filter :test_rollbar
38
- def test_rollbar
39
- puts "Raising RollbarTestingException to simulate app failure."
40
- raise RollbarTestingException.new, 'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
42
+ if defined?(Rails)
43
+ begin
44
+ require './app/controllers/application_controller'
45
+ rescue LoadError
41
46
  end
42
47
 
43
- def verify
48
+ unless defined?(ApplicationController)
49
+ puts 'No ApplicationController found, using ActionController::Base instead'
50
+ class ApplicationController < ActionController::Base; end
44
51
  end
45
52
 
46
- def logger
47
- nil
53
+ puts 'Setting up the controller.'
54
+
55
+ class RollbarTestController < ApplicationController
56
+ include RollbarTest
57
+
58
+ def verify
59
+ test_rollbar
60
+ end
61
+
62
+ def logger
63
+ nil
64
+ end
65
+ end
66
+
67
+ Rails.application.routes_reloader.execute_if_updated
68
+ Rails.application.routes.draw do
69
+ get 'verify' => 'rollbar_test#verify', :as => 'verify'
48
70
  end
49
- end
50
71
 
51
- class RollbarTestController < ApplicationController; end
72
+ # from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
73
+ if defined? Authlogic
74
+ Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
75
+ end
52
76
 
53
- Rails.application.routes_reloader.execute_if_updated
54
- Rails.application.routes.draw do
55
- get 'verify' => 'application#verify', :as => 'verify'
56
- end
77
+ protocol = (defined? Rails.application.config.force_ssl && Rails.application.config.force_ssl) ? 'https' : 'http'
78
+ app = Rails.application
79
+ else
80
+ protocol = 'http'
81
+ app = Class.new do
82
+ include RollbarTest
57
83
 
58
- # from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
59
- if defined? Authlogic
60
- Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
84
+ def self.call(_env)
85
+ new.test_rollbar
86
+ end
87
+ end
61
88
  end
62
89
 
63
- puts "Processing..."
64
- protocol = (defined? Rails.application.config.force_ssl && Rails.application.config.force_ssl) ? 'https' : 'http'
90
+ puts 'Processing...'
65
91
  env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify")
66
- status, headers, response = Rails.application.call(env)
92
+ status, = app.call(env)
67
93
 
68
94
  unless status.to_i == 500
69
- puts "Test failed! You may have a configuration issue, or you could be using a gem that's blocking the test. Contact support@rollbar.com if you need help troubleshooting."
95
+ puts 'Test failed! You may have a configuration issue, or you could be using a gem that\'s blocking the test. Contact support@rollbar.com if you need help troubleshooting.'
70
96
  end
71
97
  end
72
98
  end
@@ -49,6 +49,8 @@ module Rollbar
49
49
  fields_regex = options[:fields_regex]
50
50
  scrub_all = options[:scrub_all]
51
51
 
52
+ return scrub_array(params, options) if params.is_a?(Array)
53
+
52
54
  params.to_hash.inject({}) do |result, (key, value)|
53
55
  if value.is_a?(Hash)
54
56
  result[key] = scrub(value, options)
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.11.5'
2
+ VERSION = '2.12.0'
3
3
  end
@@ -34,6 +34,33 @@ describe Rollbar::Sidekiq, :reconfigure_notifier => false do
34
34
  described_class.handle_exception(msg_or_context, exception)
35
35
  end
36
36
 
37
+ context 'with fields in params to be scrubbed' do
38
+ let(:msg_or_context) do
39
+ {
40
+ :foo => 'bar',
41
+ :secret => 'foo',
42
+ :password => 'foo',
43
+ :password_confirmation => 'foo'
44
+ }
45
+ end
46
+ let(:expected_params) do
47
+ {
48
+ :foo => 'bar',
49
+ :secret => /\*+/,
50
+ :password => /\*+/,
51
+ :password_confirmation => /\*+/
52
+ }
53
+ end
54
+
55
+ before { reconfigure_notifier }
56
+
57
+ it 'sends a report with the scrubbed fields' do
58
+ described_class.handle_exception(msg_or_context, exception)
59
+
60
+ expect(Rollbar.last_report[:request][:params]).to be_eql_hash_with_regexes(expected_params)
61
+ end
62
+ end
63
+
37
64
  context 'when a sidekiq worker class is set' do
38
65
  it 'adds the sidekiq#queue-name to the error report context' do
39
66
  msg_or_context = {"retry" => true, "retry_count" => 1, 'queue' => 'default', 'class' => 'MyWorkerClass'}
@@ -92,7 +119,6 @@ describe Rollbar::Sidekiq, :reconfigure_notifier => false do
92
119
  described_class.handle_exception(msg_or_context, exception)
93
120
  }.to_not raise_error
94
121
  end
95
-
96
122
  end
97
123
  end
98
124
 
@@ -27,6 +27,33 @@ describe Rollbar::Scrubbers::Params do
27
27
  [:secret, :password]
28
28
  end
29
29
 
30
+ context 'with Array object' do
31
+ let(:params) do
32
+ [
33
+ {
34
+ :foo => 'bar',
35
+ :secret => 'the-secret',
36
+ :password => 'the-password',
37
+ :password_confirmation => 'the-password'
38
+ }
39
+ ]
40
+ end
41
+ let(:result) do
42
+ [
43
+ {
44
+ :foo => 'bar',
45
+ :secret => /\*+/,
46
+ :password => /\*+/,
47
+ :password_confirmation => /\*+/
48
+ }
49
+ ]
50
+ end
51
+
52
+ it 'scrubs the required parameters' do
53
+ expect(subject.call(options).first).to be_eql_hash_with_regexes(result.first)
54
+ end
55
+ end
56
+
30
57
  context 'with simple Hash' do
31
58
  let(:params) do
32
59
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.5
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -49,6 +49,7 @@ files:
49
49
  - bin/rollbar-rails-runner
50
50
  - data/rollbar.snippet.js
51
51
  - docs/configuration.md
52
+ - docs/plugins.md
52
53
  - gemfiles/rails30.gemfile
53
54
  - gemfiles/rails31.gemfile
54
55
  - gemfiles/rails32.gemfile