airbrake-ruby 4.6.0 → 6.2.2
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.
- checksums.yaml +5 -5
- data/lib/airbrake-ruby/async_sender.rb +24 -109
- data/lib/airbrake-ruby/backlog.rb +123 -0
- data/lib/airbrake-ruby/backtrace.rb +8 -7
- data/lib/airbrake-ruby/benchmark.rb +1 -1
- data/lib/airbrake-ruby/code_hunk.rb +1 -1
- data/lib/airbrake-ruby/config/processor.rb +77 -0
- data/lib/airbrake-ruby/config/validator.rb +9 -3
- data/lib/airbrake-ruby/config.rb +78 -19
- data/lib/airbrake-ruby/context.rb +51 -0
- data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
- data/lib/airbrake-ruby/file_cache.rb +6 -0
- data/lib/airbrake-ruby/filter_chain.rb +18 -1
- data/lib/airbrake-ruby/filters/context_filter.rb +4 -5
- data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +3 -3
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +7 -7
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +11 -2
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +3 -1
- data/lib/airbrake-ruby/filters/{keys_whitelist.rb → keys_allowlist.rb} +3 -3
- data/lib/airbrake-ruby/filters/{keys_blacklist.rb → keys_blocklist.rb} +3 -3
- data/lib/airbrake-ruby/filters/keys_filter.rb +41 -22
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +35 -11
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +6 -5
- data/lib/airbrake-ruby/grouppable.rb +12 -0
- data/lib/airbrake-ruby/ignorable.rb +1 -2
- data/lib/airbrake-ruby/inspectable.rb +2 -2
- data/lib/airbrake-ruby/loggable.rb +1 -1
- data/lib/airbrake-ruby/mergeable.rb +12 -0
- data/lib/airbrake-ruby/monotonic_time.rb +6 -1
- data/lib/airbrake-ruby/nested_exception.rb +22 -1
- data/lib/airbrake-ruby/notice.rb +12 -17
- data/lib/airbrake-ruby/notice_notifier.rb +15 -7
- data/lib/airbrake-ruby/performance_breakdown.rb +16 -9
- data/lib/airbrake-ruby/performance_notifier.rb +106 -54
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +20 -14
- data/lib/airbrake-ruby/queue.rb +65 -0
- data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +116 -0
- data/lib/airbrake-ruby/remote_settings.rb +128 -0
- data/lib/airbrake-ruby/request.rb +14 -11
- data/lib/airbrake-ruby/response.rb +56 -5
- data/lib/airbrake-ruby/stat.rb +27 -34
- data/lib/airbrake-ruby/sync_sender.rb +43 -11
- data/lib/airbrake-ruby/tdigest.rb +52 -66
- data/lib/airbrake-ruby/thread_pool.rb +139 -0
- data/lib/airbrake-ruby/time_truncate.rb +2 -2
- data/lib/airbrake-ruby/timed_trace.rb +1 -3
- data/lib/airbrake-ruby/truncator.rb +10 -4
- data/lib/airbrake-ruby/version.rb +11 -1
- data/lib/airbrake-ruby.rb +157 -78
- metadata +122 -116
- data/spec/airbrake_spec.rb +0 -324
- data/spec/async_sender_spec.rb +0 -155
- data/spec/backtrace_spec.rb +0 -427
- data/spec/benchmark_spec.rb +0 -33
- data/spec/code_hunk_spec.rb +0 -115
- data/spec/config/validator_spec.rb +0 -184
- data/spec/config_spec.rb +0 -154
- data/spec/deploy_notifier_spec.rb +0 -48
- data/spec/file_cache.rb +0 -36
- data/spec/filter_chain_spec.rb +0 -92
- data/spec/filters/context_filter_spec.rb +0 -23
- data/spec/filters/dependency_filter_spec.rb +0 -12
- data/spec/filters/exception_attributes_filter_spec.rb +0 -50
- data/spec/filters/gem_root_filter_spec.rb +0 -41
- data/spec/filters/git_last_checkout_filter_spec.rb +0 -46
- data/spec/filters/git_repository_filter.rb +0 -61
- data/spec/filters/git_revision_filter_spec.rb +0 -126
- data/spec/filters/keys_blacklist_spec.rb +0 -225
- data/spec/filters/keys_whitelist_spec.rb +0 -194
- data/spec/filters/root_directory_filter_spec.rb +0 -39
- data/spec/filters/sql_filter_spec.rb +0 -219
- data/spec/filters/system_exit_filter_spec.rb +0 -14
- data/spec/filters/thread_filter_spec.rb +0 -277
- data/spec/fixtures/notroot.txt +0 -7
- data/spec/fixtures/project_root/code.rb +0 -221
- data/spec/fixtures/project_root/empty_file.rb +0 -0
- data/spec/fixtures/project_root/long_line.txt +0 -1
- data/spec/fixtures/project_root/short_file.rb +0 -3
- data/spec/fixtures/project_root/vendor/bundle/ignored_file.rb +0 -5
- data/spec/helpers.rb +0 -9
- data/spec/ignorable_spec.rb +0 -14
- data/spec/inspectable_spec.rb +0 -45
- data/spec/monotonic_time_spec.rb +0 -12
- data/spec/nested_exception_spec.rb +0 -73
- data/spec/notice_notifier_spec/options_spec.rb +0 -259
- data/spec/notice_notifier_spec.rb +0 -356
- data/spec/notice_spec.rb +0 -296
- data/spec/performance_breakdown_spec.rb +0 -12
- data/spec/performance_notifier_spec.rb +0 -435
- data/spec/promise_spec.rb +0 -197
- data/spec/query_spec.rb +0 -11
- data/spec/request_spec.rb +0 -11
- data/spec/response_spec.rb +0 -88
- data/spec/spec_helper.rb +0 -100
- data/spec/stashable_spec.rb +0 -23
- data/spec/stat_spec.rb +0 -47
- data/spec/sync_sender_spec.rb +0 -133
- data/spec/tdigest_spec.rb +0 -230
- data/spec/time_truncate_spec.rb +0 -13
- data/spec/timed_trace_spec.rb +0 -125
- data/spec/truncator_spec.rb +0 -238
data/lib/airbrake-ruby.rb
CHANGED
|
@@ -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,12 +8,19 @@ 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'
|
|
20
|
+
require 'airbrake-ruby/thread_pool'
|
|
21
|
+
require 'airbrake-ruby/response'
|
|
15
22
|
require 'airbrake-ruby/sync_sender'
|
|
16
23
|
require 'airbrake-ruby/async_sender'
|
|
17
|
-
require 'airbrake-ruby/response'
|
|
18
24
|
require 'airbrake-ruby/nested_exception'
|
|
19
25
|
require 'airbrake-ruby/ignorable'
|
|
20
26
|
require 'airbrake-ruby/inspectable'
|
|
@@ -22,8 +28,8 @@ require 'airbrake-ruby/notice'
|
|
|
22
28
|
require 'airbrake-ruby/backtrace'
|
|
23
29
|
require 'airbrake-ruby/truncator'
|
|
24
30
|
require 'airbrake-ruby/filters/keys_filter'
|
|
25
|
-
require 'airbrake-ruby/filters/
|
|
26
|
-
require 'airbrake-ruby/filters/
|
|
31
|
+
require 'airbrake-ruby/filters/keys_allowlist'
|
|
32
|
+
require 'airbrake-ruby/filters/keys_blocklist'
|
|
27
33
|
require 'airbrake-ruby/filters/gem_root_filter'
|
|
28
34
|
require 'airbrake-ruby/filters/system_exit_filter'
|
|
29
35
|
require 'airbrake-ruby/filters/root_directory_filter'
|
|
@@ -51,6 +57,9 @@ require 'airbrake-ruby/performance_breakdown'
|
|
|
51
57
|
require 'airbrake-ruby/benchmark'
|
|
52
58
|
require 'airbrake-ruby/monotonic_time'
|
|
53
59
|
require 'airbrake-ruby/timed_trace'
|
|
60
|
+
require 'airbrake-ruby/queue'
|
|
61
|
+
require 'airbrake-ruby/context'
|
|
62
|
+
require 'airbrake-ruby/backlog'
|
|
54
63
|
|
|
55
64
|
# Airbrake is a thin wrapper around instances of the notifier classes (such as
|
|
56
65
|
# notice, performance & deploy notifiers). It creates a way to access them via a
|
|
@@ -68,6 +77,7 @@ require 'airbrake-ruby/timed_trace'
|
|
|
68
77
|
#
|
|
69
78
|
# @since v1.0.0
|
|
70
79
|
# @api public
|
|
80
|
+
# rubocop:disable Metrics/ModuleLength
|
|
71
81
|
module Airbrake
|
|
72
82
|
# The general error that this library uses when it wants to raise.
|
|
73
83
|
Error = Class.new(StandardError)
|
|
@@ -79,6 +89,13 @@ module Airbrake
|
|
|
79
89
|
# special cases where we need to work around older implementations
|
|
80
90
|
JRUBY = (RUBY_ENGINE == 'jruby')
|
|
81
91
|
|
|
92
|
+
# @return [Boolean] true if this Ruby supports safe levels and tainting,
|
|
93
|
+
# to guard against using deprecated or unsupported features.
|
|
94
|
+
HAS_SAFE_LEVEL = (
|
|
95
|
+
RUBY_ENGINE == 'ruby' &&
|
|
96
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
|
|
97
|
+
)
|
|
98
|
+
|
|
82
99
|
class << self
|
|
83
100
|
# @since v4.2.3
|
|
84
101
|
# @api private
|
|
@@ -106,7 +123,15 @@ module Airbrake
|
|
|
106
123
|
def configure
|
|
107
124
|
yield config = Airbrake::Config.instance
|
|
108
125
|
Airbrake::Loggable.instance = config.logger
|
|
109
|
-
|
|
126
|
+
|
|
127
|
+
config_processor = Airbrake::Config::Processor.new(config)
|
|
128
|
+
|
|
129
|
+
config_processor.process_blocklist(notice_notifier)
|
|
130
|
+
config_processor.process_allowlist(notice_notifier)
|
|
131
|
+
|
|
132
|
+
@remote_settings ||= config_processor.process_remote_configuration
|
|
133
|
+
|
|
134
|
+
config_processor.add_filters(notice_notifier)
|
|
110
135
|
end
|
|
111
136
|
|
|
112
137
|
# @since v4.2.3
|
|
@@ -130,7 +155,7 @@ module Airbrake
|
|
|
130
155
|
# @return [Boolean] true if the notifier was configured, false otherwise
|
|
131
156
|
# @since v2.3.0
|
|
132
157
|
def configured?
|
|
133
|
-
notice_notifier.configured?
|
|
158
|
+
@notice_notifier && @notice_notifier.configured?
|
|
134
159
|
end
|
|
135
160
|
|
|
136
161
|
# Sends an exception to Airbrake asynchronously.
|
|
@@ -249,10 +274,24 @@ module Airbrake
|
|
|
249
274
|
# Airbrake.close
|
|
250
275
|
# Airbrake.notify('App crashed!') #=> raises Airbrake::Error
|
|
251
276
|
#
|
|
252
|
-
# @return [
|
|
277
|
+
# @return [nil]
|
|
278
|
+
# rubocop:disable Style/IfUnlessModifier
|
|
253
279
|
def close
|
|
254
|
-
notice_notifier
|
|
280
|
+
if defined?(@notice_notifier) && @notice_notifier
|
|
281
|
+
@notice_notifier.close
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
if defined?(@performance_notifier) && @performance_notifier
|
|
285
|
+
@performance_notifier.close
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
if defined?(@remote_settings) && @remote_settings
|
|
289
|
+
@remote_settings.stop_polling
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
nil
|
|
255
293
|
end
|
|
294
|
+
# rubocop:enable Style/IfUnlessModifier
|
|
256
295
|
|
|
257
296
|
# Pings the Airbrake Deploy API endpoint about the occurred deploy.
|
|
258
297
|
#
|
|
@@ -315,9 +354,8 @@ module Airbrake
|
|
|
315
354
|
notice_notifier.merge_context(context)
|
|
316
355
|
end
|
|
317
356
|
|
|
318
|
-
# Increments request statistics of a certain +route+
|
|
319
|
-
#
|
|
320
|
-
# +status_code+.
|
|
357
|
+
# Increments request statistics of a certain +route+ invoked with +method+,
|
|
358
|
+
# which returned +status_code+.
|
|
321
359
|
#
|
|
322
360
|
# After a certain amount of time (n seconds) the aggregated route
|
|
323
361
|
# information will be sent to Airbrake.
|
|
@@ -327,40 +365,39 @@ module Airbrake
|
|
|
327
365
|
# method: 'POST',
|
|
328
366
|
# route: '/thing/:id/create',
|
|
329
367
|
# status_code: 200,
|
|
330
|
-
#
|
|
331
|
-
# file: 'app/models/foo.rb',
|
|
332
|
-
# line: 452,
|
|
333
|
-
# start_time: timestamp,
|
|
334
|
-
# end_time: Time.now
|
|
368
|
+
# timing: 123.45 # ms
|
|
335
369
|
# )
|
|
336
370
|
#
|
|
337
371
|
# @param [Hash{Symbol=>Object}] request_info
|
|
338
372
|
# @option request_info [String] :method The HTTP method that was invoked
|
|
339
373
|
# @option request_info [String] :route The route that was invoked
|
|
340
|
-
# @option request_info [Integer] :status_code The
|
|
374
|
+
# @option request_info [Integer] :status_code The response code that the
|
|
341
375
|
# route returned
|
|
342
|
-
# @option request_info [
|
|
343
|
-
# (
|
|
344
|
-
# @option request_info [String] :file The file that has the function that
|
|
345
|
-
# called the query (optional)
|
|
346
|
-
# @option request_info [Integer] :line The line that executes the query
|
|
347
|
-
# (optional)
|
|
348
|
-
# @option request_info [Date] :start_time When the request started
|
|
349
|
-
# @option request_info [Time] :end_time When the request ended (optional)
|
|
376
|
+
# @option request_info [Float] :timing How much time it took to process the
|
|
377
|
+
# request (in ms)
|
|
350
378
|
# @param [Hash] stash What needs to be appeneded to the stash, so it's
|
|
351
379
|
# available in filters
|
|
352
380
|
# @return [void]
|
|
353
381
|
# @since v3.0.0
|
|
354
382
|
# @see Airbrake::PerformanceNotifier#notify
|
|
355
383
|
def notify_request(request_info, stash = {})
|
|
356
|
-
request = Request.new(request_info)
|
|
384
|
+
request = Request.new(**request_info)
|
|
357
385
|
request.stash.merge!(stash)
|
|
358
386
|
performance_notifier.notify(request)
|
|
359
387
|
end
|
|
360
388
|
|
|
361
|
-
#
|
|
362
|
-
# +
|
|
363
|
-
#
|
|
389
|
+
# Synchronously increments request statistics of a certain +route+ invoked
|
|
390
|
+
# with +method+, which returned +status_code+.
|
|
391
|
+
# @since v4.10.0
|
|
392
|
+
# @see .notify_request
|
|
393
|
+
def notify_request_sync(request_info, stash = {})
|
|
394
|
+
request = Request.new(**request_info)
|
|
395
|
+
request.stash.merge!(stash)
|
|
396
|
+
performance_notifier.notify_sync(request)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
# Increments SQL statistics of a certain +query+. When +method+ and +route+
|
|
400
|
+
# are provided, the query is grouped by these parameters.
|
|
364
401
|
#
|
|
365
402
|
# After a certain amount of time (n seconds) the aggregated query
|
|
366
403
|
# information will be sent to Airbrake.
|
|
@@ -370,39 +407,57 @@ module Airbrake
|
|
|
370
407
|
# method: 'GET',
|
|
371
408
|
# route: '/things',
|
|
372
409
|
# query: 'SELECT * FROM things',
|
|
373
|
-
#
|
|
374
|
-
#
|
|
410
|
+
# func: 'do_stuff',
|
|
411
|
+
# file: 'app/models/foo.rb',
|
|
412
|
+
# line: 452,
|
|
413
|
+
# timing: 123.45 # ms
|
|
375
414
|
# )
|
|
376
415
|
#
|
|
377
416
|
# @param [Hash{Symbol=>Object}] query_info
|
|
378
|
-
# @option
|
|
417
|
+
# @option query_info [String] :method The HTTP method that triggered this
|
|
379
418
|
# SQL query (optional)
|
|
380
|
-
# @option
|
|
419
|
+
# @option query_info [String] :route The route that triggered this SQL
|
|
381
420
|
# query (optional)
|
|
382
|
-
# @option
|
|
383
|
-
# @option request_info [
|
|
384
|
-
#
|
|
421
|
+
# @option query_info [String] :query The query that was executed
|
|
422
|
+
# @option request_info [String] :func The function that called the query
|
|
423
|
+
# (optional)
|
|
424
|
+
# @option request_info [String] :file The file that has the function that
|
|
425
|
+
# called the query (optional)
|
|
426
|
+
# @option request_info [Integer] :line The line that executes the query
|
|
427
|
+
# (optional)
|
|
428
|
+
# @option query_info [Float] :timing How much time it took to process the
|
|
429
|
+
# query (in ms)
|
|
385
430
|
# @param [Hash] stash What needs to be appeneded to the stash, so it's
|
|
386
431
|
# available in filters
|
|
387
432
|
# @return [void]
|
|
388
433
|
# @since v3.2.0
|
|
389
434
|
# @see Airbrake::PerformanceNotifier#notify
|
|
390
435
|
def notify_query(query_info, stash = {})
|
|
391
|
-
query = Query.new(query_info)
|
|
436
|
+
query = Query.new(**query_info)
|
|
392
437
|
query.stash.merge!(stash)
|
|
393
438
|
performance_notifier.notify(query)
|
|
394
439
|
end
|
|
395
440
|
|
|
441
|
+
# Synchronously increments SQL statistics of a certain +query+. When
|
|
442
|
+
# +method+ and +route+ are provided, the query is grouped by these
|
|
443
|
+
# parameters.
|
|
444
|
+
# @since v4.10.0
|
|
445
|
+
# @see .notify_query
|
|
446
|
+
def notify_query_sync(query_info, stash = {})
|
|
447
|
+
query = Query.new(**query_info)
|
|
448
|
+
query.stash.merge!(stash)
|
|
449
|
+
performance_notifier.notify_sync(query)
|
|
450
|
+
end
|
|
451
|
+
|
|
396
452
|
# Increments performance breakdown statistics of a certain route.
|
|
397
453
|
#
|
|
398
454
|
# @example
|
|
399
|
-
# Airbrake.
|
|
455
|
+
# Airbrake.notify_performance_breakdown(
|
|
400
456
|
# method: 'POST',
|
|
401
457
|
# route: '/thing/:id/create',
|
|
402
458
|
# response_type: 'json',
|
|
403
459
|
# groups: { db: 24.0, view: 0.4 }, # ms
|
|
404
|
-
#
|
|
405
|
-
# end_time: Time.now
|
|
460
|
+
# timing: 123.45 # ms
|
|
406
461
|
# )
|
|
407
462
|
#
|
|
408
463
|
# @param [Hash{Symbol=>Object}] breakdown_info
|
|
@@ -410,35 +465,83 @@ module Airbrake
|
|
|
410
465
|
# @option breakdown_info [String] :route
|
|
411
466
|
# @option breakdown_info [String] :response_type
|
|
412
467
|
# @option breakdown_info [Array<Hash{Symbol=>Float}>] :groups
|
|
413
|
-
# @option breakdown_info [
|
|
468
|
+
# @option breakdown_info [Float] :timing How much time it took to process
|
|
469
|
+
# the performance breakdown (in ms)
|
|
414
470
|
# @param [Hash] stash What needs to be appeneded to the stash, so it's
|
|
415
471
|
# available in filters
|
|
416
472
|
# @return [void]
|
|
417
473
|
# @since v4.2.0
|
|
418
474
|
def notify_performance_breakdown(breakdown_info, stash = {})
|
|
419
|
-
performance_breakdown = PerformanceBreakdown.new(breakdown_info)
|
|
475
|
+
performance_breakdown = PerformanceBreakdown.new(**breakdown_info)
|
|
420
476
|
performance_breakdown.stash.merge!(stash)
|
|
421
477
|
performance_notifier.notify(performance_breakdown)
|
|
422
478
|
end
|
|
423
479
|
|
|
424
|
-
#
|
|
425
|
-
#
|
|
426
|
-
#
|
|
480
|
+
# Increments performance breakdown statistics of a certain route
|
|
481
|
+
# synchronously.
|
|
482
|
+
# @since v4.10.0
|
|
483
|
+
# @see .notify_performance_breakdown
|
|
484
|
+
def notify_performance_breakdown_sync(breakdown_info, stash = {})
|
|
485
|
+
performance_breakdown = PerformanceBreakdown.new(**breakdown_info)
|
|
486
|
+
performance_breakdown.stash.merge!(stash)
|
|
487
|
+
performance_notifier.notify_sync(performance_breakdown)
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# Increments statistics of a certain queue (worker).
|
|
491
|
+
#
|
|
492
|
+
# @example
|
|
493
|
+
# Airbrake.notify_queue(
|
|
494
|
+
# queue: 'emails',
|
|
495
|
+
# error_count: 1,
|
|
496
|
+
# groups: { redis: 24.0, sql: 0.4 } # ms
|
|
497
|
+
# )
|
|
498
|
+
#
|
|
499
|
+
# @param [Hash{Symbol=>Object}] queue_info
|
|
500
|
+
# @option queue_info [String] :queue The name of the queue/worker
|
|
501
|
+
# @option queue_info [Integer] :error_count How many times this worker
|
|
502
|
+
# failed
|
|
503
|
+
# @option queue_info [Array<Hash{Symbol=>Float}>] :groups Where the job
|
|
504
|
+
# spent its time
|
|
505
|
+
# @option breakdown_info [Float] :timing How much time it took to process
|
|
506
|
+
# the queue (in ms)
|
|
507
|
+
# @param [Hash] stash What needs to be appended to the stash, so it's
|
|
508
|
+
# available in filters
|
|
509
|
+
# @return [void]
|
|
510
|
+
# @since v4.9.0
|
|
511
|
+
# @see .notify_queue_sync
|
|
512
|
+
def notify_queue(queue_info, stash = {})
|
|
513
|
+
queue = Queue.new(**queue_info)
|
|
514
|
+
queue.stash.merge!(stash)
|
|
515
|
+
performance_notifier.notify(queue)
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
# Increments statistics of a certain queue (worker) synchronously.
|
|
519
|
+
# @since v4.10.0
|
|
520
|
+
# @see .notify_queue
|
|
521
|
+
def notify_queue_sync(queue_info, stash = {})
|
|
522
|
+
queue = Queue.new(**queue_info)
|
|
523
|
+
queue.stash.merge!(stash)
|
|
524
|
+
performance_notifier.notify_sync(queue)
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
# Runs a callback before {.notify_request}, {.notify_query}, {.notify_queue}
|
|
528
|
+
# or {.notify_performance_breakdown} kicks in. This is useful if you want to
|
|
529
|
+
# ignore specific metrics or filter the data the metric contains.
|
|
427
530
|
#
|
|
428
|
-
# @example Ignore all
|
|
531
|
+
# @example Ignore all metrics
|
|
429
532
|
# Airbrake.add_performance_filter(&:ignore!)
|
|
430
533
|
# @example Filter sensitive data
|
|
431
|
-
# Airbrake.add_performance_filter do |
|
|
432
|
-
# case
|
|
534
|
+
# Airbrake.add_performance_filter do |metric|
|
|
535
|
+
# case metric
|
|
433
536
|
# when Airbrake::Query
|
|
434
|
-
#
|
|
537
|
+
# metric.route = '[Filtered]'
|
|
435
538
|
# when Airbrake::Request
|
|
436
|
-
#
|
|
539
|
+
# metric.query = '[Filtered]'
|
|
437
540
|
# end
|
|
438
541
|
# end
|
|
439
542
|
# @example Filter with help of a class
|
|
440
543
|
# class MyFilter
|
|
441
|
-
# def call(
|
|
544
|
+
# def call(metric)
|
|
442
545
|
# # ...
|
|
443
546
|
# end
|
|
444
547
|
# end
|
|
@@ -446,7 +549,7 @@ module Airbrake
|
|
|
446
549
|
# Airbrake.add_performance_filter(MyFilter.new)
|
|
447
550
|
#
|
|
448
551
|
# @param [#call] filter The filter object
|
|
449
|
-
# @yield [
|
|
552
|
+
# @yield [metric] The metric to filter
|
|
450
553
|
# @yieldparam [Airbrake::Query, Airbrake::Request]
|
|
451
554
|
# @yieldreturn [void]
|
|
452
555
|
# @return [void]
|
|
@@ -478,36 +581,12 @@ module Airbrake
|
|
|
478
581
|
# @return [void]
|
|
479
582
|
# @since v4.2.2
|
|
480
583
|
def reset
|
|
481
|
-
close
|
|
584
|
+
close
|
|
482
585
|
|
|
483
586
|
self.performance_notifier = PerformanceNotifier.new
|
|
484
587
|
self.notice_notifier = NoticeNotifier.new
|
|
485
588
|
self.deploy_notifier = DeployNotifier.new
|
|
486
589
|
end
|
|
487
|
-
|
|
488
|
-
private
|
|
489
|
-
|
|
490
|
-
def process_config_options(config)
|
|
491
|
-
if config.blacklist_keys.any?
|
|
492
|
-
blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
|
|
493
|
-
notice_notifier.add_filter(blacklist)
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
if config.whitelist_keys.any?
|
|
497
|
-
whitelist = Airbrake::Filters::KeysWhitelist.new(config.whitelist_keys)
|
|
498
|
-
notice_notifier.add_filter(whitelist)
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
return unless config.root_directory
|
|
502
|
-
|
|
503
|
-
[
|
|
504
|
-
Airbrake::Filters::RootDirectoryFilter,
|
|
505
|
-
Airbrake::Filters::GitRevisionFilter,
|
|
506
|
-
Airbrake::Filters::GitRepositoryFilter,
|
|
507
|
-
Airbrake::Filters::GitLastCheckoutFilter
|
|
508
|
-
].each do |filter|
|
|
509
|
-
notice_notifier.add_filter(filter.new(config.root_directory))
|
|
510
|
-
end
|
|
511
|
-
end
|
|
512
590
|
end
|
|
513
591
|
end
|
|
592
|
+
# rubocop:enable Metrics/ModuleLength
|