rollbar 2.16.2 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +47 -0
  3. data/.travis.yml +182 -94
  4. data/Appraisals +10 -10
  5. data/Gemfile +45 -13
  6. data/README.md +20 -3
  7. data/Rakefile +0 -0
  8. data/data/rollbar.snippet.js +1 -1
  9. data/docs/configuration.md +15 -0
  10. data/gemfiles/rails30.gemfile +21 -14
  11. data/gemfiles/rails31.gemfile +21 -12
  12. data/gemfiles/rails32.gemfile +18 -8
  13. data/gemfiles/rails40.gemfile +18 -6
  14. data/gemfiles/rails41.gemfile +17 -6
  15. data/gemfiles/rails42.gemfile +24 -14
  16. data/gemfiles/rails50.gemfile +20 -11
  17. data/gemfiles/rails51.gemfile +20 -10
  18. data/gemfiles/rails52.gemfile +65 -0
  19. data/gemfiles/rails60.gemfile +67 -0
  20. data/lib/generators/rollbar/rollbar_generator.rb +1 -1
  21. data/lib/rails/rollbar_runner.rb +17 -2
  22. data/lib/rollbar.rb +2 -3
  23. data/lib/rollbar/capistrano.rb +71 -39
  24. data/lib/rollbar/capistrano3.rb +56 -1
  25. data/lib/rollbar/capistrano_tasks.rb +130 -0
  26. data/lib/rollbar/configuration.rb +95 -7
  27. data/lib/rollbar/delay/active_job.rb +17 -0
  28. data/lib/rollbar/delay/girl_friday.rb +2 -2
  29. data/lib/rollbar/delay/resque.rb +4 -6
  30. data/lib/rollbar/delay/shoryuken.rb +15 -9
  31. data/lib/rollbar/delay/sidekiq.rb +6 -8
  32. data/lib/rollbar/delay/sucker_punch.rb +17 -19
  33. data/lib/rollbar/delay/thread.rb +3 -3
  34. data/lib/rollbar/deploy.rb +90 -0
  35. data/lib/rollbar/encoding/encoder.rb +9 -9
  36. data/lib/rollbar/exception_reporter.rb +19 -5
  37. data/lib/rollbar/item.rb +62 -20
  38. data/lib/rollbar/item/backtrace.rb +4 -4
  39. data/lib/rollbar/item/frame.rb +7 -1
  40. data/lib/rollbar/item/locals.rb +56 -0
  41. data/lib/rollbar/json.rb +5 -51
  42. data/lib/rollbar/language_support.rb +4 -20
  43. data/lib/rollbar/lazy_store.rb +5 -5
  44. data/lib/rollbar/logger.rb +1 -0
  45. data/lib/rollbar/logger_proxy.rb +15 -2
  46. data/lib/rollbar/middleware/js.rb +110 -10
  47. data/lib/rollbar/middleware/js/json_value.rb +26 -0
  48. data/lib/rollbar/middleware/rack.rb +4 -1
  49. data/lib/rollbar/middleware/rails/rollbar.rb +10 -1
  50. data/lib/rollbar/notifier.rb +118 -49
  51. data/lib/rollbar/notifier/trace_with_bindings.rb +65 -0
  52. data/lib/rollbar/plugin.rb +54 -6
  53. data/lib/rollbar/plugins.rb +7 -1
  54. data/lib/rollbar/plugins/active_job.rb +5 -1
  55. data/lib/rollbar/plugins/basic_socket.rb +21 -6
  56. data/lib/rollbar/plugins/delayed_job/job_data.rb +3 -3
  57. data/lib/rollbar/plugins/delayed_job/plugin.rb +3 -3
  58. data/lib/rollbar/plugins/goalie.rb +11 -3
  59. data/lib/rollbar/plugins/rails/controller_methods.rb +17 -4
  60. data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -3
  61. data/lib/rollbar/plugins/rake.rb +2 -2
  62. data/lib/rollbar/plugins/sidekiq/plugin.rb +10 -6
  63. data/lib/rollbar/rake_tasks.rb +3 -86
  64. data/lib/rollbar/request_data_extractor.rb +35 -21
  65. data/lib/rollbar/rollbar_test.rb +147 -0
  66. data/lib/rollbar/scrubbers.rb +7 -3
  67. data/lib/rollbar/scrubbers/params.rb +38 -20
  68. data/lib/rollbar/scrubbers/url.rb +27 -13
  69. data/lib/rollbar/truncation.rb +9 -2
  70. data/lib/rollbar/truncation/min_body_strategy.rb +2 -3
  71. data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
  72. data/lib/rollbar/truncation/remove_extra_strategy.rb +35 -0
  73. data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
  74. data/lib/rollbar/truncation/strings_strategy.rb +3 -4
  75. data/lib/rollbar/util.rb +75 -45
  76. data/lib/rollbar/util/hash.rb +30 -6
  77. data/lib/rollbar/util/ip_anonymizer.rb +8 -7
  78. data/lib/rollbar/util/ip_obfuscator.rb +1 -1
  79. data/lib/rollbar/version.rb +1 -1
  80. data/lib/tasks/benchmark.rake +103 -0
  81. data/rollbar.gemspec +14 -8
  82. metadata +25 -277
  83. data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -49
  84. data/lib/rollbar/json/default.rb +0 -11
  85. data/lib/rollbar/json/oj.rb +0 -16
  86. data/lib/rollbar/tasks/rollbar.cap +0 -47
  87. data/spec/cacert.pem +0 -3988
  88. data/spec/controllers/home_controller_spec.rb +0 -480
  89. data/spec/delay/sidekiq_spec.rb +0 -61
  90. data/spec/delay/sucker_punch_spec.rb +0 -25
  91. data/spec/delayed/backend/test.rb +0 -140
  92. data/spec/delayed/serialization/test.rb +0 -0
  93. data/spec/dummyapp/.gitignore +0 -73
  94. data/spec/dummyapp/Rakefile +0 -7
  95. data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
  96. data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
  97. data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
  98. data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
  99. data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
  100. data/spec/dummyapp/app/helpers/.gitkeep +0 -0
  101. data/spec/dummyapp/app/mailers/.gitkeep +0 -0
  102. data/spec/dummyapp/app/models/.gitkeep +0 -0
  103. data/spec/dummyapp/app/models/book.rb +0 -5
  104. data/spec/dummyapp/app/models/post.rb +0 -9
  105. data/spec/dummyapp/app/models/user.rb +0 -9
  106. data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
  107. data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
  108. data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
  109. data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
  110. data/spec/dummyapp/app/views/home/index.html.erb +0 -4
  111. data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
  112. data/spec/dummyapp/app/views/js/test.html.erb +0 -1
  113. data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
  114. data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
  115. data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
  116. data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
  117. data/spec/dummyapp/app/views/users/index.html.erb +0 -8
  118. data/spec/dummyapp/app/views/users/show.html.erb +0 -3
  119. data/spec/dummyapp/config.ru +0 -4
  120. data/spec/dummyapp/config/application.rb +0 -59
  121. data/spec/dummyapp/config/boot.rb +0 -10
  122. data/spec/dummyapp/config/database.yml +0 -25
  123. data/spec/dummyapp/config/environment.rb +0 -5
  124. data/spec/dummyapp/config/environments/development.rb +0 -37
  125. data/spec/dummyapp/config/environments/production.rb +0 -67
  126. data/spec/dummyapp/config/environments/test.rb +0 -37
  127. data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
  128. data/spec/dummyapp/config/initializers/inflections.rb +0 -15
  129. data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
  130. data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
  131. data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
  132. data/spec/dummyapp/config/initializers/session_store.rb +0 -8
  133. data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
  134. data/spec/dummyapp/config/locales/devise.en.yml +0 -58
  135. data/spec/dummyapp/config/locales/en.yml +0 -5
  136. data/spec/dummyapp/config/routes.rb +0 -17
  137. data/spec/dummyapp/config/secrets.yml +0 -2
  138. data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
  139. data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
  140. data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
  141. data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
  142. data/spec/dummyapp/db/schema.rb +0 -41
  143. data/spec/dummyapp/db/seeds.rb +0 -12
  144. data/spec/dummyapp/lib/assets/.gitkeep +0 -0
  145. data/spec/dummyapp/public/404.html +0 -26
  146. data/spec/dummyapp/public/422.html +0 -26
  147. data/spec/dummyapp/public/500.html +0 -25
  148. data/spec/dummyapp/public/favicon.ico +0 -0
  149. data/spec/dummyapp/script/rails +0 -6
  150. data/spec/fixtures/file1 +0 -1
  151. data/spec/fixtures/file2 +0 -1
  152. data/spec/fixtures/payloads/message.json +0 -25
  153. data/spec/fixtures/payloads/sample.trace.json +0 -275
  154. data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
  155. data/spec/fixtures/plugins/dummy1.rb +0 -5
  156. data/spec/fixtures/plugins/dummy2.rb +0 -5
  157. data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
  158. data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
  159. data/spec/requests/home_spec.rb +0 -49
  160. data/spec/rollbar/configuration_spec.rb +0 -46
  161. data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
  162. data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
  163. data/spec/rollbar/delay/resque_spec.rb +0 -37
  164. data/spec/rollbar/delay/thread_spec.rb +0 -27
  165. data/spec/rollbar/encoding/encoder_spec.rb +0 -63
  166. data/spec/rollbar/item/backtrace_spec.rb +0 -26
  167. data/spec/rollbar/item/frame_spec.rb +0 -267
  168. data/spec/rollbar/item_spec.rb +0 -736
  169. data/spec/rollbar/json/oj_spec.rb +0 -18
  170. data/spec/rollbar/json_spec.rb +0 -110
  171. data/spec/rollbar/lazy_store_spec.rb +0 -99
  172. data/spec/rollbar/logger_proxy_spec.rb +0 -50
  173. data/spec/rollbar/logger_spec.rb +0 -124
  174. data/spec/rollbar/middleware/js_spec.rb +0 -421
  175. data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
  176. data/spec/rollbar/notifier_spec.rb +0 -56
  177. data/spec/rollbar/plugin_spec.rb +0 -209
  178. data/spec/rollbar/plugins/active_job_spec.rb +0 -38
  179. data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
  180. data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
  181. data/spec/rollbar/plugins/rack_spec.rb +0 -152
  182. data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
  183. data/spec/rollbar/plugins/rake_spec.rb +0 -34
  184. data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
  185. data/spec/rollbar/plugins/sidekiq_spec.rb +0 -171
  186. data/spec/rollbar/plugins/validations_spec.rb +0 -56
  187. data/spec/rollbar/plugins_spec.rb +0 -68
  188. data/spec/rollbar/request_data_extractor_spec.rb +0 -270
  189. data/spec/rollbar/scrubbers/params_spec.rb +0 -314
  190. data/spec/rollbar/scrubbers/url_spec.rb +0 -136
  191. data/spec/rollbar/scrubbers_spec.rb +0 -31
  192. data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
  193. data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
  194. data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
  195. data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
  196. data/spec/rollbar/truncation_spec.rb +0 -27
  197. data/spec/rollbar/util/hash_spec.rb +0 -22
  198. data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
  199. data/spec/rollbar/util_spec.rb +0 -80
  200. data/spec/rollbar_bc_spec.rb +0 -380
  201. data/spec/rollbar_spec.rb +0 -1667
  202. data/spec/spec_helper.rb +0 -84
  203. data/spec/support/cause_exception.rb +0 -1
  204. data/spec/support/encoding_helpers.rb +0 -8
  205. data/spec/support/encodings/iso_8859_9 +0 -1
  206. data/spec/support/fixture_helpers.rb +0 -10
  207. data/spec/support/get_ip_raising.rb +0 -7
  208. data/spec/support/helpers.rb +0 -5
  209. data/spec/support/matchers.rb +0 -23
  210. data/spec/support/notifier_helpers.rb +0 -57
  211. data/spec/support/rollbar_api.rb +0 -57
  212. data/spec/support/shared_contexts.rb +0 -12
