rollbar 2.23.2 → 2.24.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
  SHA256:
3
- metadata.gz: 9073beef837ad644c6679c6f95599b7eb6e387d089c9f8d88448cbf39960ea22
4
- data.tar.gz: 148751730bba10444641bd319314b7af7ee69a51e2c15cc686a909f797eec379
3
+ metadata.gz: c1848033c2fc853846ba902fbe4dc6095ad17a6e27595a3937484a6036154b76
4
+ data.tar.gz: a42d4a1274624ea5991b66b0df1ce7031d699390c5dcf574b98d8fe03ea5519d
5
5
  SHA512:
6
- metadata.gz: c8b0529b951944385beba61f53f43c3ea4270fe38c94fb85639a55a833d2e67c92ae61e88325ba3e3c4a0b64492aab3c95bc6faa6f458df1e9ad792c1e38e77d
7
- data.tar.gz: 6d12a2415ac6ba94b7e5b00b944a4de7afe5a4fa6e43c9d86618c944d0968e0aeb8d601a34363fd97b89bc4ff5316b7dfa2cff6a54aee1a7f198b5690391da23
6
+ metadata.gz: 5d71b0e452e917b566e48a292368a242404c2d26e91c011f641f1fb7bde2b05ee8bd88a9af6d595bf6581cea17d5d4a996af63104c4ea55a19de564760b4f7f3
7
+ data.tar.gz: b7ec97dfa2625823709eba27b5252706fce661877b9e4338595228c901e5766ab9752a5103a87f929d7af8ae9c687a978f7630d93d0aee5611ab58e5771ccd2c
@@ -69,6 +69,10 @@ Style/FrozenStringLiteralComment:
69
69
  # throughout the project, in order to prepare for a future Ruby 3.x.
70
70
  Enabled: false
71
71
 
72
+ Style/SafeNavigation:
73
+ # Not available in Ruby < 2.3.
74
+ Enabled: false
75
+
72
76
  #
73
77
  # Performance cops are opt in, and `Enabled: true` is always required.
74
78
  # Full list is here: https://github.com/rubocop-hq/rubocop-performance/tree/master/lib/rubocop/cop/performance
@@ -129,6 +129,7 @@ An array of backup handlers if the async handlers fails. Each should respond to
129
129
 
130
130
  For use with `write_to_file`. Indicates location of the rollbar log file being
131
131
  tracked by [rollbar-agent](https://github.com/rollbar/rollbar-agent).
132
+ Enable `files_with_pid_name_enabled` if you want to have different files for each process(only works if extension `rollbar`)
132
133
 
133
134
  ### framework
134
135
 
@@ -39,7 +39,7 @@ module Rails
39
39
  end
40
40
 
41
41
  def eval_runner
42
- if Rails.version >= '5.1.0'
42
+ if Gem::Version.new(Rails.version) >= Gem::Version.new('5.1.0')
43
43
  rails5_runner
44
44
  else
45
45
  legacy_runner
@@ -55,6 +55,8 @@ module Rails
55
55
  end
56
56
 
57
57
  def rails5_runner
58
+ require 'rails/command'
59
+
58
60
  Rails::Command.invoke 'runner', ARGV
59
61
  end
60
62
 
@@ -24,7 +24,6 @@ module Rollbar
24
24
  attr_accessor :environment
25
25
  attr_accessor :exception_level_filters
26
26
  attr_accessor :failover_handlers
27
- attr_accessor :filepath
28
27
  attr_accessor :framework
29
28
  attr_accessor :ignored_person_ids
30
29
  attr_accessor :host
@@ -61,7 +60,6 @@ module Rollbar
61
60
  attr_accessor :async_json_payload
62
61
  attr_reader :use_eventmachine
63
62
  attr_accessor :web_base
64
- attr_accessor :write_to_file
65
63
  attr_reader :send_extra_frame_data
66
64
  attr_accessor :use_exception_level_filters_default
67
65
  attr_accessor :proxy
@@ -70,6 +68,13 @@ module Rollbar
70
68
  attr_accessor :log_payload
71
69
  attr_accessor :backtrace_cleaner
72
70
 
71
+ attr_accessor :write_to_file
72
+ attr_accessor :filepath
73
+ attr_accessor :files_with_pid_name_enabled
74
+ attr_accessor :files_processed_enabled
75
+ attr_accessor :files_processed_duration # seconds
76
+ attr_accessor :files_processed_size # bytes
77
+
73
78
  attr_reader :project_gem_paths
74
79
  attr_accessor :configured_options
75
80
 
@@ -134,7 +139,6 @@ module Rollbar
134
139
  @use_eventmachine = false
135
140
  @verify_ssl_peer = true
136
141
  @web_base = DEFAULT_WEB_BASE
137
- @write_to_file = false
138
142
  @send_extra_frame_data = :none
139
143
  @project_gem_paths = []
140
144
  @use_exception_level_filters_default = false
@@ -150,6 +154,12 @@ module Rollbar
150
154
  :on_report_internal_error => nil # params: exception
151
155
  }
