airbrake-ruby 4.8.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake-ruby.rb +132 -57
  3. data/lib/airbrake-ruby/async_sender.rb +7 -30
  4. data/lib/airbrake-ruby/backtrace.rb +8 -7
  5. data/lib/airbrake-ruby/benchmark.rb +1 -1
  6. data/lib/airbrake-ruby/code_hunk.rb +1 -1
  7. data/lib/airbrake-ruby/config.rb +59 -15
  8. data/lib/airbrake-ruby/config/processor.rb +71 -0
  9. data/lib/airbrake-ruby/config/validator.rb +9 -3
  10. data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
  11. data/lib/airbrake-ruby/file_cache.rb +1 -1
  12. data/lib/airbrake-ruby/filter_chain.rb +16 -1
  13. data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
  14. data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +2 -2
  15. data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
  16. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +5 -5
  17. data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
  18. data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
  19. data/lib/airbrake-ruby/filters/{keys_whitelist.rb → keys_allowlist.rb} +3 -3
  20. data/lib/airbrake-ruby/filters/{keys_blacklist.rb → keys_blocklist.rb} +3 -3
  21. data/lib/airbrake-ruby/filters/keys_filter.rb +39 -20
  22. data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
  23. data/lib/airbrake-ruby/filters/sql_filter.rb +7 -7
  24. data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
  25. data/lib/airbrake-ruby/filters/thread_filter.rb +5 -4
  26. data/lib/airbrake-ruby/grouppable.rb +12 -0
  27. data/lib/airbrake-ruby/ignorable.rb +1 -0
  28. data/lib/airbrake-ruby/inspectable.rb +2 -2
  29. data/lib/airbrake-ruby/loggable.rb +1 -1
  30. data/lib/airbrake-ruby/mergeable.rb +12 -0
  31. data/lib/airbrake-ruby/monotonic_time.rb +5 -0
  32. data/lib/airbrake-ruby/notice.rb +7 -14
  33. data/lib/airbrake-ruby/notice_notifier.rb +11 -3
  34. data/lib/airbrake-ruby/performance_breakdown.rb +16 -10
  35. data/lib/airbrake-ruby/performance_notifier.rb +80 -58
  36. data/lib/airbrake-ruby/promise.rb +1 -0
  37. data/lib/airbrake-ruby/query.rb +20 -15
  38. data/lib/airbrake-ruby/queue.rb +65 -0
  39. data/lib/airbrake-ruby/remote_settings.rb +105 -0
  40. data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
  41. data/lib/airbrake-ruby/remote_settings/settings_data.rb +116 -0
  42. data/lib/airbrake-ruby/request.rb +14 -12
  43. data/lib/airbrake-ruby/stat.rb +26 -33
  44. data/lib/airbrake-ruby/sync_sender.rb +3 -2
  45. data/lib/airbrake-ruby/tdigest.rb +43 -58
  46. data/lib/airbrake-ruby/thread_pool.rb +11 -1
  47. data/lib/airbrake-ruby/truncator.rb +10 -4
  48. data/lib/airbrake-ruby/version.rb +11 -1
  49. data/spec/airbrake_spec.rb +206 -71
  50. data/spec/async_sender_spec.rb +3 -12
  51. data/spec/backtrace_spec.rb +44 -44
  52. data/spec/code_hunk_spec.rb +11 -11
  53. data/spec/config/processor_spec.rb +143 -0
  54. data/spec/config/validator_spec.rb +23 -6
  55. data/spec/config_spec.rb +40 -14
  56. data/spec/deploy_notifier_spec.rb +2 -2
  57. data/spec/filter_chain_spec.rb +28 -1
  58. data/spec/filters/dependency_filter_spec.rb +1 -1
  59. data/spec/filters/gem_root_filter_spec.rb +9 -9
  60. data/spec/filters/git_last_checkout_filter_spec.rb +21 -4
  61. data/spec/filters/git_repository_filter.rb +1 -1
  62. data/spec/filters/git_revision_filter_spec.rb +10 -10
  63. data/spec/filters/{keys_whitelist_spec.rb → keys_allowlist_spec.rb} +29 -28
  64. data/spec/filters/{keys_blacklist_spec.rb → keys_blocklist_spec.rb} +39 -29
  65. data/spec/filters/root_directory_filter_spec.rb +9 -9
  66. data/spec/filters/sql_filter_spec.rb +58 -60
  67. data/spec/filters/system_exit_filter_spec.rb +1 -1
  68. data/spec/filters/thread_filter_spec.rb +32 -30
  69. data/spec/fixtures/project_root/code.rb +9 -9
  70. data/spec/loggable_spec.rb +17 -0
  71. data/spec/monotonic_time_spec.rb +11 -0
  72. data/spec/notice_notifier/options_spec.rb +17 -17
  73. data/spec/notice_notifier_spec.rb +20 -20
  74. data/spec/notice_spec.rb +6 -6
  75. data/spec/performance_breakdown_spec.rb +0 -1
  76. data/spec/performance_notifier_spec.rb +220 -73
  77. data/spec/query_spec.rb +1 -1
  78. data/spec/queue_spec.rb +18 -0
  79. data/spec/remote_settings/callback_spec.rb +143 -0
  80. data/spec/remote_settings/settings_data_spec.rb +348 -0
  81. data/spec/remote_settings_spec.rb +187 -0
  82. data/spec/request_spec.rb +1 -3
  83. data/spec/response_spec.rb +8 -8
  84. data/spec/spec_helper.rb +6 -6
  85. data/spec/stat_spec.rb +2 -12
  86. data/spec/sync_sender_spec.rb +14 -12
  87. data/spec/tdigest_spec.rb +7 -7
  88. data/spec/thread_pool_spec.rb +39 -10
  89. data/spec/timed_trace_spec.rb +1 -1
  90. data/spec/truncator_spec.rb +12 -12
  91. metadata +32 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb6fd7fd474a31d89d2b532d467f5c319399b183a5805488bbb57789bc502bef