@@ -1 +1,56 @@
1
- load File.expand_path('../tasks/rollbar.cap', __FILE__)
1
+ # This is a tasks file to use with Capistrano 3
2
+
3
+ require 'net/http'
4
+ require 'rubygems'
5
+ require 'json'
6
+ require 'rollbar/deploy'
7
+ require 'rollbar/capistrano_tasks'
8
+
9
+ namespace :rollbar do
10
+ # dry_run? wasn't introduced till Capistrano 3.5.0; use the old fetch(:sshkit_backed)
11
+ set :dry_run, (proc { ::Capistrano::Configuration.env.fetch(:sshkit_backend) == ::SSHKit::Backend::Printer })
12
+
13
+ desc 'Send deployment started notification to Rollbar.'
14
+ task :deploy_started do
15
+ on primary fetch(:rollbar_role) do
16
+ ::Rollbar::CapistranoTasks.deploy_started(self, self, fetch(:dry_run))
17
+ end
18
+ end
19
+
20
+ desc 'Send deployment succeeded notification to Rollbar.'
21
+ task :deploy_succeeded do
22
+ on primary fetch(:rollbar_role) do
23
+ ::Rollbar::CapistranoTasks.deploy_succeeded(self, self, fetch(:dry_run))
24
+ end
25
+ end
26
+
27
+ desc 'Send deployment failed notification to Rollbar.'
28
+ task :deploy_failed do
29
+ on primary fetch(:rollbar_role) do
30
+ ::Rollbar::CapistranoTasks.deploy_failed(self, self, fetch(:dry_run))
31
+ end
32
+ end
33
+
34
+ task :fail do
35
+ raise StandardError
36
+ end
37
+ end
38
+
39
+ namespace :deploy do
40
+ after 'deploy:set_current_revision', 'rollbar:deploy_started'
41
+ after 'deploy:finished', 'rollbar:deploy_succeeded'
42
+ after 'deploy:failed', 'rollbar:deploy_failed'
43
+
44
+ # Used for testing :deploy_failed task
45
+ # after 'rollbar:deploy_started', 'rollbar:fail'
46
+ end
47
+
48
+ namespace :load do
49
+ task :defaults do
50
+ set :rollbar_user, (proc { fetch :local_user, ENV['USER'] || ENV['USERNAME'] })
51
+ set :rollbar_env, (proc { fetch :rails_env, 'production' })
52
+ set :rollbar_token, (proc { abort "Please specify the Rollbar access token, set :rollbar_token, 'your token'" })
53
+ set :rollbar_role, (proc { :app })
54
+ set :rollbar_revision, (proc { fetch :current_revision })
55
+ end
56
+ end
@@ -0,0 +1,130 @@
1
+ require 'rollbar/deploy'
2
+
3
+ module Rollbar
4
+ # Module containing the logic of Capistrano tasks for deploy tracking
5
+ module CapistranoTasks
6
+ class << self
7
+ def deploy_started(capistrano, logger, dry_run)
8
+ deploy_task(logger, :desc => 'Notifying Rollbar of deployment start') do
9
+ result = report_deploy_started(capistrano, dry_run)
10
+
11
+ debug_request_response(logger, result)
12
+
13
+ capistrano.set(:rollbar_deploy_id, 123) if dry_run
14
+
15
+ skip_in_dry_run(logger, dry_run) do
16
+ if result[:success] && (deploy_id = result[:data] && result[:data][:deploy_id])
17
+ capistrano.set :rollbar_deploy_id, deploy_id
18
+ else
19
+ logger.error 'Unable to report deploy to Rollbar' + (result[:message] ? ': ' + result[:message] : '')
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def deploy_succeeded(capistrano, logger, dry_run)
26
+ deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `succeeded` in Rollbar') do
27
+ report_deploy_succeeded(capistrano, dry_run)
28
+ end
29
+ end
30
+
31
+ def deploy_failed(capistrano, logger, dry_run)
32
+ deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `failed` in Rollbar') do
33
+ report_deploy_failed(capistrano, dry_run)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def deploy_task(logger, opts = {})
40
+ capistrano_300_warning(logger)
41
+ logger.info opts[:desc] if opts[:desc]
42
+ yield
43
+ end
44
+
45
+ def deploy_update(capistrano, logger, dry_run, opts = {})
46
+ deploy_task(logger, opts) do
47
+ depend_on_deploy_id(capistrano, logger) do
48
+ result = yield
49
+
50
+ debug_request_response(logger, result)
51
+
52
+ skip_in_dry_run(logger, dry_run) do
53
+ if result[:success]
54
+ logger.info 'Updated deploy status in Rollbar'
55
+ else
56
+ logger.error 'Unable to update deploy status in Rollbar' + (result[:message] ? ': ' + result[:message] : '')
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ def capistrano_300_warning(logger)
64
+ logger.warn("You need to upgrade capistrano to '>= 3.1' version in order to correctly report deploys to Rollbar. (On 3.0, the reported revision will be incorrect.)") if ::Capistrano::VERSION =~ /^3\.0/
65
+ end
66
+
67
+ def report_deploy_started(capistrano, dry_run)
68
+ ::Rollbar::Deploy.report(
69
+ {
70
+ :rollbar_username => capistrano.fetch(:rollbar_user),
71
+ :local_username => capistrano.fetch(:rollbar_user),
72
+ :comment => capistrano.fetch(:rollbar_comment),
73
+ :status => :started,
74
+ :proxy => :ENV,
75
+ :dry_run => dry_run
76
+ },
77
+ capistrano.fetch(:rollbar_token),
78
+ capistrano.fetch(:rollbar_env),
79
+ capistrano.fetch(:rollbar_revision)
80
+ )
81
+ end
82
+
83
+ def report_deploy_succeeded(capistrano, dry_run)
84
+ ::Rollbar::Deploy.update(
85
+ {
86
+ :proxy => :ENV,
87
+ :dry_run => dry_run
88
+ },
89
+ capistrano.fetch(:rollbar_token),
90
+ capistrano.fetch(:rollbar_deploy_id),
91
+ :succeeded
92
+ )
93
+ end
94
+
95
+ def report_deploy_failed(capistrano, dry_run)
96
+ ::Rollbar::Deploy.update(
97
+ {
98
+ :proxy => :ENV,
99
+ :dry_run => dry_run
100
+ },
101
+ capistrano.fetch(:rollbar_token),
102
+ capistrano.fetch(:rollbar_deploy_id),
103
+ :failed
104
+ )
105
+ end
106
+
107
+ def depend_on_deploy_id(capistrano, logger)
108
+ if capistrano.fetch(:rollbar_deploy_id)
109
+ yield
110
+ else
111
+ logger.error 'Failed to update the deploy in Rollbar. No deploy id available.'
112
+ end
113
+ end
114
+
115
+ def skip_in_dry_run(logger, dry_run)
116
+ if dry_run
117
+ logger.info 'Skipping sending HTTP requests to Rollbar in dry run.'
118
+ else
119
+ yield
120
+ end
121
+ end
122
+
123
+ def debug_request_response(logger, result)
124
+ # NOTE: in Capistrano debug messages go to log/capistrano.log but not to stdout even if log_level == :debug
125
+ logger.debug result[:request_info]
126
+ logger.debug result[:response_info] if result[:response_info]
127
+ end
128
+ end
129
+ end
130
+ end
@@ -8,10 +8,12 @@ module Rollbar
8
8
  attr_accessor :async_handler
