rollbar 2.25.1 → 2.26.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: 5bffe91029b00ca56f007756a93e94cdfb22ae068983b7d81c8f5b8dd168de41
4
- data.tar.gz: 5f75d00b9b6f8910fb0d7c8de71f30efde6b00132927b01746811d101b5a4dc2
3
+ metadata.gz: 69307fc6496e1b12a3ebbe3e40b7341f725a7f4efadd6a1a5e76d7246bc86928
4
+ data.tar.gz: 117fb5d03ab1f140f9469558c6560963180806935d3d56eeeb35da9cf450edc6
5
5
  SHA512:
6
- metadata.gz: ff7f880b5749d41a349ffa441198d495f13b450712c79a407b9569f091161ca06fdd5c3db08068d05a970745d629e99ed258de770cb8a973e3c3834a66d0592c
7
- data.tar.gz: 740de4df537388a5a52280c2aebb5f2286849dc70589baa20dd587518a49334e8a10f28c2caa6540b1c45dbcf24c1c46652f90c35395c51bba7ae9d154bb3c64
6
+ metadata.gz: 61587004c5ba54fffb2bd34d9f4abdfd182a82002ebcbe688c8c500975797f43f2caac63ce3ca510276828e1b2132cda95027b42ea02533221a18a008d8d654b
7
+ data.tar.gz: 9b62efc68f689811910cb92ae3262447c41732eaa6ebdc14019b7fd96114fcfebddf921e29699480e1fa7a21d54281e9130e99a3c85f8104f2d4440fd22f840d
@@ -136,11 +136,18 @@ module Rollbar
136
136
  uuid = stringified_payload['data']['uuid']
137
137
  host = stringified_payload['data'].fetch('server', {})['host']
138
138
 
139
+ original_error = {
140
+ :message => message,
141
+ :exception => exception,
142
+ :configuration => configuration,
143
+ :uuid => uuid,
144
+ :host => host
145
+ }
146
+
139
147
  notifier.send_failsafe(
140
148
  too_large_payload_string(attempts),
141
149
  nil,
142
- uuid,
143
- host
150
+ original_error
144
151
  )
145
152
  logger.error("[Rollbar] Payload too large to be sent for UUID #{uuid}: #{Rollbar::JSON.dump(payload)}")
146
153
  end
@@ -55,7 +55,7 @@ module Rollbar
55
55
  current_exception = exception
56
56
 
57
57
  while current_exception.respond_to?(:cause) && (cause = current_exception.cause) && cause.is_a?(Exception) && !visited.include?(cause)
58
- traces.unshift(trace_data(cause))
58
+ traces << trace_data(cause)
59
59
  visited << cause
60
60
  current_exception = cause
61
61
  end
@@ -80,8 +80,11 @@ module Rollbar
80
80
  return app_result unless response_string
81
81
 
82
82
  env[JS_IS_INJECTED_KEY] = true
83
- response = ::Rack::Response.new(response_string, app_result[0],
84
- app_result[1])
83
+
84
+ status, headers, = app_result
85
+ headers['Content-Length'] = response_string.bytesize.to_s if headers.key?('Content-Length')
86
+
87
+ response = ::Rack::Response.new(response_string, status, headers)
85
88
 
86
89
  finished = response.finish
87
90
 
@@ -21,6 +21,7 @@ module Rollbar
21
21
 
22
22
  MUTEX = Mutex.new
23
23
  EXTENSION_REGEXP = /.rollbar\z/.freeze
24
+ FAILSAFE_STRING_LENGTH = 10_000
24
25
 
25
26
  def initialize(parent_notifier = nil, payload_options = nil, scope = nil)
26
27
  if parent_notifier
@@ -158,7 +159,13 @@ module Rollbar
158
159
  def report_with_rescue(level, message, exception, extra, context)
159
160
  report(level, message, exception, extra, context)
160
161
  rescue StandardError, SystemStackError => e
161
- report_internal_error(e)
162
+ original_error = {
163
+ :message => message,
164
+ :exception => exception,
165
+ :configuration => configuration
166
+ }
167
+
168
+ report_internal_error(e, original_error)
162
169
 
163
170
  'error'
164
171
  end
@@ -262,32 +269,32 @@ module Rollbar
262
269
  end
263
270
  end
264
271
 