152
156
 
157
+ @write_to_file = false
158
+ @files_with_pid_name_enabled = false
159
+ @files_processed_enabled = false
160
+ @files_processed_duration = 60
161
+ @files_processed_size = 5 * 1000 * 1000
162
+
153
163
  @configured_options = ConfiguredOptions.new(self)
154
164
  end
155
165
 
@@ -19,7 +19,8 @@ module Rollbar
19
19
  attr_accessor :last_report
20
20
  attr_accessor :scope_object
21
21
 
22
- @file_semaphore = Mutex.new
22
+ MUTEX = Mutex.new
23
+ EXTENSION_REGEXP = /.rollbar\z/.freeze
23
24
 
24
25
  def initialize(parent_notifier = nil, payload_options = nil, scope = nil)
25
26
  if parent_notifier
@@ -200,11 +201,11 @@ module Rollbar
200
201
  def process_item(item)
201
202
  if configuration.write_to_file
202
203
  if configuration.use_async
203
- @file_semaphore.synchronize do
204
- write_item(item)
204
+ MUTEX.synchronize do
205
+ do_write_item(item)
205
206
  end
206
207
  else
207
- write_item(item)
208
+ do_write_item(item)
208
209
  end
209
210
  else
210
211
  send_item(item)
@@ -675,27 +676,24 @@ module Rollbar
675
676
  end
676
677
  end
677
678
 
678
- def write_item(item)
679
- if configuration.use_async
680
- @file_semaphore.synchronize do
681
- do_write_item(item)
682
- end
683
- else
684
- do_write_item(item)
685
- end
686
- end
687
-
688
679
  def do_write_item(item)
689
680
  log_info '[Rollbar] Writing item to file'
690
681
 
691
682
  body = item.dump
692
683
  return unless body
693
684
 
685
+ file_name = if configuration.files_with_pid_name_enabled
686
+ configuration.filepath.gsub(EXTENSION_REGEXP, "_#{Process.pid}\\0")
687
+ else
688
+ configuration.filepath
689
+ end
690
+
694
691
  begin
695
- @file ||= File.open(configuration.filepath, 'a')
692
+ @file ||= File.open(file_name, 'a')
696
693
 
697
694
  @file.puts(body)
698
695
  @file.flush
696
+ update_file(@file, file_name)
699
697
 
700
698
  log_info '[Rollbar] Success'
701
699
  rescue IOError => e
@@ -703,6 +701,18 @@ module Rollbar
703
701
  end
704
702
  end
705
703
 
704
+ def update_file(file, file_name)
705
+ return unless configuration.files_processed_enabled
706
+
707
+ time_now = Time.now
708
+ return if configuration.files_processed_duration > time_now - file.birthtime && file.size < configuration.files_processed_size
709
+
710
+ new_file_name = file_name.gsub(EXTENSION_REGEXP, "_processed_#{time_now.to_i}\\0")
711
+ File.rename(file, new_file_name)
712
+ file.close
713
+ @file = File.open(file_name, 'a')
714
+ end
715
+
706
716
  def failsafe_reason(message, exception)
707
717
  body = ''
708
718
 
