rollbar 0.12.20 → 0.13.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: a174b1d884a3719e380c721e3f31176157b55895
4
- data.tar.gz: 8a848c8705970c1ff53a45f763a89068b3f6f6c9
3
+ metadata.gz: edd3328a4f2609cd9fe7a75916ef566e36fa4a03
4
+ data.tar.gz: 971ed93611878985514906f336a290bb74cdb120
5
5
  SHA512:
6
- metadata.gz: 4f00108d55e33e68bc513f6f7493b7707a3b87e8d4bbdeeb2190172829e091f410acd5bac8533232b6297311a98639e5c60ed58bc7076cafb23738fef74104f7
7
- data.tar.gz: 59414c7223324364962285a981007b5a0934ea3aef2c3d68b435a7aacfc56d8d416ec05a55bbd096f031b80e0ffdd14c7564f60f653de4e85ab7f9e5552dc6c1
6
+ metadata.gz: 6b9ccd2085f183dd0d3074a8c42201daeb21eae07a06981f65aca8e18afdf9ab357525805921095fea71a07cb7c89ad292539f1873aabaadbec0741d7e546b75
7
+ data.tar.gz: 0176e82ff4510507d448b9db337a1b93e7623ca4c53e805bd4c8faaa30fd2c1cc9a43c88034342c6d14fc93bdac6482c6bc5666173929b6de7caad0d4fdb5e51
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ **0.13.0**
4
+ - Hook for delayed_job no longer a plugin, will now only ever be initialized once
5
+ - New configuration option `delayed_job_enabled` that defaults to true
6
+ - Potentially breaking change if using delayed_job: if you disabled the delayed_job plugin previously, please remove that code and instead set the new configuration option `delayed_job_enabled` to false
7
+
3
8
  **0.12.20**
4
9
  - Fix asynchronous reports with sidekiq version < 2.3.2
5
10
  - Support for specifying multiple project_gems with regex [#114](https://github.com/rollbar/rollbar-gem/pull/114)
data/README.md CHANGED
@@ -233,7 +233,7 @@ config.dj_threshold = 2 # default is 0
233
233
  If you use [custom jobs](https://github.com/collectiveidea/delayed_job#custom-jobs) that define their own hooks to report exceptions, please consider disabling our plugin. Not doing so will result in duplicate exceptions being reported as well as lack of control when exceptions should be reported. To disable our Delayed::Job plugin, add the following line after the `Rollbar.configure` block.
234
234
 
235
235
  ```ruby
236
- Delayed::Worker.plugins.delete(Delayed::Plugins::Rollbar)
236
+ config.delayed_job_enabled = false
237
237
  ```
238
238
 
239
239
 
data/THANKS.md CHANGED
@@ -27,6 +27,7 @@ Huge thanks to the following contributors (by github username). For the most up-
27
27
  - [miloops](https://github.com/miloops)
28
28
  - [mipearson](https://github.com/mipearson)
29
29
  - [mrgordon](https://github.com/mrgordon)
30
+ - [notahat](https://github.com/notahat)
30
31
  - [petergoldstein](https://github.com/petergoldstein)
31
32
  - [pmen](https://github.com/pmen)
32
33
  - [rogercampos](https://github.com/rogercampos)
@@ -20,11 +20,17 @@ require 'rollbar/railtie' if defined?(Rails)
20
20
 
21
21
  module Rollbar
22
22
  MAX_PAYLOAD_SIZE = 128 * 1024 #128kb
23
-
23
+
24
24
  class << self
25
25
  attr_writer :configuration
26
26
  attr_accessor :last_report
27
27
 
28
+ # Similar to configure below, but used only internally within the gem
29
+ # to configure it without initializing any of the third party hooks
30
+ def preconfigure
31
+ yield(configuration)
32
+ end
33
+
28
34
  # Configures the gem.
29
35
  #
30
36
  # Call on app startup to set the `access_token` (required) and other config params.
@@ -36,13 +42,13 @@ module Rollbar
36
42
  # config.access_token = 'abcdefg'
37
43
  # end
38
44
  def configure
39
- require_hooks
40
-
41
45
  # if configuration.enabled has not been set yet (is still 'nil'), set to true.
42
46
  if configuration.enabled.nil?
43
47
  configuration.enabled = true
44
48
  end
45
49
  yield(configuration)
50
+
51
+ require_hooks
46
52
  end
47
53
 
48
54
  def reconfigure
@@ -81,12 +87,12 @@ module Rollbar
81
87
  person_id = person_data[Rollbar.configuration.person_id_method.to_sym]
82
88
  return 'ignored' if configuration.ignored_person_ids.include?(person_id)
83
89
  end
84
-
90
+
85
91
  return 'disabled' unless configuration.enabled
86
92
  return 'ignored' if ignored?(exception)
87
93
 
88
94
  data = exception_data(exception, level ? level : filtered_level(exception))
89
-
95
+
90
96
  attach_request_data(data, request_data) if request_data
91
97
  data[:person] = person_data if person_data
92
98
 
@@ -116,9 +122,9 @@ module Rollbar
116
122
  return 'disabled' unless configuration.enabled
117
123
 
118
124
  data = message_data(message, level, extra_data)
119
-
125
+
120
126
  @last_report = data
121
-
127
+
122
128
  payload = build_payload(data)
123
129
  schedule_payload(payload)
124
130
  log_instance_link(data)
@@ -147,12 +153,12 @@ module Rollbar
147
153
  return 'disabled' unless configuration.enabled
148
154
 
149
155
  data = message_data(message, level, extra_data)
150
-
156
+
151
157
  attach_request_data(data, request_data) if request_data
152
158
  data[:person] = person_data if person_data
153
-
159
+
154
160
  @last_report = data
155
-
161
+
156
162
  payload = build_payload(data)
157
163
  schedule_payload(payload)
158
164
  log_instance_link(data)
@@ -226,23 +232,27 @@ module Rollbar
226
232
  end
227
233
 
228
234
  private
229
-
235
+
230
236
  def attach_request_data(payload, request_data)
231
237
  if request_data[:route]
232
238
  route = request_data[:route]
233
-
239
+
234
240
  # make sure route is a hash built by RequestDataExtractor in rails apps
235
241
  if route.is_a?(Hash) and not route.empty?
236
242
  payload[:context] = "#{request_data[:route][:controller]}" + '#' + "#{request_data[:route][:action]}"
237
243
  end
238
244
  end
239
-
245
+
240
246
  request_data[:env].reject!{|k, v| v.is_a?(IO) } if request_data[:env]
241
247
  payload[:request] = request_data
242
248
  end
243
249
 
244
250
  def require_hooks()
245
- require 'rollbar/delayed_job' if defined?(Delayed) && defined?(Delayed::Plugins)
251
+ if defined?(Delayed) && defined?(Delayed::Worker) && configuration.delayed_job_enabled
252
+ require 'rollbar/delayed_job'
253
+ Rollbar::Delayed::wrap_worker
254
+ end
255
+
246
256
  require 'rollbar/sidekiq' if defined?(Sidekiq)
247
257
  require 'rollbar/goalie' if defined?(Goalie)
248
258
  require 'rollbar/rack' if defined?(Rack)
@@ -409,7 +419,7 @@ module Rollbar
409
419
  if payload.nil?
410
420
  return
411
421
  end
412
-
422
+
413
423
  log_info '[Rollbar] Scheduling payload'
414
424
 
415
425
  if configuration.use_async
@@ -435,18 +445,18 @@ module Rollbar
435
445
  :data => data
436
446
  }
437
447
  result = MultiJson.dump(payload)
438
-
448
+
439
449
  # Try to truncate strings in the payload a few times if the payload is too big
440
450
  original_size = result.bytesize
441
451
  if original_size > MAX_PAYLOAD_SIZE
442
452
  thresholds = [1024, 512, 256]
443
453
  thresholds.each_with_index do |threshold, i|
444
454
  new_payload = payload.clone
445
-
455
+
446
456
  truncate_payload(new_payload, threshold)
447
-
457
+
448
458
  result = MultiJson.dump(new_payload)
449
-
459
+
450
460
  if result.bytesize <= MAX_PAYLOAD_SIZE
451
461
  break
452
462
  elsif i == thresholds.length - 1
@@ -457,7 +467,7 @@ module Rollbar
457
467
  end
458
468
  end
459
469
  end
460
-
470
+
461
471
  result
462
472
  end
463
473
 
@@ -493,7 +503,7 @@ module Rollbar
493
503
  unless config.custom_data_method.nil?
494
504
  data[:custom] = config.custom_data_method.call
495
505
  end
496
-
506
+
497
507
  data
498
508
  end
499
509
 
@@ -592,7 +602,7 @@ module Rollbar
592
602
  log_error "[Rollbar] Error sending failsafe : #{e}"
593
603
  end
594
604
  end
595
-
605
+
596
606
  def truncate_payload(payload, byte_threshold)
597
607
  truncator = Proc.new do |value|
598
608
  if value.is_a?(String) and value.bytesize > byte_threshold
@@ -601,7 +611,7 @@ module Rollbar
601
611
  value
602
612
  end
603
613
  end
604
-
614
+
605
615
  Rollbar::Util::iterate_and_update(payload, truncator)
606
616
  end
607
617
  end
@@ -8,6 +8,7 @@ module Rollbar
8
8
  attr_accessor :branch
9
9
  attr_accessor :code_version
10
10
  attr_accessor :custom_data_method
11
+ attr_accessor :delayed_job_enabled
11
12
  attr_accessor :default_logger
12
13
  attr_accessor :dj_threshold
13
14
  attr_accessor :enabled
@@ -42,6 +43,7 @@ module Rollbar
42
43
  @code_version = nil
43
44
  @custom_data_method = nil
44
45
  @default_logger = lambda { Logger.new(STDERR) }
46
+ @delayed_job_enabled = true
45
47
  @dj_threshold = 0
46
48
  @enabled = nil # set to true when configure is called
47
49
  @endpoint = DEFAULT_ENDPOINT
@@ -1,23 +1,20 @@
1
- # based on http://bit.ly/VGdfVI
2
-
3
- module Delayed
4
- module Plugins
5
- class Rollbar < Plugin
6
- callbacks do |lifecycle|
7
- lifecycle.around(:invoke_job) do |job, *args, &block|
8
- begin
9
- block.call(job, *args)
10
- rescue Exception => e
11
- if job.attempts >= ::Rollbar.configuration.dj_threshold
12
- data = ::Rollbar.configuration.report_dj_data ? job : nil
13
- ::Rollbar.report_exception(e, data)
14
- end
15
- raise e
1
+ module Rollbar
2
+ module Delayed
3
+ def self.wrap_worker
4
+ return if @wrapped
5
+ @wrapped = true
6
+
7
+ ::Delayed::Worker.lifecycle.around(:invoke_job) do |job, *args, &block|
8
+ begin
9
+ block.call(job, *args)
10
+ rescue Exception => e
11
+ if job.attempts >= ::Rollbar.configuration.dj_threshold
12
+ data = ::Rollbar.configuration.report_dj_data ? job : nil
13
+ ::Rollbar.report_exception(e, data)
16
14
  end
15
+ raise e
17
16
  end
18
17
  end
19
18
  end
20
19
  end
21
20
  end
22
-
23
- Delayed::Worker.plugins << Delayed::Plugins::Rollbar
@@ -9,7 +9,7 @@ module Rollbar
9
9
  RAILS_DEFAULT_LOGGER
10
10
  end
11
11
 
12
- Rollbar.configure do |config|
12
+ Rollbar.preconfigure do |config|
13
13
  config.logger = rails_logger
14
14
  config.environment = defined?(::Rails.env) && ::Rails.env || defined?(RAILS_ENV) && RAILS_ENV
15
15
  config.root = defined?(::Rails.root) && ::Rails.root || defined?(RAILS_ROOT) && RAILS_ROOT
@@ -15,7 +15,7 @@ module Rollbar
15
15
  end
16
16
 
17
17
  config.after_initialize do
18
- Rollbar.configure do |config|
18
+ Rollbar.preconfigure do |config|
19
19
  config.logger ||= ::Rails.logger
20
20
  config.environment ||= ::Rails.env
21
21
  config.root ||= ::Rails.root
@@ -41,4 +41,3 @@ module Rollbar
41
41
  end
42
42
  end
43
43
  end
44
-
@@ -8,7 +8,7 @@ namespace :rollbar do
8
8
  Logger.new(STDOUT)
9
9
 
10
10
  Rails.logger.level = Logger::DEBUG
11
- Rollbar.configure do |config|
11
+ Rollbar.preconfigure do |config|
12
12
  config.logger = Rails.logger
13
13
  end
14
14
 
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "0.12.20"
2
+ VERSION = "0.13.0"
3
3
  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: 0.12.20
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Rue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json