rollbar 3.2.0 → 3.3.0

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +81 -34
  3. data/Gemfile +8 -8
  4. data/gemfiles/rails30.gemfile +10 -12
  5. data/gemfiles/rails31.gemfile +10 -12
  6. data/gemfiles/rails32.gemfile +3 -5
  7. data/gemfiles/rails40.gemfile +2 -4
  8. data/gemfiles/rails41.gemfile +2 -5
  9. data/gemfiles/rails42.gemfile +4 -9
  10. data/gemfiles/rails50.gemfile +7 -9
  11. data/gemfiles/rails51.gemfile +6 -8
  12. data/gemfiles/rails52.gemfile +5 -5
  13. data/gemfiles/rails60.gemfile +3 -4
  14. data/gemfiles/rails61.gemfile +3 -3
  15. data/lib/generators/rollbar/rollbar_generator.rb +18 -14
  16. data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
  17. data/lib/rails/rollbar_runner.rb +12 -5
  18. data/lib/rollbar/capistrano.rb +16 -8
  19. data/lib/rollbar/capistrano3.rb +8 -2
  20. data/lib/rollbar/capistrano_tasks.rb +16 -7
  21. data/lib/rollbar/configuration.rb +113 -91
  22. data/lib/rollbar/delay/shoryuken.rb +4 -3
  23. data/lib/rollbar/delay/sidekiq.rb +3 -1
  24. data/lib/rollbar/delay/sucker_punch.rb +1 -2
  25. data/lib/rollbar/delay/thread.rb +3 -2
  26. data/lib/rollbar/deploy.rb +6 -7
  27. data/lib/rollbar/encoding/encoder.rb +7 -3
  28. data/lib/rollbar/exception_reporter.rb +17 -8
  29. data/lib/rollbar/item/backtrace.rb +10 -8
  30. data/lib/rollbar/item/frame.rb +6 -5
  31. data/lib/rollbar/item/locals.rb +3 -1
  32. data/lib/rollbar/item.rb +47 -38
  33. data/lib/rollbar/json.rb +1 -1
  34. data/lib/rollbar/lazy_store.rb +1 -3
  35. data/lib/rollbar/logger.rb +2 -0
  36. data/lib/rollbar/logger_proxy.rb +3 -1
  37. data/lib/rollbar/middleware/js.rb +32 -20
  38. data/lib/rollbar/middleware/rack/builder.rb +3 -3
  39. data/lib/rollbar/middleware/rack/test_session.rb +3 -3
  40. data/lib/rollbar/middleware/rack.rb +4 -4
  41. data/lib/rollbar/middleware/rails/rollbar.rb +9 -6
  42. data/lib/rollbar/middleware/rails/show_exceptions.rb +8 -4
  43. data/lib/rollbar/notifier/trace_with_bindings.rb +4 -2
  44. data/lib/rollbar/notifier.rb +179 -133
  45. data/lib/rollbar/plugin.rb +8 -8
  46. data/lib/rollbar/plugins/active_job.rb +11 -2
  47. data/lib/rollbar/plugins/delayed_job/plugin.rb +10 -3
  48. data/lib/rollbar/plugins/goalie.rb +27 -16
  49. data/lib/rollbar/plugins/rails/controller_methods.rb +18 -14
  50. data/lib/rollbar/plugins/rails/railtie30.rb +2 -1
  51. data/lib/rollbar/plugins/rails/railtie32.rb +2 -1
  52. data/lib/rollbar/plugins/rails/railtie_mixin.rb +2 -2
  53. data/lib/rollbar/plugins/rails.rb +5 -2
  54. data/lib/rollbar/plugins/rake.rb +2 -1
  55. data/lib/rollbar/plugins/sidekiq/plugin.rb +5 -5
  56. data/lib/rollbar/plugins/thread.rb +1 -1
  57. data/lib/rollbar/plugins/validations.rb +3 -1
  58. data/lib/rollbar/rake_tasks.rb +0 -1
  59. data/lib/rollbar/request_data_extractor.rb +38 -17
  60. data/lib/rollbar/rollbar_test.rb +3 -1
  61. data/lib/rollbar/scrubbers/params.rb +13 -7
  62. data/lib/rollbar/scrubbers/url.rb +37 -17
  63. data/lib/rollbar/scrubbers.rb +1 -1
  64. data/lib/rollbar/truncation/remove_any_key_strategy.rb +4 -1
  65. data/lib/rollbar/truncation/remove_extra_strategy.rb +3 -1
  66. data/lib/rollbar/util/hash.rb +14 -7
  67. data/lib/rollbar/util/ip_anonymizer.rb +1 -1
  68. data/lib/rollbar/util.rb +19 -13
  69. data/lib/rollbar/version.rb +1 -1
  70. data/lib/rollbar.rb +12 -7
  71. data/lib/tasks/benchmark.rake +2 -1
  72. data/rollbar.gemspec +3 -1
  73. metadata +3 -3