9
9
  attr_accessor :branch
10
10
  attr_reader :before_process
11
+ attr_accessor :capture_uncaught
11
12
  attr_accessor :code_version
12
13
  attr_accessor :custom_data_method
13
14
  attr_accessor :delayed_job_enabled
14
15
  attr_accessor :default_logger
16
+ attr_reader :logger_level
15
17
  attr_accessor :disable_monkey_patch
16
18
  attr_accessor :disable_rack_monkey_patch
17
19
  attr_accessor :disable_core_monkey_patch
@@ -25,6 +27,7 @@ module Rollbar
25
27
  attr_accessor :framework
26
28
  attr_accessor :ignored_person_ids
27
29
  attr_accessor :host
30
+ attr_accessor :locals
28
31
  attr_writer :logger
29
32
  attr_accessor :payload_options
30
33
  attr_accessor :person_method
@@ -43,6 +46,7 @@ module Rollbar
43
46
  attr_accessor :scrub_fields
44
47
  attr_accessor :scrub_user
45
48
  attr_accessor :scrub_password
49
+ attr_accessor :scrub_whitelist
46
50
  attr_accessor :collect_user_ip
47
51
  attr_accessor :anonymize_user_ip
48
52
  attr_accessor :user_ip_obfuscator_secret
@@ -59,20 +63,26 @@ module Rollbar
59
63
  attr_reader :send_extra_frame_data
60
64
  attr_accessor :use_exception_level_filters_default
61
65
  attr_accessor :proxy
66
+ attr_accessor :raise_on_error
67
+ attr_accessor :transmit
68
+ attr_accessor :log_payload
62
69
 
63
70
  attr_reader :project_gem_paths
71
+ attr_accessor :configured_options
64
72
 
65
- alias_method :safely?, :safely
73
+ alias safely? safely
66
74
 
67
- DEFAULT_ENDPOINT = 'https://api.rollbar.com/api/1/item/'
68
- DEFAULT_WEB_BASE = 'https://rollbar.com'
75
+ DEFAULT_ENDPOINT = 'https://api.rollbar.com/api/1/item/'.freeze
76
+ DEFAULT_WEB_BASE = 'https://rollbar.com'.freeze
69
77
 
70
78
  def initialize
71
79
  @async_handler = nil
72
80
  @before_process = []
81
+ @capture_uncaught = nil
73
82
  @code_version = nil
74
83
  @custom_data_method = nil
75
84
  @default_logger = lambda { ::Logger.new(STDERR) }
85
+ @logger_level = :info
76
86
  @delayed_job_enabled = true
77
87
  @disable_monkey_patch = false
78
88
  @disable_core_monkey_patch = false
@@ -102,12 +112,14 @@ module Rollbar
102
112
  @net_retries = 3
103
113
  @js_enabled = false
104
114
  @js_options = {}
115
+ @locals = {}
105
116
  @scrub_fields = [:passwd, :password, :password_confirmation, :secret,
106
117
  :confirm_password, :password_confirmation, :secret_token,
107
- :api_key, :access_token]
118
+ :api_key, :access_token, :accessToken, :session_id]
108
119
  @scrub_user = true
109
120
  @scrub_password = true
110
121
  @randomize_scrub_length = true
122
+ @scrub_whitelist = []
111
123
  @uncaught_exception_level = 'error'
112
124
  @scrub_headers = ['Authorization']
113
125
  @sidekiq_threshold = 0
@@ -122,8 +134,17 @@ module Rollbar
122
134
  @project_gem_paths = []
123
135
  @use_exception_level_filters_default = false
124
136
  @proxy = nil
137
+ @raise_on_error = false
138
+ @transmit = true
139
+ @log_payload = false
125
140
  @collect_user_ip = true
126
141
  @anonymize_user_ip = false
142
+ @hooks = {
143
+ :on_error_response => nil, # params: response
144
+ :on_report_internal_error => nil # params: exception
145
+ }
146
+
147
+ @configured_options = ConfiguredOptions.new(self)
127
148
  end
128
149
 
129
150
  def initialize_copy(orig)