4
- data.tar.gz: 83493c7a39f6eea49668f7c94fc202c90d55efcc1d4822864a70cca03c96134f
3
+ metadata.gz: 8102082d97168a2204b3e730fc2085d30d06d4ab501e6207d91ce9d67bd91584
4
+ data.tar.gz: cf2234bd6fc61e439796b0f664163a12fdd4c39c4256a1c469f06dd1f8132de3
5
5
  SHA512:
6
- metadata.gz: 149075c2e3a3cd9f43f19f7309f8b9e46aa36bde2994bc48b80c8b66a4c675d1fef2989e2020e5bc81dc55a8e8490f18aa445307dd2212f7c2467a3186fb1c8d
7
- data.tar.gz: 030edc9303bd0f1042a6aa3f3ec5b672ab58598fee90a71e6d7f6a6fed84716d2043afab9edf46b3bdd6ee9939ef6b979ad78dc37575be774663ac84e8af73a7
6
+ metadata.gz: d5b353597aa2bf9d59fa454f8a6a87fadcdc71685a7e21ef3ec9f74e57b20268e5d6cad2d6d0fe061bdcdbe02e65cf2e5761d4e92c6370ea1d1316972da9d9af
7
+ data.tar.gz: d13b77d0f959ff3a5326f054b8df67c9402b216038afd25672df8b6803623ac135bb5366739687fc5c234ae2e127d075828f747bb945d9ba4d48f3f354775f17
@@ -1,7 +1,6 @@
1
1
  require 'net/https'
2
2
  require 'logger'
3
3
  require 'json'
4
- require 'thread'
5
4
  require 'set'
6
5
  require 'socket'
7
6
  require 'time'
@@ -9,8 +8,14 @@ require 'time'
9
8
  require 'airbrake-ruby/version'
10
9
  require 'airbrake-ruby/loggable'
11
10
  require 'airbrake-ruby/stashable'
11
+ require 'airbrake-ruby/mergeable'
12
+ require 'airbrake-ruby/grouppable'
12
13
  require 'airbrake-ruby/config'
13
14
  require 'airbrake-ruby/config/validator'
15
+ require 'airbrake-ruby/config/processor'
16
+ require 'airbrake-ruby/remote_settings/callback'
17
+ require 'airbrake-ruby/remote_settings/settings_data'
18
+ require 'airbrake-ruby/remote_settings'
14
19
  require 'airbrake-ruby/promise'
15
20
  require 'airbrake-ruby/thread_pool'
16
21
  require 'airbrake-ruby/sync_sender'
@@ -23,8 +28,8 @@ require 'airbrake-ruby/notice'
23
28
  require 'airbrake-ruby/backtrace'
24
29
  require 'airbrake-ruby/truncator'
25
30
  require 'airbrake-ruby/filters/keys_filter'
26
- require 'airbrake-ruby/filters/keys_whitelist'
27
- require 'airbrake-ruby/filters/keys_blacklist'
31
+ require 'airbrake-ruby/filters/keys_allowlist'
32
+ require 'airbrake-ruby/filters/keys_blocklist'
28
33
  require 'airbrake-ruby/filters/gem_root_filter'
29
34
  require 'airbrake-ruby/filters/system_exit_filter'
30
35
  require 'airbrake-ruby/filters/root_directory_filter'
@@ -52,6 +57,7 @@ require 'airbrake-ruby/performance_breakdown'
52
57
  require 'airbrake-ruby/benchmark'
53
58
  require 'airbrake-ruby/monotonic_time'
54
59
  require 'airbrake-ruby/timed_trace'
60
+ require 'airbrake-ruby/queue'
55
61
 
56
62
  # Airbrake is a thin wrapper around instances of the notifier classes (such as
57
63
  # notice, performance & deploy notifiers). It creates a way to access them via a
@@ -69,6 +75,7 @@ require 'airbrake-ruby/timed_trace'
69
75
  #
70
76
  # @since v1.0.0
71
77
  # @api public
78
+ # rubocop:disable Metrics/ModuleLength
72
79
  module Airbrake
73
80
  # The general error that this library uses when it wants to raise.
74
81
  Error = Class.new(StandardError)
@@ -80,6 +87,13 @@ module Airbrake
80
87
  # special cases where we need to work around older implementations
81
88
  JRUBY = (RUBY_ENGINE == 'jruby')
82
89
 
90
+ # @return [Boolean] true if this Ruby supports safe levels and tainting,
91
+ # to guard against using deprecated or unsupported features.
92
+ HAS_SAFE_LEVEL = (
93
+ RUBY_ENGINE == 'ruby' &&
94
+ Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
95
+ )
96
+
83
97
  class << self
84
98
  # @since v4.2.3
85
99
  # @api private
@@ -107,7 +121,15 @@ module Airbrake
107
121
  def configure
108
122
  yield config = Airbrake::Config.instance
109
123
  Airbrake::Loggable.instance = config.logger
110
- process_config_options(config)
124
+
125
+ config_processor = Airbrake::Config::Processor.new(config)
126
+
127
+ config_processor.process_blocklist(notice_notifier)
128
+ config_processor.process_allowlist(notice_notifier)
129
+
130
+ @remote_settings ||= config_processor.process_remote_configuration
131
+
132
+ config_processor.add_filters(notice_notifier)
111
133
  end
112
134
 
113
135
  # @since v4.2.3
@@ -131,7 +153,7 @@ module Airbrake
131
153
  # @return [Boolean] true if the notifier was configured, false otherwise
132
154
  # @since v2.3.0
133
155
  def configured?
134
- notice_notifier.configured?
156
+ @notice_notifier && @notice_notifier.configured?
135
157
  end
136
158
 
137
159
  # Sends an exception to Airbrake asynchronously.
@@ -250,11 +272,24 @@ module Airbrake
250
272
  # Airbrake.close
251
273
  # Airbrake.notify('App crashed!') #=> raises Airbrake::Error
252
274
  #
253
- # @return [void]
275
+ # @return [nil]
276
+ # rubocop:disable Style/IfUnlessModifier, Metrics/CyclomaticComplexity
254
277
  def close
255
- notice_notifier.close
256
- performance_notifier.close
278
+ if defined?(@notice_notifier) && @notice_notifier
279
+ @notice_notifier.close
280
+ end
281
+
282
+ if defined?(@performance_notifier) && @performance_notifier
283
+ @performance_notifier.close
284
+ end
285
+
286
+ if defined?(@remote_settings) && @remote_settings
287
+ @remote_settings.stop_polling
288
+ end
289
+
290
+ nil
257
291
  end
292
+ # rubocop:enable Style/IfUnlessModifier, Metrics/CyclomaticComplexity
258
293
 
259
294
  # Pings the Airbrake Deploy API endpoint about the occurred deploy.
260
295
  #
@@ -317,9 +352,8 @@ module Airbrake
317
352
  notice_notifier.merge_context(context)
318
353
  end
319
354
 
320
- # Increments request statistics of a certain +route+ that was invoked on
321
- # +start_time+ and ended on +end_time+ with +method+, and returned
322
- # +status_code+.
355
+ # Increments request statistics of a certain +route+ invoked with +method+,
356
+ # which returned +status_code+.
323
357
  #
324
358
  # After a certain amount of time (n seconds) the aggregated route
325
359
  # information will be sent to Airbrake.
@@ -332,8 +366,7 @@ module Airbrake
332
366
  # func: 'do_stuff',
333
367
  # file: 'app/models/foo.rb',
334
368
  # line: 452,
335
- # start_time: timestamp,
336
- # end_time: Time.now
369
+ # timing: 123.45 # ms
337
370
  # )
338
371
  #
339
372
  # @param [Hash{Symbol=>Object}] request_info
@@ -347,22 +380,31 @@ module Airbrake
347
380
  # called the query (optional)
348
381
  # @option request_info [Integer] :line The line that executes the query
349
382
  # (optional)
350
- # @option request_info [Date] :start_time When the request started
351
- # @option request_info [Time] :end_time When the request ended (optional)
383
+ # @option request_info [Float] :timing How much time it took to process the
384
+ # request (in ms)
352
385
  # @param [Hash] stash What needs to be appeneded to the stash, so it's
353
386
  # available in filters
354
387
  # @return [void]
355
388
  # @since v3.0.0
356
389
  # @see Airbrake::PerformanceNotifier#notify
357
390
  def notify_request(request_info, stash = {})
358
- request = Request.new(request_info)
391
+ request = Request.new(**request_info)
359
392
  request.stash.merge!(stash)
360
393
  performance_notifier.notify(request)
361
394
  end
362
395
 
363
- # Increments SQL statistics of a certain +query+ that was invoked on
364
- # +start_time+ and finished on +end_time+. When +method+ and +route+ are
365
- # provided, the query is grouped by these parameters.
396
+ # Synchronously increments request statistics of a certain +route+ invoked
397
+ # with +method+, which returned +status_code+.
398
+ # @since v4.10.0
399
+ # @see .notify_request
400
+ def notify_request_sync(request_info, stash = {})
401
+ request = Request.new(**request_info)
402
+ request.stash.merge!(stash)
403
+ performance_notifier.notify_sync(request)
404
+ end
405
+
406
+ # Increments SQL statistics of a certain +query+. When +method+ and +route+
407
+ # are provided, the query is grouped by these parameters.
366
408
  #
367
409
  # After a certain amount of time (n seconds) the aggregated query
368
410
  # information will be sent to Airbrake.
@@ -372,29 +414,39 @@ module Airbrake
372
414
  # method: 'GET',
373
415
  # route: '/things',
374
416
  # query: 'SELECT * FROM things',
375
- # start_time: timestamp,
376
- # end_time: Time.now
417
+ # timing: 123.45 # ms
377
418
  # )
378
419
  #
379
420
  # @param [Hash{Symbol=>Object}] query_info