@@ -5,7 +5,8 @@ require 'generators/rollbar/rollbar_generator'
5
5
  module Rollbar
6
6
  module Generators
7
7
  class RollbarGenerator < ::Rails::Generators::Base
8
- argument :access_token, :type => :string, :banner => 'access_token', :default => :use_env_sentinel
8
+ argument :access_token, :type => :string, :banner => 'access_token',
9
+ :default => :use_env_sentinel
9
10
 
10
11
  source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
11
12
 
@@ -13,32 +14,35 @@ module Rollbar
13
14
  say 'creating initializer...'
14
15
  if access_token_configured?
15
16
  say "It looks like you've already configured Rollbar."
16
- say 'To re-create the config file, remove it first: config/initializers/rollbar.rb'
17
+ say 'To re-create the config file, remove it first: ' \
18
+ 'config/initializers/rollbar.rb'
17
19
  exit
18
20
  end
19
21
 
20
22
  begin
21
23
  require 'ey_config'
22
24
  rescue LoadError
25
+ # Skip loading
23
26
  end
24
27
 
25
28
  if defined? EY::Config
26
29
  say 'Access token will be read from Engine Yard configuration'
30
+ elsif access_token === :use_env_sentinel
31
+ say 'Generator run without an access token; assuming you want to ' \
32
+ 'configure using an environment variable.'
33
+ say "You'll need to add an environment variable ROLLBAR_ACCESS_TOKEN " \
34
+ 'with your access token:'
35
+ say "\n$ export ROLLBAR_ACCESS_TOKEN=yourtokenhere"
36
+ say "\nIf that's not what you wanted to do:"
37
+ say "\n$ rm config/initializers/rollbar.rb"
38
+ say '$ rails generate rollbar yourtokenhere'
39
+ say "\n"
27
40
  else
28
- if access_token === :use_env_sentinel
29
- say 'Generator run without an access token; assuming you want to configure using an environment variable.'
30
- say "You'll need to add an environment variable ROLLBAR_ACCESS_TOKEN with your access token:"
31
- say "\n$ export ROLLBAR_ACCESS_TOKEN=yourtokenhere"
32
- say "\nIf that's not what you wanted to do:"
33
- say "\n$ rm config/initializers/rollbar.rb"
34
- say '$ rails generate rollbar yourtokenhere'
35
- say "\n"
36
- else
37
- say 'access token: ' << access_token
38
- end
41
+ say 'access token: ' << access_token
39
42
  end
40
43
 
41
- template 'initializer.rb', 'config/initializers/rollbar.rb', :assigns => { :access_token => access_token_expr }
44
+ template 'initializer.erb', 'config/initializers/rollbar.rb',
45
+ :assigns => { :access_token => access_token_expr }
42
46
 
43
47
  # TODO: run rake test task
44
48
  end
@@ -4,7 +4,10 @@ require 'rollbar'
4
4
  # Rails.root is not present here.
5
5
  # RSpec needs ENV['DUMMYAPP_PATH'] in order to have a valid path.
6
6
  # Dir.pwd is used in normal operation.
7
- APP_PATH = File.expand_path('config/application', (ENV['DUMMYAPP_PATH'] || Dir.pwd))
7
+ APP_PATH = File.expand_path(
8
+ 'config/application',
9
+ (ENV['DUMMYAPP_PATH'] || Dir.pwd)
10
+ )
8
11
 
9
12
  module Rails
10
13
  class RollbarRunner
@@ -49,9 +52,9 @@ module Rails
49
52
  def legacy_runner
50
53
  string_to_eval = File.read(runner_path)
51
54
 
52
- ::Rails.module_eval(<<-EOL, __FILE__, __LINE__ + 2)
55
+ ::Rails.module_eval(<<-FILE, __FILE__, __LINE__ + 1)
53
56
  #{string_to_eval}
54
- EOL
57
+ FILE
55
58
  end
56
59
 
57
60
  def rails5_runner
@@ -68,11 +71,15 @@ module Rails
68
71
  end
69
72
 
70
73
  def runner_path
71
- railties_gem_dir + '/lib/rails/commands/runner.rb'
74
+ "#{railties_gem_dir}/lib/rails/commands/runner.rb"
72
75
  end
73
76
 
74
77
  def railties_gem
75
- resolver_class = Gem::Specification.respond_to?(:find_by_name) ? GemResolver : LegacyGemResolver
78
+ resolver_class = if Gem::Specification.respond_to?(:find_by_name)
79
+ GemResolver
80
+ else
81
+ LegacyGemResolver
82
+ end
76
83
  gem = resolver_class.new.railties_gem
77
84
 
78
85
  abort 'railties gem not found' unless gem
@@ -34,7 +34,11 @@ module Rollbar
34
34
  _cset(:rollbar_role) { :app }
35
35
  _cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
36
36
  _cset(:rollbar_env) { fetch(:rails_env, 'production') }
37
- _cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
37
+ _cset(:rollbar_token) do
38
+ abort(
39
+ "Please specify the Rollbar access token, set :rollbar_token, 'your token'"
40
+ )
41
+ end
38
42
  _cset(:rollbar_revision) { real_revision }
39
43
  _cset(:rollbar_comment) { nil }
40
44
  end
@@ -51,7 +55,9 @@ module Rollbar
51
55
  :task => :deploy_started,
52
56
  :configuration => configuration
53
57
  ) do
54
- ::Rollbar::CapistranoTasks.deploy_started(configuration, configuration.logger, configuration.dry_run)
58
+ ::Rollbar::CapistranoTasks.deploy_started(
59
+ configuration, configuration.logger, configuration.dry_run
60
+ )
55
61
  end
56
62
  end
57
63
 
@@ -61,17 +67,17 @@ module Rollbar
61
67
  :task => :deploy_succeeded,
62
68
  :configuration => configuration
63
69
  ) do
64
- ::Rollbar::CapistranoTasks.deploy_succeeded(configuration, configuration.logger, configuration.dry_run)
70
+ ::Rollbar::CapistranoTasks.deploy_succeeded(
71
+ configuration, configuration.logger, configuration.dry_run
72
+ )
65
73
  end
66
74
  end
67
75
 
68
- def load_task(configuration:, desc:, task:)
76
+ def load_task(configuration:, desc:, task:, &block)
69
77
  configuration.load do
70
78
  namespace :rollbar do
71
79
  desc(desc)
72
- task(task) do
73
- yield
74
- end
80
+ task(task, &block)
75
81
  end
76
82
  end
77
83
  end
@@ -79,4 +85,6 @@ module Rollbar
79
85
  end
80
86
  end
81
87
 
82
- Rollbar::Capistrano2.load_into(Capistrano::Configuration.instance) if Capistrano::Configuration.instance
88
+ if Capistrano::Configuration.instance
89
+ Rollbar::Capistrano2.load_into(Capistrano::Configuration.instance)
90
+ end
@@ -8,7 +8,10 @@ require 'rollbar/capistrano_tasks'
8
8
 
9
9
  namespace :rollbar do
10
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 })
11
+ set :dry_run, (proc {
12
+ ::Capistrano::Configuration.env.fetch(:sshkit_backend) ==
13
+ ::SSHKit::Backend::Printer
14
+ })
12
15
 
13
16
  desc 'Send deployment started notification to Rollbar.'
14
17
  task :deploy_started do
@@ -49,7 +52,10 @@ namespace :load do
49
52
  task :defaults do
50
53
  set :rollbar_user, (proc { fetch :local_user, ENV['USER'] || ENV['USERNAME'] })
51
54
  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'" })
55
+ set :rollbar_token, (proc {
56
+ abort 'Please specify the Rollbar access token, ' \
57
+ "set :rollbar_token, 'your token'"
58
+ })
53
59
  set :rollbar_role, (proc { :app })
54
60
  set :rollbar_revision, (proc { fetch :current_revision })
55
61
  end
@@ -13,7 +13,9 @@ module Rollbar
13
13
  capistrano.set(:rollbar_deploy_id, 123) if dry_run
14
14
 
15
15
  skip_in_dry_run(logger, dry_run) do
16
- if result[:success] && (deploy_id = result[:data] && result[:data][:deploy_id])
16
+ if result[:success] &&
17
+ (deploy_id = result[:data] &&
18
+ result[:data][:deploy_id])
17
19
  capistrano.set :rollbar_deploy_id, deploy_id
18
20
  else
19
21
  message = format_message('Unable to report deploy to Rollbar',
@@ -25,13 +27,17 @@ module Rollbar
25
27
  end
26
28
 
27
29
  def deploy_succeeded(capistrano, logger, dry_run)
28
- deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `succeeded` in Rollbar') do
30
+ deploy_update(
31
+ capistrano, logger, dry_run,
32
+ :desc => 'Setting deployment status to `succeeded` in Rollbar'
33
+ ) do
29
34
  report_deploy_succeeded(capistrano, dry_run)
30
35
  end
31
36
  end
32
37
 
33
38
  def deploy_failed(capistrano, logger, dry_run)
34
- deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `failed` in Rollbar') do
39
+ deploy_update(capistrano, logger, dry_run,
40
+ :desc => 'Setting deployment status to `failed` in Rollbar') do
35
41
  report_deploy_failed(capistrano, dry_run)
36
42
  end
37
43
  end
@@ -42,7 +48,6 @@ module Rollbar
42
48
  capistrano_300_warning(logger)
43
49
  logger.info opts[:desc] if opts[:desc]
44
50
  yield
45
-
46
51
  rescue StandardError => e
47
52
  log_error logger, "Error reporting to Rollbar: #{e.inspect}"
48
53
  end
@@ -68,7 +73,9 @@ module Rollbar
68
73
  end
69
74
 
70
75
  def capistrano_300_warning(logger)
71
- return unless ::Capistrano.const_defined?('VERSION') && ::Capistrano::VERSION =~ /^3\.0/
76
+ unless ::Capistrano.const_defined?('VERSION') && ::Capistrano::VERSION =~ /^3\.0/
77
+ return
78
+ end
72
79
 
73
80
  logger.warn('You need to upgrade capistrano to >= 3.1 version in order'\
74
81
  'to correctly report deploys to Rollbar. (On 3.0, the reported revision'\
@@ -121,7 +128,8 @@ module Rollbar
121
128
  if capistrano.fetch(:rollbar_deploy_id)
122
129
  yield
123
130
  else
124
- log_error logger, 'Failed to update the deploy in Rollbar. No deploy id available.'
131
+ log_error logger,
132
+ 'Failed to update the deploy in Rollbar. No deploy id available.'
125
133
  end
126
134
  end
127
135
 
@@ -134,7 +142,8 @@ module Rollbar
134
142
  end
135
143
 
136
144
  def debug_request_response(logger, result)
137
- # NOTE: in Capistrano debug messages go to log/capistrano.log but not to stdout even if log_level == :debug
145
+ # NOTE: in Capistrano debug messages go to log/capistrano.log but not to
146
+ # stdout even if log_level == :debug
138
147
  logger.debug result[:request_info]
139
148
  logger.debug result[:response_info] if result[:response_info]
140
149
  end
@@ -4,82 +4,82 @@ module Rollbar
4
4
  class Configuration
5
5
  SEND_EXTRA_FRAME_DATA_OPTIONS = [:none, :app, :all].freeze
6
6
 
7
- attr_accessor :access_token
8
- attr_accessor :async_handler
9
- attr_accessor :branch
10
- attr_reader :before_process
11
- attr_accessor :capture_uncaught
12
- attr_accessor :code_version
13
- attr_accessor :custom_data_method
14
- attr_accessor :delayed_job_enabled
15
- attr_accessor :default_logger
16
- attr_reader :logger_level
17
- attr_accessor :disable_monkey_patch
18
- attr_accessor :disable_rack_monkey_patch
19
- attr_accessor :disable_core_monkey_patch
20
- attr_accessor :enable_error_context
21
- attr_accessor :dj_threshold
22
- attr_accessor :async_skip_report_handler
23
- attr_accessor :enabled
24
- attr_accessor :endpoint
25
- attr_accessor :environment
26
- attr_accessor :exception_level_filters
27
- attr_accessor :failover_handlers
28
- attr_accessor :framework
29
- attr_accessor :ignored_person_ids
30
- attr_accessor :host
31
- attr_accessor :locals
32
- attr_writer :logger
33
- attr_accessor :payload_options
34
- attr_accessor :person_method
35
- attr_accessor :person_id_method
36
- attr_accessor :person_username_method
37
- attr_accessor :person_email_method
38
- attr_accessor :populate_empty_backtraces
39
- attr_accessor :report_dj_data
40
- attr_accessor :open_timeout
41
- attr_accessor :request_timeout
42
- attr_accessor :net_retries
43
- attr_accessor :root
44
- attr_accessor :js_options
45
- attr_accessor :js_enabled
46
- attr_accessor :safely
47
- attr_accessor :scrub_fields
48
- attr_accessor :scrub_user
49
- attr_accessor :scrub_password
50
- attr_accessor :scrub_whitelist
51
- attr_accessor :collect_user_ip
52
- attr_accessor :anonymize_user_ip
53
- attr_accessor :user_ip_obfuscator_secret
54
- attr_accessor :randomize_scrub_length
55
- attr_accessor :uncaught_exception_level
56
- attr_accessor :scrub_headers
57
- attr_accessor :sidekiq_threshold
58
- attr_accessor :sidekiq_use_scoped_block
59
- attr_reader :transform
60
- attr_accessor :verify_ssl_peer
61
- attr_accessor :use_async
62
- attr_accessor :async_json_payload
63
- attr_reader :use_eventmachine
64
- attr_accessor :web_base
65
- attr_reader :send_extra_frame_data
66
- attr_accessor :use_exception_level_filters_default
67
- attr_accessor :proxy
68
- attr_accessor :raise_on_error
69
- attr_accessor :transmit
70
- attr_accessor :log_payload
71
- attr_accessor :backtrace_cleaner
72
-
73
- attr_accessor :write_to_file
74
- attr_accessor :filepath
75
- attr_accessor :files_with_pid_name_enabled
76
- attr_accessor :files_processed_enabled
77
- attr_accessor :files_processed_duration # seconds
78
- attr_accessor :files_processed_size # bytes
79
- attr_accessor :use_payload_access_token
80
-
81
- attr_reader :project_gem_paths
82
- attr_accessor :configured_options
7
+ attr_accessor :access_token,
8
+ :anonymize_user_ip,
9
+ :async_handler,
10
+ :async_json_payload,
11
+ :async_skip_report_handler,
12
+ :backtrace_cleaner,
13
+ :branch,
14
+ :capture_uncaught,
15
+ :code_version,
16
+ :collect_user_ip,
17
+ :configured_options,
18
+ :custom_data_method,
19
+ :default_logger,
20
+ :delayed_job_enabled,
21
+ :disable_core_monkey_patch,
22
+ :disable_monkey_patch,
23
+ :disable_rack_monkey_patch,
24
+ :dj_threshold,
25
+ :enable_error_context,
26
+ :enabled,
27
+ :endpoint,
28
+ :environment,
29
+ :exception_level_filters,
30
+ :failover_handlers,
31
+ :filepath,
32
+ :files_processed_duration,
33
+ :files_processed_enabled,
34
+ :files_processed_size,
35
+ :files_with_pid_name_enabled,
36
+ :framework,
37
+ :ignore_internal_errors,
38
+ :ignored_person_ids,
39
+ :js_enabled,
40
+ :js_options,
41
+ :host,
42
+ :locals,
43
+ :log_payload,
44
+ :net_retries,
45
+ :open_timeout,
46
+ :payload_options,
47
+ :person_email_method,
48
+ :person_id_method,
49
+ :person_method,
50
+ :person_username_method,
51
+ :populate_empty_backtraces,
52
+ :proxy,
53
+ :raise_on_error,
54
+ :randomize_scrub_length,
55
+ :report_dj_data,
56
+ :request_timeout,
57
+ :root,
58
+ :safely,
59
+ :scrub_fields,
60
+ :scrub_password,
61
+ :scrub_user,
62
+ :scrub_whitelist,
63
+ :transmit,
64
+ :uncaught_exception_level,
65
+ :user_ip_obfuscator_secret,
66
+ :user_ip_rack_env_key,
67
+ :scrub_headers,
68
+ :sidekiq_threshold,
69
+ :sidekiq_use_scoped_block,
70
+ :use_async,
71
+ :use_exception_level_filters_default,
72
+ :use_payload_access_token,
73
+ :verify_ssl_peer,
74
+ :web_base,
75
+ :write_to_file
76
+ attr_reader :before_process,
77
+ :logger_level,
78
+ :project_gem_paths,
79
+ :send_extra_frame_data,
80
+ :transform,
81
+ :use_eventmachine
82
+ attr_writer :logger # seconds # bytes
83
83
 
84
84
  alias safely? safely
85
85
 
@@ -94,7 +94,7 @@ module Rollbar
94
94
  @capture_uncaught = nil
95
95
  @code_version = nil
96
96
  @custom_data_method = nil
97
- @default_logger = lambda { ::Logger.new(STDERR) }
97
+ @default_logger = lambda { ::Logger.new($stderr) }
98
98
  @logger_level = :info
99
99
  @delayed_job_enabled = true
100
100
  @disable_monkey_patch = false
@@ -113,6 +113,11 @@ module Rollbar
113
113
  }
114
114
  @failover_handlers = []
115
115
  @framework = 'Plain'
116
+ @ignore_internal_errors = [
117
+ 'Net::ReadTimeout',
118
+ 'Net::OpenTimeout',
119
+ 'SocketError'
120
+ ]
116
121
  @ignored_person_ids = []
117
122
  @host = nil
118
123
  @payload_options = {}
@@ -158,6 +163,7 @@ module Rollbar
158
163
  @collect_user_ip = true
159
164
  @anonymize_user_ip = false
160
165
  @user_ip_obfuscator_secret = nil
166
+ @user_ip_rack_env_key = nil
161
167
  @backtrace_cleaner = nil
162
168
  @hooks = {
163
169
  :on_error_response => nil, # params: response
@@ -214,7 +220,8 @@ module Rollbar
214
220
  def use_active_job(options = {})
215
221
  require 'rollbar/delay/active_job'
216
222
 
217
- Rollbar::Delay::ActiveJob.queue_as(options[:queue] || Rollbar::Delay::ActiveJob.default_queue_name)
223
+ Rollbar::Delay::ActiveJob.queue_as(options[:queue] ||
224
+ Rollbar::Delay::ActiveJob.default_queue_name)
218
225
 
219
226
  @use_async = true
220
227
  @async_handler = Rollbar::Delay::ActiveJob
@@ -254,8 +261,13 @@ module Rollbar
254
261
  end
255
262
 
256
263
  def use_sidekiq=(value)
257
- deprecation_message = '#use_sidekiq=(value) has been deprecated in favor of #use_sidekiq(options = {}). Please update your rollbar configuration.'
258
- defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
264
+ deprecation_message = '#use_sidekiq=(value) has been deprecated in favor ' \
265
+ 'of #use_sidekiq(options = {}). Please update your rollbar configuration.'
266
+ if defined?(ActiveSupport)
267
+ ActiveSupport::Deprecation.warn(deprecation_message)
268
+ else
269
+ puts(deprecation_message)
270
+ end
259
271
 
260
272
  value.is_a?(Hash) ? use_sidekiq(value) : use_sidekiq
261
273
  end
@@ -274,8 +286,13 @@ module Rollbar
274
286
  end
275
287
 
276
288
  def use_sucker_punch=(_value)
277
- deprecation_message = '#use_sucker_punch=(value) has been deprecated in favor of #use_sucker_punch. Please update your rollbar configuration.'
278
- defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
289
+ deprecation_message = '#use_sucker_punch=(value) has been deprecated in ' \
290
+ 'favor of #use_sucker_punch. Please update your rollbar configuration.'
291
+ if defined?(ActiveSupport)
292
+ ActiveSupport::Deprecation.warn(deprecation_message)
293
+ else
294
+ puts(deprecation_message)
295
+ end
279
296
 
280
297
  use_sucker_punch
281
298
  end
@@ -306,7 +323,9 @@ module Rollbar
306
323
 
307
324
  def send_extra_frame_data=(value)
308
325
  unless SEND_EXTRA_FRAME_DATA_OPTIONS.include?(value)
309
- logger.warning("Wrong 'send_extra_frame_data' value, :none, :app or :full is expected")
326
+ logger.warning(
327
+ "Wrong 'send_extra_frame_data' value, :none, :app or :full is expected"
328
+ )
310
329
 
311
330
  return
312
331
  end
@@ -332,14 +351,14 @@ module Rollbar
332
351
  end
333
352
 
334
353
  def hook(symbol, &block)
335
- if @hooks.key?(symbol)
336
- if block_given?
337
- @hooks[symbol] = block
338
- else
339
- @hooks[symbol]
340
- end
354
+ unless @hooks.key?(symbol)
355
+ raise StandardError, "Hook :#{symbol} is not supported by Rollbar SDK."
356
+ end
357
+
358
+ if block_given?
359
+ @hooks[symbol] = block
341
360
  else
342
- raise StandardError, 'Hook :' + symbol.to_s + ' is not supported by Rollbar SDK.'
361
+ @hooks[symbol]
343
362
  end
344
363
  end
345
364
 
@@ -360,7 +379,10 @@ module Rollbar
360
379
  return super unless configuration.respond_to?(method)
361
380
 
362
381
  method_string = method.to_s
363
- configured[method_string.chomp('=').to_sym] = args.first if method_string.end_with?('=')
382
+ if method_string.end_with?('=')
383
+ configured[method_string.chomp('=').to_sym] =
384
+ args.first
385
+ end
364
386
 
365
387
  configuration.send(method, *args, &block)
366
388
  end
@@ -2,9 +2,10 @@ require 'shoryuken'
2
2
 
3
3
  module Rollbar
4
4
  module Delay
5
- # Following class allows to send rollbars using Sho-ryu-ken as a background jobs processor.
6
- # see the queue_name method which states that your queues needs to be names as "rollbar_ENVIRONMENT".
7
- # retry intervals will be used to retry sending the same message again if failed before.
5
+ # Following class allows to send rollbars using Sho-ryu-ken as a background
6
+ # jobs processor. See the queue_name method which states that your queues
7
+ # needs to be names as "rollbar_ENVIRONMENT". Retry intervals will be used
8
+ # to retry sending the same message again if failed before.
8
9
  class Shoryuken
9
10
  include ::Shoryuken::Worker
10
11
 
@@ -10,7 +10,9 @@ module Rollbar
10
10
  end
11
11
 
12
12
  def call(payload)
13
- raise StandardError, 'Unable to push the job to Sidekiq' if ::Sidekiq::Client.push(@options.merge('args' => [payload])).nil?
13
+ return unless ::Sidekiq::Client.push(@options.merge('args' => [payload])).nil?
14
+
15
+ raise(StandardError, 'Unable to push the job to Sidekiq')
14
16
  end
15
17
 
16
18
  include ::Sidekiq::Worker
@@ -7,8 +7,7 @@ module Rollbar
7
7
  include ::SuckerPunch::Job
8
8
 
9
9
  class << self
10
- attr_accessor :perform_proc
11
- attr_accessor :ready
10
+ attr_accessor :perform_proc, :ready
12
11
  end
13
12
 
14
13
  self.ready = false
@@ -62,11 +62,12 @@ module Rollbar
62
62
  reaper.join
63
63
  end
64
64
  rescue Timeout::Error
65
- raise TimeoutError, "unable to reap all threads within #{EXIT_TIMEOUT} seconds"
65
+ raise TimeoutError,
66
+ "unable to reap all threads within #{EXIT_TIMEOUT} seconds"
66
67
  end
67
68
  end
68
69
  end
69
- end # class << self
70
+ end
70
71
 
71
72
  def priority
72
73
  self.class.options[:priority] || DEFAULT_PRIORITY
@@ -30,9 +30,7 @@ module Rollbar
30
30
  return {} unless access_token && !access_token.empty?
31
31
 
32
32
  uri = ::URI.parse(
33
- ::Rollbar::Deploy::ENDPOINT +
34
- deploy_id.to_s +
35
- '?access_token=' + access_token
33
+ "#{::Rollbar::Deploy::ENDPOINT}#{deploy_id}?access_token=#{access_token}"
36
34
  )
37
35
 
38
36
  request = ::Net::HTTP::Patch.new(uri.request_uri)
@@ -74,17 +72,18 @@ module Rollbar
74
72
 
75
73
  def request_result(uri, request)
76
74
  {
77
- :request_info => uri.inspect + ': ' + request.body,
75
+ :request_info => "#{uri.inspect}: #{request.body}",
78
76
  :request => request
79
77
  }
80
78
  end
81
79
 
82
80
  def response_result(response)
81
+ code = response.code
82
+ message = response.message
83
+ body = response.body.delete("\n")
83
84
  {
84
85
  :response => response,
85
- :response_info => response.code + '; ' +
86
- response.message + '; ' +
87
- response.body.delete("\n")
86
+ :response_info => "#{code}; #{message}; #{body}"
88
87
  }.merge(::JSON.parse(response.body, :symbolize_names => true))
89
88
  end
90
89
  end
@@ -1,8 +1,10 @@
1
1
  module Rollbar
2
2
  module Encoding
3
3
  class Encoder
4
- ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT, ::Encoding::US_ASCII].freeze
5
- ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT, ::Encoding::ISO_8859_1].freeze
4
+ ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT,
5
+ ::Encoding::US_ASCII].freeze
6
+ ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT,
7
+ ::Encoding::ISO_8859_1].freeze
6
8
  UTF8 = 'UTF-8'.freeze
7
9
  BINARY = 'binary'.freeze
8
10
 
@@ -40,7 +42,9 @@ module Rollbar
40
42
  def force_encoding(value)
41
43
  return value if value.frozen?
42
44
 
43
- value.force_encoding(detect_encoding(value)) if value.encoding == ::Encoding::UTF_8
45
+ if value.encoding == ::Encoding::UTF_8
46
+ value.force_encoding(detect_encoding(value))
47
+ end
44
48
 
45
49
  value
46
50
  end