@@ -12,7 +12,13 @@ module Rollbar
12
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 has failed and won't be retried anymore: " + job.last_error, :use_exception_level_filters => true) if job.last_error
15
+
16
+ # DelayedJob < 4.1 doesn't provide job#error
17
+ if job.class.method_defined? :error
18
+ ::Rollbar.scope(:request => data).error(job.error, :use_exception_level_filters => true) if job.error
19
+ elsif job.last_error
20
+ ::Rollbar.scope(:request => data).error("Job has failed and won't be retried anymore: " + job.last_error, :use_exception_level_filters => true)
21
+ end
16
22
  end
17
23
  end
18
24
  end
@@ -247,7 +247,12 @@ module Rollbar
247
247
  end
248
248
 
249
249
  def sensitive_headers_list
250
- Rollbar.configuration.scrub_headers || []
250
+ return [] unless Rollbar.configuration.scrub_headers && Rollbar.configuration.scrub_headers.is_a?(Array)
251
+
252
+ # Normalize into the expected matching format
253
+ Rollbar.configuration.scrub_headers.map do |header|
254
+ header.split(/[-_]/).map(&:capitalize).join('-').gsub(/^Http-/, '')
255
+ end
251
256
  end
252
257
  end
253
258
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.23.2'.freeze
2
+ VERSION = '2.24.0'.freeze
3
3
  end
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = 'https://rollbar.com'
14
14
  gem.license = 'MIT'
15
15
  gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ gem.files += ['spec/support/rollbar_api.rb'] # useful helper for app spec/tests.
16
17
  gem.name = 'rollbar'
17
18
  gem.require_paths = ['lib']
18
19
  gem.required_ruby_version = '>= 1.9.3'
@@ -0,0 +1,67 @@
1
+ require 'rack/request'
2
+
3
+ class RollbarAPI
4
+ UNAUTHORIZED_ACCESS_TOKEN = 'unauthorized'.freeze
5
+
6
+ def call(env)
7
+ request = Rack::Request.new(env)
8
+ json = JSON.parse(request.body.read)
9
+
10
+ return unauthorized unless authorized?(json, request)
11
+
12
+ return bad_request(json) unless valid_data?(json, request)
13
+
14
+ success(json, request)
15
+ end
16
+
17
+ protected
18
+
19
+ def authorized?(json, _request)
20
+ json['access_token'] != UNAUTHORIZED_ACCESS_TOKEN
21
+ end
22
+
23
+ def response_headers
24
+ {
25
+ 'Content-Type' => 'application/json'
26
+ }
27
+ end
28
+
29
+ def valid_data?(json, _request)
30
+ !!json['access_token']
31
+ end
32
+
33
+ def unauthorized
34
+ [401, response_headers, [unauthorized_body]]
35
+ end
36
+
37
+ def bad_request(_json)
38
+ [400, response_headers, [bad_request_body]]
39
+ end
40
+
41
+ def success(json, request)
42
+ [200, response_headers, [success_body(json, request)]]
43
+ end
44
+
45
+ def unauthorized_body
46
+ result(1, nil, 'invalid access token')
47
+ end
48
+
49
+ def bad_request_body
50
+ result(1, nil, 'bad request')
51
+ end
52
+
53
+ def success_body(json, _request)
54
+ result(0, {
55
+ :id => rand(1_000_000),
56
+ :uuid => json['data']['uuid']
57
+ }, nil)
58
+ end
59
+
60
+ def result(err, body, message)
61
+ {
62
+ :err => err,
63
+ :result => body,
64
+ :message => message
65
+ }.to_json
66
+ end
67
+ end
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.23.2
4
+ version: 2.24.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: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy and powerful exception tracking for Ruby
14
14
  email:
@@ -134,6 +134,7 @@ files:
134
134
  - lib/tasks/benchmark.rake
135
135
  - lib/tasks/tasks.rake
136
136
  - rollbar.gemspec
137
+ - spec/support/rollbar_api.rb
137
138
  homepage: https://rollbar.com
138
139
  licenses:
139
140
  - MIT
@@ -158,7 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubygems_version: 3.1.2
162
+ rubyforge_project:
163
+ rubygems_version: 2.7.7
162
164
  signing_key:
163
165
  specification_version: 4
164
166
  summary: Reports exceptions to Rollbar