380
- # @option request_info [String] :method The HTTP method that triggered this
421
+ # @option query_info [String] :method The HTTP method that triggered this
381
422
  # SQL query (optional)
382
- # @option request_info [String] :route The route that triggered this SQL
423
+ # @option query_info [String] :route The route that triggered this SQL
383
424
  # query (optional)
384
- # @option request_info [String] :query The query that was executed
385
- # @option request_info [Date] :start_time When the query started executing
386
- # @option request_info [Time] :end_time When the query finished (optional)
425
+ # @option query_info [String] :query The query that was executed
426
+ # @option query_info [Float] :timing How much time it took to process the
427
+ # query (in ms)
387
428
  # @param [Hash] stash What needs to be appeneded to the stash, so it's
388
429
  # available in filters
389
430
  # @return [void]
390
431
  # @since v3.2.0
391
432
  # @see Airbrake::PerformanceNotifier#notify
392
433
  def notify_query(query_info, stash = {})
393
- query = Query.new(query_info)
434
+ query = Query.new(**query_info)
394
435
  query.stash.merge!(stash)
395
436
  performance_notifier.notify(query)
396
437
  end
397
438
 
439
+ # Synchronously increments SQL statistics of a certain +query+. When
440
+ # +method+ and +route+ are provided, the query is grouped by these
441
+ # parameters.
442
+ # @since v4.10.0
443
+ # @see .notify_query
444
+ def notify_query_sync(query_info, stash = {})
445
+ query = Query.new(**query_info)
446
+ query.stash.merge!(stash)
447
+ performance_notifier.notify_sync(query)
448
+ end
449
+
398
450
  # Increments performance breakdown statistics of a certain route.
399
451
  #
400
452
  # @example
@@ -403,8 +455,7 @@ module Airbrake
403
455
  # route: '/thing/:id/create',
404
456
  # response_type: 'json',
405
457
  # groups: { db: 24.0, view: 0.4 }, # ms
406
- # start_time: timestamp,
407
- # end_time: Time.now
458
+ # timing: 123.45 # ms
408
459
  # )
409
460
  #
410
461
  # @param [Hash{Symbol=>Object}] breakdown_info
@@ -412,17 +463,65 @@ module Airbrake
412
463
  # @option breakdown_info [String] :route
413
464
  # @option breakdown_info [String] :response_type
414
465
  # @option breakdown_info [Array<Hash{Symbol=>Float}>] :groups
415
- # @option breakdown_info [Date] :start_time
466
+ # @option breakdown_info [Float] :timing How much time it took to process
467
+ # the performance breakdown (in ms)
416
468
  # @param [Hash] stash What needs to be appeneded to the stash, so it's
417
469
  # available in filters
418
470
  # @return [void]
419
471
  # @since v4.2.0
420
472
  def notify_performance_breakdown(breakdown_info, stash = {})
421
- performance_breakdown = PerformanceBreakdown.new(breakdown_info)
473
+ performance_breakdown = PerformanceBreakdown.new(**breakdown_info)
422
474
  performance_breakdown.stash.merge!(stash)
423
475
  performance_notifier.notify(performance_breakdown)
424
476
  end
425
477
 