265
- def send_failsafe(message, exception, uuid = nil, host = nil)
266
- exception_reason = failsafe_reason(message, exception)
267
-
268
- log_error "[Rollbar] Sending failsafe response due to #{exception_reason}"
269
-
270
- body = failsafe_body(exception_reason)
271
-
272
- failsafe_data = {
272
+ def failsafe_initial_data(exception_reason)
273
+ {
273
274
  :level => 'error',
274
275
  :environment => configuration.environment.to_s,
275
276
  :body => {
276
277
  :message => {
277
- :body => body
278
+ :body => failsafe_body(exception_reason)
278
279
  }
279
280
  },
280
281
  :notifier => {
281
282
  :name => 'rollbar-gem',
282
283
  :version => VERSION
283
284
  },
284
- :custom => {
285
- :orig_uuid => uuid,
286
- :orig_host => host
287
- },
288
285
  :internal => true,
289
286
  'failsafe' => true
290
287
  }
288
+ end
289
+
290
+ def send_failsafe(message, exception, original_error = nil)
291
+ exception_reason = failsafe_reason(message, exception)
292
+
293
+ log_error "[Rollbar] Sending failsafe response due to #{exception_reason}"
294
+
295
+ failsafe_data = failsafe_initial_data(exception_reason)
296
+
297
+ failsafe_add_original_error_data(failsafe_data[:notifier], original_error)
291
298
 
292
299
  failsafe_payload = {
293
300
  'data' => failsafe_data
@@ -298,7 +305,9 @@ module Rollbar
298
305
  :notifier => self,
299
306
  :configuration => configuration,
300
307
  :logger => logger)
301
- schedule_item(item)
308
+
309
+ process_item(item)
310
+ log_and_return_item_data(item)
302
311
  rescue StandardError => e
303
312
  log_error "[Rollbar] Error sending failsafe : #{e}"
304
313
  end
@@ -306,6 +315,57 @@ module Rollbar
306
315
  failsafe_payload
307
316
  end
308
317
 
318
+ def failsafe_add_original_error_data(payload_notifier, original_error)
319
+ return unless original_error
320
+
321
+ payload_notifier[:diagnostic] ||= {}
322
+
323
+ add_original_host(payload_notifier[:diagnostic], original_error)
324
+ add_original_uuid(payload_notifier[:diagnostic], original_error)
325
+ add_original_message(payload_notifier[:diagnostic], original_error)
326
+ add_original_error(payload_notifier[:diagnostic], original_error)
327
+ add_configured_options(payload_notifier, original_error)
328
+ end
329
+
330
+ def add_original_message(diagnostic, original_error)
331
+ diagnostic[:original_message] = original_error[:message].truncate(FAILSAFE_STRING_LENGTH) if original_error[:message]
332
+
333
+ rescue StandardError => e
334
+ diagnostic[:original_message] = "Failed: #{e.message}"
335
+ end
336
+
337
+ def add_original_error(diagnostic, original_error)
338
+ if original_error[:exception]
339
+ backtrace = original_error[:exception].backtrace
340
+ message = original_error[:exception].message
341
+ diagnostic[:original_error] = {
342
+ :message => message && message.truncate(FAILSAFE_STRING_LENGTH),
343
+ :stack => backtrace && backtrace.join(', ').truncate(FAILSAFE_STRING_LENGTH)
344
+ }
345
+ end
346
+
347
+ rescue StandardError => e
348
+ diagnostic[:original_error] = "Failed: #{e.message}"
349
+ end
350
+
351
+ def add_configured_options(payload_notifier, original_error)
352
+ if original_error[:configuration]
353
+ configured = original_error[:configuration].configured_options.configured
354
+ payload_notifier[:configured_options] = ::JSON.generate(configured).truncate(FAILSAFE_STRING_LENGTH)
355
+ end
356
+
357
+ rescue StandardError => e
358
+ payload_notifier[:configured_options] = "Failed: #{e.message}"
359
+ end
360
+
361
+ def add_original_host(diagnostic, original_error)
362
+ diagnostic[:original_host] = original_error[:host] if original_error[:host]
363
+ end
364
+
365
+ def add_original_uuid(diagnostic, original_error)
366
+ diagnostic[:original_uuid] = original_error[:uuid] if original_error[:uuid]
367
+ end
368
+
309
369
  ## Logging
310
370
  %w[debug info warn error].each do |level|
311
371
  define_method(:"log_#{level}") do |message|
@@ -461,7 +521,7 @@ module Rollbar
461
521
  # Reports an internal error in the Rollbar library. This will be reported within the configured
462
522
  # Rollbar project. We'll first attempt to provide a report including the exception traceback.
463
523
  # If that fails, we'll fall back to a more static failsafe response.
464
- def report_internal_error(exception)
524
+ def report_internal_error(exception, original_error = nil)
465
525
  log_error '[Rollbar] Reporting internal error encountered while sending data to Rollbar.'
466
526
 
467
527
  configuration.execute_hook(:on_report_internal_error, exception)
@@ -469,7 +529,7 @@ module Rollbar
469
529
  begin
470
530
  item = build_item('error', nil, exception, { :internal => true }, nil)
471
531
  rescue StandardError => e
472
- send_failsafe('build_item in exception_data', e)
532
+ send_failsafe('build_item in exception_data', e, original_error)
473
533
  log_error "[Rollbar] Exception: #{exception}"
474
534
  return
475
535
  end
@@ -477,7 +537,7 @@ module Rollbar
477
537
  begin
478
538
  process_item(item)
479
539
  rescue StandardError => e
480
- send_failsafe('error in process_item', e)
540
+ send_failsafe('error in process_item', e, original_error)
481
541
  log_error "[Rollbar] Item: #{item}"
482
542
  return
483
543
  end
@@ -485,7 +545,7 @@ module Rollbar
485
545
  begin
486
546
  log_instance_link(item['data'])
487
547
  rescue StandardError => e
488
- send_failsafe('error logging instance link', e)
548
+ send_failsafe('error logging instance link', e, original_error)
489
549
  log_error "[Rollbar] Item: #{item}"
490
550
  return
491
551
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.25.1'.freeze
2
+ VERSION = '2.26.0'.freeze
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: 2.25.1
4
+ version: 2.26.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-06-10 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy and powerful exception tracking for Ruby
14
14
  email: