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
@@ -7,6 +7,8 @@ module Rollbar
7
7
  attr_reader :name
8
8
  attr_reader :dependencies
9
9
  attr_reader :callables
10
+ attr_reader :revert_callables
11
+ attr_accessor :on_demand
10
12
  attr_accessor :loaded
11
13
 
12
14
  private :loaded=
@@ -15,31 +17,73 @@ module Rollbar
15
17
  @name = name
16
18
  @dependencies = []
17
19
  @callables = []
20
+ @revert_callables = []
18
21
  @loaded = false
22
+ @on_demand = false
23
+ end
24
+
25
+ def load_on_demand
26
+ @on_demand = true
19
27
  end
20
28
 
21
29
  def configuration
22
30
  Rollbar.configuration
23
31
  end
24
32
 
33
+ def load_scoped!(transparent = false)
34
+ if transparent
35
+ load! if load?
36
+
37
+ result = yield
38
+
39
+ unload! if loaded
40
+ else
41
+ return unless load?
42
+
43
+ load!
44
+
45
+ result = yield
46
+
47
+ unload!
48
+ end
49
+
50
+ result
51
+ end
52
+
25
53
  def load!
26
54
  return unless load?
27
55
 
28
56
  begin
29
57
  callables.each(&:call)
30
- rescue => e
58
+ rescue StandardError => e
31
59
  log_loading_error(e)
32
60
  ensure
33
61
  self.loaded = true
34
62
  end
35
63
  end
36
64
 
65
+ def unload!
66
+ return unless loaded
67
+
68
+ begin
69
+ revert_callables.each(&:call)
70
+ rescue StandardError => e
71
+ log_unloading_error(e)
72
+ ensure
73
+ self.loaded = false
74
+ end
75
+ end
76
+
37
77
  def execute(&block)
38
78
  callables << block
39
79
  end
40
80
 
41
- def execute!(&block)
42
- block.call if load?
81
+ def execute!
82
+ yield if load?
83
+ end
84
+
85
+ def revert(&block)
86
+ revert_callables << block
43
87
  end
44
88
 
45
89
  private
@@ -61,7 +105,7 @@ module Rollbar
61
105
 
62
106
  def load?
63
107
  !loaded && dependencies_satisfy?
64
- rescue => e
108
+ rescue StandardError => e
65
109
  log_loading_error(e)
66
110
 
67
111
  false
@@ -71,8 +115,12 @@ module Rollbar
71
115
  dependencies.all?(&:call)
72
116
  end
73
117
 
74
- def log_loading_error(e)
75
- Rollbar.log_error("Error trying to load plugin '#{name}': #{e.class}, #{e.message}")
118
+ def log_loading_error(error)
119
+ Rollbar.log_error("Error trying to load plugin '#{name}': #{error.class}, #{error.message}")
120
+ end
121
+
122
+ def log_unloading_error(error)
123
+ Rollbar.log_error("Error trying to unload plugin '#{name}': #{error.class}, #{error.message}")
76
124
  end
77
125
  end
78
126
  end
@@ -29,7 +29,13 @@ module Rollbar
29
29
  end
30
30
 
31
31
  def load!
32
- collection.each(&:load!)
32
+ collection.each do |plugin|
33
+ plugin.load! unless plugin.on_demand
34
+ end
35
+ end
36
+
37
+ def get(name)
38
+ collection.find { |plugin| plugin.name == name }
33
39
  end
34
40
 
35
41
  private
@@ -6,9 +6,13 @@ module Rollbar
6
6
  Rollbar.error(exception,
7
7
  :job => self.class.name,
8
8
  :job_id => job_id,
9
- :use_exception_level_filters => true)
9
+ :use_exception_level_filters => true,
10
+ :arguments => arguments)
10
11
  raise exception
11
12
  end
12
13
  end
13
14
  end
14
15
  end
16
+
17
+ # Automatically add to ActionMailer::DeliveryJob
18
+ ActionMailer::DeliveryJob.send(:include, Rollbar::ActiveJob) if defined?(ActionMailer::DeliveryJob)
@@ -1,16 +1,31 @@
1
1
  Rollbar.plugins.define('basic_socket') do
2
+ load_on_demand
3
+
2
4
  dependency { !configuration.disable_core_monkey_patch }
3
5
 
4
6
  # Needed to avoid active_support (< 4.1.0) bug serializing JSONs
5
- dependency { defined?(ActiveSupport::VERSION::STRING) }
7
+ dependency do
8
+ defined?(ActiveSupport::VERSION::STRING) &&
9
+ Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('4.1.0')
10
+ end
6
11
 
7
12
  execute do
8
- require 'socket'
9
-
10
- class BasicSocket
11
- def as_json(*)
12
- to_s
13
+ class BasicSocket # :nodoc:
14
+ def new_as_json(_options = nil)
15
+ {
16
+ :value => inspect
17
+ }
13
18
  end
19
+ # alias_method is recommended over alias when aliasing at runtime.
20
+ # https://github.com/rubocop-hq/ruby-style-guide#alias-method
21
+ alias_method :original_as_json, :as_json # rubocop:disable Style/Alias
22
+ alias_method :as_json, :new_as_json # rubocop:disable Style/Alias
23
+ end
24
+ end
25
+
26
+ revert do
27
+ class BasicSocket # :nodoc:
28
+ alias_method :as_json, :original_as_json # rubocop:disable Style/Alias
14
29
  end
15
30
  end
16
31
  end
@@ -10,7 +10,7 @@ module Rollbar
10
10
  def to_hash
11
11
  job_data = extract_job_data
12
12
 
13
- handler_parent = job_data['job'] ? job_data['job'] : job_data
13
+ handler_parent = job_data['job'] || job_data
14
14
  handler_parent['handler'] = handler_data
15
15
 
16
16
  job_data
@@ -32,7 +32,7 @@ module Rollbar
32
32
  return payload_object unless payload_object.respond_to?(:object)
33
33
 
34
34
  object_data(payload_object.object)
35
- rescue
35
+ rescue StandardError
36
36
  {}
37
37
  end
38
38
 
@@ -42,7 +42,7 @@ module Rollbar
42
42
  :args => job.payload_object.args,
43
43
  :object => object.is_a?(Class) ? object.name : object.to_s
44
44
  }
45
- rescue
45
+ rescue StandardError
46
46
  {}
47
47
  end
48
48
  end
@@ -9,10 +9,10 @@ module Rollbar
9
9
 
10
10
  class RollbarPlugin < ::Delayed::Plugin
11
11
  callbacks do |lifecycle|
12
- lifecycle.around(:invoke_job, &Delayed::invoke_job_callback)
12
+ lifecycle.around(:invoke_job, &Delayed.invoke_job_callback)
13
13
  lifecycle.after(:failure) do |_, job, _, _|
14
14
  data = Rollbar::Delayed.build_job_data(job)
15
- ::Rollbar.scope(:request => data).error(job.last_error, :use_exception_level_filters => true) if job.last_error
15
+ ::Rollbar.scope(:request => data).error("Job has failed and won't be retried anymore: " + job.last_error, :use_exception_level_filters => true) if job.last_error
16
16
  end
17
17
  end
18
18
  end
@@ -37,7 +37,7 @@ module Rollbar
37
37
  proc do |job, *args, &block|
38
38
  begin
39
39
  block.call(job, *args)
40
- rescue => e
40
+ rescue StandardError => e
41
41
  report(e, job)
42
42
 
43
43
  raise e
@@ -10,10 +10,18 @@ Rollbar.plugins.define('goalie') do
10
10
 
11
11
  begin
12
12
  controller = env['action_controller.instance']
13
- request_data = controller.rollbar_request_data rescue nil
14
- person_data = controller.rollbar_person_data rescue nil
13
+ request_data = begin
14
+ controller.rollbar_request_data
15
+ rescue StandardError
16
+ nil
17
+ end
18
+ person_data = begin
19
+ controller.rollbar_person_data
20
+ rescue StandardError
21
+ nil
22
+ end
15
23
  exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception, :use_exception_level_filters => true)
16
- rescue => e
24
+ rescue StandardError => e
17
25
  Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
18
26
  end
19
27
 
@@ -1,4 +1,5 @@
1
1
  require 'rollbar/request_data_extractor'
2
+ require 'rollbar/util'
2
3
 
3
4
  module Rollbar
4
5
  module Rails
@@ -6,13 +7,25 @@ module Rollbar
6
7
  include RequestDataExtractor
7
8
 
8
9
  def rollbar_person_data
9
- user = send(Rollbar.configuration.person_method)
10
+ (user = send(Rollbar.configuration.person_method)) unless Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)
10
11
  # include id, username, email if non-empty
11
12
  if user
12
13
  {
13
- :id => (user.send(Rollbar.configuration.person_id_method) rescue nil),
14
- :username => (user.send(Rollbar.configuration.person_username_method) rescue nil),
15
- :email => (user.send(Rollbar.configuration.person_email_method) rescue nil)
14
+ :id => (begin
15
+ user.send(Rollbar.configuration.person_id_method)
16
+ rescue StandardError
17
+ nil
18
+ end),
19
+ :username => (begin
20
+ user.send(Rollbar.configuration.person_username_method)
21
+ rescue StandardError
22
+ nil
23
+ end),
24
+ :email => (begin
25
+ user.send(Rollbar.configuration.person_email_method)
26
+ rescue StandardError
27
+ nil
28
+ end)
16
29
  }
17
30
  else
18
31
  {}
@@ -1,5 +1,3 @@
1
- require 'rollbar'
2
-
3
1
  module Rollbar
4
2
  module RailtieMixin
5
3
  extend ActiveSupport::Concern
@@ -16,7 +14,13 @@ module Rollbar
16
14
  config.environment ||= ::Rails.env
17
15
  config.root ||= ::Rails.root
18
16
  config.framework = "Rails: #{::Rails::VERSION::STRING}"
19
- config.filepath ||= ::Rails.application.class.parent_name + '.rollbar'
17
+ config.filepath ||= begin
18
+ if ::Rails.application.class.respond_to?(:module_parent_name)
19
+ ::Rails.application.class.module_parent_name + '.rollbar'
20
+ else
21
+ ::Rails.application.class.parent_name + '.rollbar'
22
+ end
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -58,9 +58,9 @@ Rollbar.plugins.define('rake') do
58
58
 
59
59
  def self.rake_version
60
60
  if Object.const_defined?('RAKEVERSION')
61
- return RAKEVERSION
61
+ RAKEVERSION
62
62
  elsif ::Rake.const_defined?('VERSION')
63
- return ::Rake::VERSION
63
+ ::Rake::VERSION
64
64
  end
65
65
  end
66
66
  end
@@ -2,10 +2,10 @@ require 'rollbar/scrubbers/params'
2
2
 
3
3
  module Rollbar
4
4
  class Sidekiq
5
- PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class]
5
+ PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class].freeze
6
6
 
7
7
  class ClearScope
8
- def call(worker, msg, queue)
8
+ def call(_worker, _msg, _queue)
9
9
  Rollbar.reset_notifier!
10
10
 
11
11
  yield
@@ -38,12 +38,16 @@ module Rollbar
38
38
  Rollbar::Scrubbers::Params.call(options)
39
39
  end
40
40
 
41
- def self.skip_report?(job_hash, e)
42
- !job_hash.nil? && (job_hash['retry'] && job_hash['retry_count'] &&
43
- job_hash['retry_count'] < ::Rollbar.configuration.sidekiq_threshold)
41
+ def self.skip_report?(job_hash, _e)
42
+ return false if job_hash.nil?
43
+
44
+ # when rollbar middleware catches, sidekiq's retry_job processor hasn't set
45
+ # the retry_count for the current job yet, so adding 1 gives the actual retry count
46
+ actual_retry_count = job_hash.fetch('retry_count', -1) + 1
47
+ job_hash['retry'] && actual_retry_count < ::Rollbar.configuration.sidekiq_threshold
44
48
  end
45
49
 
46
- def call(worker, msg, queue)
50
+ def call(_worker, msg, _queue)
47
51
  Rollbar.reset_notifier!
48
52
 
49
53
  yield
@@ -1,93 +1,10 @@
1
- require 'rollbar'
2
- begin
3
- require 'rack/mock'
4
- rescue LoadError
5
- end
6
- require 'logger'
7
1
 
8
2
  namespace :rollbar do
9
3
  desc 'Verify your gem installation by sending a test exception to Rollbar'
10
4
  task :test => [:environment] do
11
- if defined?(Rails)
12
- Rails.logger = if defined?(ActiveSupport::TaggedLogging)
13
- ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
14
- else
15
- Logger.new(STDOUT)
16
- end
17
-
18
- Rails.logger.level = Logger::DEBUG
19
- Rollbar.preconfigure do |config|
20
- config.logger = Rails.logger
21
- end
22
- end
23
-
24
- class RollbarTestingException < RuntimeError; end
25
-
26
- unless Rollbar.configuration.access_token
27
- puts 'Rollbar needs an access token configured. Check the README for instructions.'
28
-
29
- exit
30
- end
31
-
32
- puts 'Testing manual report...'
33
- Rollbar.error('Test error from rollbar:test')
34
-
35
- # Module to inject into the Rails controllers or
36
- # rack apps
37
- module RollbarTest
38
- def test_rollbar
39
- puts 'Raising RollbarTestingException to simulate app failure.'
40
-
41
- raise RollbarTestingException.new, 'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
42
- end
43
- end
44
-
45
- if defined?(Rack::MockRequest)
46
- if defined?(Rails)
47
- puts 'Setting up the controller.'
48
-
49
- class RollbarTestController < ActionController::Base
50
- include RollbarTest
51
-
52
- def verify
53
- test_rollbar
54
- end
55
-
56
- def logger
57
- nil
58
- end
59
- end
60
-
61
- Rails.application.routes_reloader.execute_if_updated
62
- Rails.application.routes.draw do
63
- get 'verify' => 'rollbar_test#verify', :as => 'verify'
64
- end
65
-
66
- # from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
67
- if defined? Authlogic
68
- Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
69
- end
70
-
71
- protocol = (defined? Rails.application.config.force_ssl && Rails.application.config.force_ssl) ? 'https' : 'http'
72
- app = Rails.application
73
- else
74
- protocol = 'http'
75
- app = Class.new do
76
- include RollbarTest
77
-
78
- def self.call(_env)
79
- new.test_rollbar
80
- end
81
- end
82
- end
83
-
84
- puts 'Processing...'
85
- env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify")
86
- status, = app.call(env)
5
+ rollbar_dir = Gem.loaded_specs['rollbar'].full_gem_path
6
+ require "#{rollbar_dir}/lib/rollbar/rollbar_test"
87
7
 
88
- unless status.to_i == 500
89
- 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.'
90
- end
91
- end
8
+ RollbarTest.run
92
9
  end
93
10
  end