478
+ # Increments performance breakdown statistics of a certain route
479
+ # synchronously.
480
+ # @since v4.10.0
481
+ # @see .notify_performance_breakdown
482
+ def notify_performance_breakdown_sync(breakdown_info, stash = {})
483
+ performance_breakdown = PerformanceBreakdown.new(**breakdown_info)
484
+ performance_breakdown.stash.merge!(stash)
485
+ performance_notifier.notify_sync(performance_breakdown)
486
+ end
487
+
488
+ # Increments statistics of a certain queue (worker).
489
+ #
490
+ # @example
491
+ # Airbrake.notify_queue(
492
+ # queue: 'emails',
493
+ # error_count: 1,
494
+ # groups: { redis: 24.0, sql: 0.4 } # ms
495
+ # )
496
+ #
497
+ # @param [Hash{Symbol=>Object}] queue_info
498
+ # @option queue_info [String] :queue The name of the queue/worker
499
+ # @option queue_info [Integer] :error_count How many times this worker
500
+ # failed
501
+ # @option queue_info [Array<Hash{Symbol=>Float}>] :groups Where the job
502
+ # spent its time
503
+ # @option breakdown_info [Float] :timing How much time it took to process
504
+ # the queue (in ms)
505
+ # @param [Hash] stash What needs to be appended to the stash, so it's
506
+ # available in filters
507
+ # @return [void]
508
+ # @since v4.9.0
509
+ # @see .notify_queue_sync
510
+ def notify_queue(queue_info, stash = {})
511
+ queue = Queue.new(**queue_info)
512
+ queue.stash.merge!(stash)
513
+ performance_notifier.notify(queue)
514
+ end
515
+
516
+ # Increments statistics of a certain queue (worker) synchronously.
517
+ # @since v4.10.0
518
+ # @see .notify_queue
519
+ def notify_queue_sync(queue_info, stash = {})
520
+ queue = Queue.new(**queue_info)
521
+ queue.stash.merge!(stash)
522
+ performance_notifier.notify_sync(queue)
523
+ end
524
+
426
525
  # Runs a callback before {.notify_request} or {.notify_query} kicks in. This
427
526
  # is useful if you want to ignore specific resources or filter the data the
428
527
  # resource contains.
@@ -480,36 +579,12 @@ module Airbrake
480
579
  # @return [void]
481
580
  # @since v4.2.2
482
581
  def reset
483
- close if notice_notifier && configured?
582
+ close
484
583
 
485
584
  self.performance_notifier = PerformanceNotifier.new
486
585
  self.notice_notifier = NoticeNotifier.new
487
586
  self.deploy_notifier = DeployNotifier.new
488
587
  end
489
-
490
- private
491
-
492
- def process_config_options(config)
493
- if config.blacklist_keys.any?
494
- blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
495
- notice_notifier.add_filter(blacklist)
496
- end
497
-
498
- if config.whitelist_keys.any?
499
- whitelist = Airbrake::Filters::KeysWhitelist.new(config.whitelist_keys)
500
- notice_notifier.add_filter(whitelist)
501
- end
502
-
503
- return unless config.root_directory
504
-
505
- [
506
- Airbrake::Filters::RootDirectoryFilter,
507
- Airbrake::Filters::GitRevisionFilter,
508
- Airbrake::Filters::GitRepositoryFilter,
509
- Airbrake::Filters::GitLastCheckoutFilter
510
- ].each do |filter|
511
- notice_notifier.add_filter(filter.new(config.root_directory))
512
- end
513
- end
514
588
  end
515
589
  end
590
+ # rubocop:enable Metrics/ModuleLength
@@ -7,12 +7,6 @@ module Airbrake
7
7
  class AsyncSender
8
8
  include Loggable
9
9
 
10
- # @return [String]
11
- WILL_NOT_DELIVER_MSG =
12
- "%<log_label>s AsyncSender has reached its capacity of %<capacity>s " \
13
- "and the following notice will not be delivered " \
14
- "Error: %<type>s - %<message>s\nBacktrace: %<backtrace>s\n".freeze
15
-
16
10
  def initialize(method = :post)
17
11
  @config = Airbrake::Config.instance
18
12
  @method = method
@@ -20,12 +14,13 @@ module Airbrake
20
14
 
21
15
  # Asynchronously sends a notice to Airbrake.
22
16
  #
23
- # @param [Airbrake::Notice] notice A notice that was generated by the
24
- # library
17
+ # @param [Hash] payload Whatever needs to be sent
25
18
  # @return [Airbrake::Promise]
26
- def send(notice, promise, endpoint = @config.endpoint)
27
- unless thread_pool << [notice, promise, endpoint]
28
- return will_not_deliver(notice, promise)
19
+ def send(payload, promise, endpoint = @config.error_endpoint)
20
+ unless thread_pool << [payload, promise, endpoint]
21
+ return promise.reject(
22
+ "AsyncSender has reached its capacity of #{@config.queue_size}",
23
+ )
29
24
  end
30
25
 
31
26
  promise
@@ -54,27 +49,9 @@ module Airbrake
54
49
  ThreadPool.new(
55
50
  worker_size: @config.workers,
56
51
  queue_size: @config.queue_size,
57
- block: proc { |args| sender.send(*args) }
52
+ block: proc { |args| sender.send(*args) },
58
53
  )
59
54
  end
60
55
  end
61
-
62
- def will_not_deliver(notice, promise)
63
- error = notice[:errors].first
64
-
65
- logger.error(
66
- format(
67
- WILL_NOT_DELIVER_MSG,
68
- log_label: LOG_LABEL,
69
- capacity: @config.queue_size,
70
- type: error[:type],
71
- message: error[:message],
72
- backtrace: error[:backtrace].map do |line|
73
- "#{line[:file]}:#{line[:line]} in `#{line[:function]}'"
74
- end.join("\n")
75
- )
76
- )
77
- promise.reject("AsyncSender has reached its capacity of #{@config.queue_size}")
78
- end
79
56
  end
80
57
  end
@@ -22,7 +22,7 @@ module Airbrake
22
22
  (?<line>\d+) # Matches '43'
23
23
  :in\s
24
24
  `(?<function>.*)' # Matches "`block (3 levels) in <top (required)>'"
25
- \z}x
25
+ \z}x.freeze
26
26
 
27
27
  # @return [Regexp] the pattern that matches JRuby Java stack frames, such
28
28
  # as org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
@@ -39,7 +39,7 @@ module Airbrake
39
39
  :?
40
40
  (?<line>\d+)? # Matches '105'
41
41
  \)
42
- \z}x
42
+ \z}x.freeze
43
43
 
44
44
  # @return [Regexp] the pattern that tries to assume what a generic stack
45
45
  # frame might look like, when exception's backtrace is set manually.
@@ -53,7 +53,7 @@ module Airbrake
53
53
  |
54
54
  :in\s(?<function>.+) # Matches ":in func"
55
55
  )? # ... or nothing
56
- \z}x
56
+ \z}x.freeze
57
57
 
58
58
  # @return [Regexp] the pattern that matches exceptions from PL/SQL such as
59
59
  # ORA-06512: at "STORE.LI_LICENSES_PACK", line 1945
@@ -67,7 +67,7 @@ module Airbrake
67
67
  |
68
68
  #{GENERIC}
69
69
  )
70
- \z/x
70
+ \z/x.freeze
71
71
 
72
72
  # @return [Regexp] the pattern that matches CoffeeScript backtraces
73
73
  # usually coming from Rails & ExecJS
@@ -82,7 +82,7 @@ module Airbrake
82
82
  # Matches the Ruby part of the backtrace
83
83
  #{RUBY}
84
84
  )
85
- \z/x
85
+ \z/x.freeze
86
86
  end
87
87
 
88
88
  # @return [Integer] how many first frames should include code hunks
@@ -95,6 +95,7 @@ module Airbrake
95
95
  # @return [Array<Hash{Symbol=>String,Integer}>] the parsed backtrace
96
96
  def self.parse(exception)
97
97
  return [] if exception.backtrace.nil? || exception.backtrace.none?
98
+
98
99
  parse_backtrace(exception)
99
100
  end
100
101
 
@@ -147,13 +148,13 @@ module Airbrake
147
148
  return {
148
149
  file: match[:file],
149
150
  line: (Integer(match[:line]) if match[:line]),
150
- function: match[:function]
151
+ function: match[:function],
151
152
  }
152
153
  end
153
154
 
154
155
  logger.error(
155
156
  "can't parse '#{stackframe}' (please file an issue so we can fix " \
156
- "it: https://github.com/airbrake/airbrake-ruby/issues/new)"
157
+ "it: https://github.com/airbrake/airbrake-ruby/issues/new)",
157
158
  )
158
159
  { file: nil, line: nil, function: stackframe }
159
160
  end