@@ -131,9 +152,18 @@ module Rollbar
131
152
 
132
153
  instance_variables.each do |var|
133
154
  instance_var = instance_variable_get(var)
134
- instance_variable_set(var, Rollbar::Util::deep_copy(instance_var))
155
+ instance_variable_set(var, Rollbar::Util.deep_copy(instance_var))
156
+ end
157
+ end
158
+
159
+ def wrapped_clone
160
+ original_clone.tap do |new_config|
161
+ new_config.configured_options = ConfiguredOptions.new(new_config)
162
+ new_config.configured_options.configured = configured_options.configured
135
163
  end
136
164
  end
165
+ alias original_clone clone
166
+ alias clone wrapped_clone
137
167
 
138
168
  def merge(options)
139
169
  new_configuration = clone
@@ -153,6 +183,15 @@ module Rollbar
153
183
  self
154
184
  end
155
185
 
186
+ def use_active_job(options = {})
187
+ require 'rollbar/delay/active_job'
188
+
189
+ Rollbar::Delay::ActiveJob.queue_as(options[:queue] || Rollbar::Delay::ActiveJob.default_queue_name)
190
+
191
+ @use_async = true
192
+ @async_handler = Rollbar::Delay::ActiveJob
193
+ end
194
+
156
195
  def use_delayed_job(options = {})
157
196
  require 'rollbar/delay/delayed_job'
158
197
 
@@ -177,8 +216,11 @@ module Rollbar
177
216
  @async_handler = Rollbar::Delay::Resque
178
217
  end
179
218
 
180
- def use_shoryuken
219
+ def use_shoryuken(options = {})
181
220
  require 'rollbar/delay/shoryuken' if defined?(Shoryuken)
221
+
222
+ Rollbar::Delay::Shoryuken.queue = options[:queue] if options[:queue]
223
+
182
224
  @use_async = true
183
225
  @async_handler = Rollbar::Delay::Shoryuken
184
226
  end
@@ -202,7 +244,7 @@ module Rollbar
202
244
  @async_handler = Rollbar::Delay::SuckerPunch
203
245
  end
204
246
 
205
- def use_sucker_punch=(value)
247
+ def use_sucker_punch=(_value)
206
248
  deprecation_message = '#use_sucker_punch=(value) has been deprecated in favor of #use_sucker_punch. Please update your rollbar configuration.'
207
249
  defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
208
250
 
@@ -245,8 +287,54 @@ module Rollbar
245
287
  send(option)
246
288
  end
247
289
 
290
+ def logger_level=(level)
291
+ @logger_level = if level
292
+ level.to_sym
293
+ else
294
+ level
295
+ end
296
+ end
297
+
248
298
  def logger
249
299
  @logger ||= default_logger.call
250
300
  end
301
+
302
+ def hook(symbol, &block)
303
+ if @hooks.key?(symbol)
304
+ if block_given?
305
+ @hooks[symbol] = block
306
+ else
307
+ @hooks[symbol]
308
+ end
309
+ else
310
+ raise StandardError, 'Hook :' + symbol.to_s + ' is not supported by Rollbar SDK.'
311
+ end
312
+ end
313
+
314
+ def execute_hook(symbol, *args)
315
+ hook(symbol).call(*args) if hook(symbol).is_a?(Proc)
316
+ end
317
+ end
318
+
319
+ class ConfiguredOptions
320
+ attr_accessor :configuration, :configured
321
+
322
+ def initialize(configuration)
323
+ @configuration = configuration
324
+ @configured = {}
325
+ end
326
+
327
+ def method_missing(method, *args, &block)
328
+ return super unless configuration.respond_to?(method)
329
+
330
+ method_string = method.to_s
331
+ configured[method_string.chomp('=').to_sym] = args.first if method_string.end_with?('=')
332
+
333
+ configuration.send(method, *args, &block)
334
+ end
335
+
336
+ def respond_to_missing?(method)
337
+ configuration.respond_to?(method) || super
338
+ end
251
339
  end
252
340
  end
@@ -0,0 +1,17 @@
1
+ module Rollbar
2
+ module Delay
3
+ # This class provides the ActiveJob async handler. Users can
4
+ # use ActiveJob in order to send the reports to the Rollbar API
5
+ class ActiveJob < ::ActiveJob::Base
6
+ queue_as :default
7
+
8
+ def perform(payload)
9
+ Rollbar.process_from_async_handler(payload)
10
+ end
11
+
12
+ def self.call(payload)
13
+ perform_later payload
14
+ end
15
+ end
16
+ end
17
+ end
@@ -11,10 +11,10 @@ module Rollbar
11
11
  end
12
12
 
13
13
  def queue
14
- @queue ||= self.queue_class.new(nil, :size => 5) do |payload|
14
+ @queue ||= queue_class.new(nil, :size => 5) do |payload|
15
15
  begin
16
16
  Rollbar.process_from_async_handler(payload)
17
- rescue
17
+ rescue StandardError
18
18
  # According to https://github.com/mperham/girl_friday/wiki#error-handling
19
19
  # we reraise the exception so it can be handled some way
20
20
  raise
@@ -23,12 +23,10 @@ module Rollbar
23
23
  end
24
24
 
25
25
  def perform(payload)
26
- begin
27
- Rollbar.process_from_async_handler(payload)
28
- rescue
29
- # Raise the exception so Resque can track the errored job
30
- raise
31
- end
26
+ Rollbar.process_from_async_handler(payload)
27
+ rescue StandardError
28
+ # Raise the exception so Resque can track the errored job
29
+ raise
32
30
  end
33
31
  end
34
32
  end
@@ -8,22 +8,28 @@ module Rollbar
8
8
  class Shoryuken
9
9
  include ::Shoryuken::Worker
10
10
 
11
- def self.queue_name
12
- "rollbar_#{Rollbar.configuration.environment}"
11
+ class << self
12
+ attr_accessor :queue
13
+ end
14
+
15
+ self.queue = "rollbar_#{Rollbar.configuration.environment}"
16
+
17
+ def self.call(payload)
18
+ new.call(payload, :queue => queue)
19
+ end
20
+
21
+ def call(payload, options = {})
22
+ self.class.perform_async(payload, options)
13
23
  end
14
24
 
15
25
  # not allowing bulk, to not double-report rollbars if one of them failed in bunch.
16
- shoryuken_options :queue => queue_name, :auto_delete => true, :body_parser => :json, :retry_intervals => [60, 180, 360, 120_0, 360_0, 186_00]
26
+ shoryuken_options :auto_delete => true,
27
+ :body_parser => :json,
28
+ :retry_intervals => [60, 180, 360, 120_0, 360_0, 186_00]
17
29
 
18
- ## responsible for performing job. - payload is a json parsed body of the message.
19
30
  def perform(_sqs_message, payload)
20
31
  Rollbar.process_from_async_handler(payload)
21
32
  end
22
-
23
- ## to push the job !
24
- def call(payload)
25
- self.class.perform_async(payload)
26
- end
27
33
  end
28
34
  end
29
35
  end