airbrake-ruby 4.15.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/async_sender.rb +4 -2
- data/lib/airbrake-ruby/backtrace.rb +6 -5
- data/lib/airbrake-ruby/config/processor.rb +77 -0
- data/lib/airbrake-ruby/config/validator.rb +6 -0
- data/lib/airbrake-ruby/config.rb +44 -35
- data/lib/airbrake-ruby/context.rb +51 -0
- data/lib/airbrake-ruby/file_cache.rb +1 -1
- data/lib/airbrake-ruby/filter_chain.rb +3 -0
- 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 +1 -1
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +3 -4
- 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_filter.rb +23 -15
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +11 -11
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +4 -3
- data/lib/airbrake-ruby/grouppable.rb +1 -1
- data/lib/airbrake-ruby/ignorable.rb +1 -2
- data/lib/airbrake-ruby/mergeable.rb +1 -1
- data/lib/airbrake-ruby/monotonic_time.rb +1 -1
- data/lib/airbrake-ruby/notice.rb +1 -8
- data/lib/airbrake-ruby/notice_notifier.rb +4 -4
- data/lib/airbrake-ruby/performance_breakdown.rb +1 -6
- data/lib/airbrake-ruby/performance_notifier.rb +40 -54
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +1 -6
- data/lib/airbrake-ruby/queue.rb +1 -8
- 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 +1 -8
- data/lib/airbrake-ruby/stat.rb +2 -13
- data/lib/airbrake-ruby/sync_sender.rb +3 -2
- data/lib/airbrake-ruby/tdigest.rb +12 -9
- data/lib/airbrake-ruby/thread_pool.rb +9 -6
- data/lib/airbrake-ruby/time_truncate.rb +2 -2
- data/lib/airbrake-ruby/timed_trace.rb +1 -3
- data/lib/airbrake-ruby/truncator.rb +8 -2
- data/lib/airbrake-ruby/version.rb +11 -1
- data/lib/airbrake-ruby.rb +44 -54
- data/spec/airbrake_spec.rb +178 -92
- data/spec/async_sender_spec.rb +10 -8
- data/spec/backtrace_spec.rb +39 -36
- data/spec/benchmark_spec.rb +7 -5
- data/spec/code_hunk_spec.rb +26 -17
- data/spec/config/processor_spec.rb +167 -0
- data/spec/config/validator_spec.rb +23 -3
- data/spec/config_spec.rb +43 -55
- data/spec/context_spec.rb +54 -0
- data/spec/deploy_notifier_spec.rb +6 -4
- data/spec/file_cache_spec.rb +1 -0
- data/spec/filter_chain_spec.rb +29 -24
- data/spec/filters/context_filter_spec.rb +14 -5
- data/spec/filters/dependency_filter_spec.rb +3 -1
- data/spec/filters/exception_attributes_filter_spec.rb +5 -3
- data/spec/filters/gem_root_filter_spec.rb +9 -6
- data/spec/filters/git_last_checkout_filter_spec.rb +10 -12
- data/spec/filters/{git_repository_filter.rb → git_repository_filter_spec.rb} +26 -15
- data/spec/filters/git_revision_filter_spec.rb +20 -20
- data/spec/filters/keys_allowlist_spec.rb +26 -16
- data/spec/filters/keys_blocklist_spec.rb +35 -18
- data/spec/filters/root_directory_filter_spec.rb +7 -7
- data/spec/filters/sql_filter_spec.rb +28 -28
- data/spec/filters/system_exit_filter_spec.rb +4 -2
- data/spec/filters/thread_filter_spec.rb +16 -14
- data/spec/loggable_spec.rb +2 -2
- data/spec/monotonic_time_spec.rb +8 -6
- data/spec/nested_exception_spec.rb +46 -46
- data/spec/notice_notifier/options_spec.rb +25 -15
- data/spec/notice_notifier_spec.rb +54 -49
- data/spec/notice_spec.rb +7 -3
- data/spec/performance_breakdown_spec.rb +0 -12
- data/spec/performance_notifier_spec.rb +69 -87
- data/spec/promise_spec.rb +38 -32
- data/spec/query_spec.rb +1 -11
- data/spec/queue_spec.rb +1 -13
- data/spec/remote_settings/callback_spec.rb +162 -0
- data/spec/remote_settings/settings_data_spec.rb +348 -0
- data/spec/remote_settings_spec.rb +201 -0
- data/spec/request_spec.rb +1 -13
- data/spec/response_spec.rb +34 -12
- data/spec/spec_helper.rb +4 -4
- data/spec/stashable_spec.rb +5 -5
- data/spec/stat_spec.rb +7 -14
- data/spec/sync_sender_spec.rb +52 -17
- data/spec/tdigest_spec.rb +61 -56
- data/spec/thread_pool_spec.rb +67 -58
- data/spec/time_truncate_spec.rb +23 -6
- data/spec/timed_trace_spec.rb +32 -30
- data/spec/truncator_spec.rb +72 -43
- metadata +67 -51
@@ -1,4 +1,6 @@
|
|
1
1
|
RSpec.describe Airbrake::PerformanceNotifier do
|
2
|
+
subject(:perf_notifier) { described_class.new }
|
3
|
+
|
2
4
|
let(:routes) { 'https://api.airbrake.io/api/v5/projects/1/routes-stats' }
|
3
5
|
let(:queries) { 'https://api.airbrake.io/api/v5/projects/1/queries-stats' }
|
4
6
|
let(:breakdowns) { 'https://api.airbrake.io/api/v5/projects/1/routes-breakdowns' }
|
@@ -22,7 +24,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
22
24
|
|
23
25
|
describe "#notify" do
|
24
26
|
it "sends full query" do
|
25
|
-
|
27
|
+
perf_notifier.notify(
|
26
28
|
Airbrake::Query.new(
|
27
29
|
method: 'POST',
|
28
30
|
route: '/foo',
|
@@ -34,7 +36,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
34
36
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
35
37
|
),
|
36
38
|
)
|
37
|
-
|
39
|
+
perf_notifier.close
|
38
40
|
|
39
41
|
expect(
|
40
42
|
a_request(:put, queries).with(body: %r|
|
@@ -55,7 +57,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
55
57
|
end
|
56
58
|
|
57
59
|
it "sends full request" do
|
58
|
-
|
60
|
+
perf_notifier.notify(
|
59
61
|
Airbrake::Request.new(
|
60
62
|
method: 'POST',
|
61
63
|
route: '/foo',
|
@@ -64,7 +66,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
64
66
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
65
67
|
),
|
66
68
|
)
|
67
|
-
|
69
|
+
perf_notifier.close
|
68
70
|
|
69
71
|
expect(
|
70
72
|
a_request(:put, routes).with(body: %r|
|
@@ -82,7 +84,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
82
84
|
end
|
83
85
|
|
84
86
|
it "sends full performance breakdown" do
|
85
|
-
|
87
|
+
perf_notifier.notify(
|
86
88
|
Airbrake::PerformanceBreakdown.new(
|
87
89
|
method: 'DELETE',
|
88
90
|
route: '/routes-breakdowns',
|
@@ -92,7 +94,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
92
94
|
groups: { db: 131, view: 421 },
|
93
95
|
),
|
94
96
|
)
|
95
|
-
|
97
|
+
perf_notifier.close
|
96
98
|
|
97
99
|
expect(
|
98
100
|
a_request(:put, breakdowns).with(body: %r|
|
@@ -124,7 +126,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
124
126
|
end
|
125
127
|
|
126
128
|
it "sends full queue" do
|
127
|
-
|
129
|
+
perf_notifier.notify(
|
128
130
|
Airbrake::Queue.new(
|
129
131
|
queue: 'emails',
|
130
132
|
error_count: 2,
|
@@ -133,7 +135,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
133
135
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
134
136
|
),
|
135
137
|
)
|
136
|
-
|
138
|
+
perf_notifier.close
|
137
139
|
|
138
140
|
expect(
|
139
141
|
a_request(:put, queues).with(body: /
|
@@ -164,7 +166,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
164
166
|
end
|
165
167
|
|
166
168
|
it "rounds time to the floor minute" do
|
167
|
-
|
169
|
+
perf_notifier.notify(
|
168
170
|
Airbrake::Request.new(
|
169
171
|
method: 'GET',
|
170
172
|
route: '/foo',
|
@@ -173,7 +175,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
173
175
|
time: Time.new(2018, 1, 1, 0, 0, 20, 0),
|
174
176
|
),
|
175
177
|
)
|
176
|
-
|
178
|
+
perf_notifier.close
|
177
179
|
|
178
180
|
expect(
|
179
181
|
a_request(:put, routes).with(body: /"time":"2018-01-01T00:00:00\+00:00"/),
|
@@ -181,7 +183,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
181
183
|
end
|
182
184
|
|
183
185
|
it "increments routes with the same key" do
|
184
|
-
|
186
|
+
perf_notifier.notify(
|
185
187
|
Airbrake::Request.new(
|
186
188
|
method: 'GET',
|
187
189
|
route: '/foo',
|
@@ -189,7 +191,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
189
191
|
timing: 213,
|
190
192
|
),
|
191
193
|
)
|
192
|
-
|
194
|
+
perf_notifier.notify(
|
193
195
|
Airbrake::Request.new(
|
194
196
|
method: 'GET',
|
195
197
|
route: '/foo',
|
@@ -197,7 +199,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
197
199
|
timing: 123,
|
198
200
|
),
|
199
201
|
)
|
200
|
-
|
202
|
+
perf_notifier.close
|
201
203
|
|
202
204
|
expect(
|
203
205
|
a_request(:put, routes).with(body: /"count":2/),
|
@@ -205,7 +207,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
205
207
|
end
|
206
208
|
|
207
209
|
it "groups routes by time" do
|
208
|
-
|
210
|
+
perf_notifier.notify(
|
209
211
|
Airbrake::Request.new(
|
210
212
|
method: 'GET',
|
211
213
|
route: '/foo',
|
@@ -214,7 +216,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
214
216
|
time: Time.new(2018, 1, 1, 0, 0, 49, 0),
|
215
217
|
),
|
216
218
|
)
|
217
|
-
|
219
|
+
perf_notifier.notify(
|
218
220
|
Airbrake::Request.new(
|
219
221
|
method: 'GET',
|
220
222
|
route: '/foo',
|
@@ -223,7 +225,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
223
225
|
time: Time.new(2018, 1, 1, 0, 1, 49, 0),
|
224
226
|
),
|
225
227
|
)
|
226
|
-
|
228
|
+
perf_notifier.close
|
227
229
|
|
228
230
|
expect(
|
229
231
|
a_request(:put, routes).with(
|
@@ -241,7 +243,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
241
243
|
end
|
242
244
|
|
243
245
|
it "groups routes by route key" do
|
244
|
-
|
246
|
+
perf_notifier.notify(
|
245
247
|
Airbrake::Request.new(
|
246
248
|
method: 'GET',
|
247
249
|
route: '/foo',
|
@@ -250,7 +252,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
250
252
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
251
253
|
),
|
252
254
|
)
|
253
|
-
|
255
|
+
perf_notifier.notify(
|
254
256
|
Airbrake::Request.new(
|
255
257
|
method: 'POST',
|
256
258
|
route: '/foo',
|
@@ -259,7 +261,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
259
261
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
260
262
|
),
|
261
263
|
)
|
262
|
-
|
264
|
+
perf_notifier.close
|
263
265
|
|
264
266
|
expect(
|
265
267
|
a_request(:put, routes).with(
|
@@ -277,7 +279,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
277
279
|
end
|
278
280
|
|
279
281
|
it "groups performance breakdowns by route key" do
|
280
|
-
|
282
|
+
perf_notifier.notify(
|
281
283
|
Airbrake::PerformanceBreakdown.new(
|
282
284
|
method: 'DELETE',
|
283
285
|
route: '/routes-breakdowns',
|
@@ -287,7 +289,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
287
289
|
groups: { db: 131, view: 421 },
|
288
290
|
),
|
289
291
|
)
|
290
|
-
|
292
|
+
perf_notifier.notify(
|
291
293
|
Airbrake::PerformanceBreakdown.new(
|
292
294
|
method: 'DELETE',
|
293
295
|
route: '/routes-breakdowns',
|
@@ -297,7 +299,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
297
299
|
groups: { db: 55, view: 11 },
|
298
300
|
),
|
299
301
|
)
|
300
|
-
|
302
|
+
perf_notifier.close
|
301
303
|
|
302
304
|
expect(
|
303
305
|
a_request(:put, breakdowns).with(body: %r|
|
@@ -329,7 +331,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
329
331
|
end
|
330
332
|
|
331
333
|
it "groups queues by queue key" do
|
332
|
-
|
334
|
+
perf_notifier.notify(
|
333
335
|
Airbrake::Queue.new(
|
334
336
|
queue: 'emails',
|
335
337
|
error_count: 2,
|
@@ -338,7 +340,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
338
340
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
339
341
|
),
|
340
342
|
)
|
341
|
-
|
343
|
+
perf_notifier.notify(
|
342
344
|
Airbrake::Queue.new(
|
343
345
|
queue: 'emails',
|
344
346
|
error_count: 3,
|
@@ -347,7 +349,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
347
349
|
time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
348
350
|
),
|
349
351
|
)
|
350
|
-
|
352
|
+
perf_notifier.close
|
351
353
|
|
352
354
|
expect(
|
353
355
|
a_request(:put, queues).with(body: /
|
@@ -378,7 +380,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
378
380
|
end
|
379
381
|
|
380
382
|
it "returns a promise" do
|
381
|
-
promise =
|
383
|
+
promise = perf_notifier.notify(
|
382
384
|
Airbrake::Request.new(
|
383
385
|
method: 'GET',
|
384
386
|
route: '/foo',
|
@@ -386,7 +388,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
386
388
|
timing: 123,
|
387
389
|
),
|
388
390
|
)
|
389
|
-
|
391
|
+
perf_notifier.close
|
390
392
|
|
391
393
|
expect(promise).to be_an(Airbrake::Promise)
|
392
394
|
expect(promise.value).to eq('' => '')
|
@@ -396,16 +398,19 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
396
398
|
request = Airbrake::Request.new(
|
397
399
|
method: 'GET', route: '/foo', status_code: 200, timing: 123,
|
398
400
|
)
|
399
|
-
|
400
|
-
.
|
401
|
-
|
402
|
-
|
401
|
+
allow(Airbrake::Config.instance).to receive(:check_performance_options)
|
402
|
+
.and_return(Airbrake::Promise.new)
|
403
|
+
perf_notifier.notify(request)
|
404
|
+
perf_notifier.close
|
405
|
+
|
406
|
+
expect(Airbrake::Config.instance)
|
407
|
+
.to have_received(:check_performance_options).with(request)
|
403
408
|
end
|
404
409
|
|
405
410
|
it "sends environment when it's specified" do
|
406
411
|
Airbrake::Config.instance.merge(performance_stats: true, environment: 'test')
|
407
412
|
|
408
|
-
|
413
|
+
perf_notifier.notify(
|
409
414
|
Airbrake::Request.new(
|
410
415
|
method: 'POST',
|
411
416
|
route: '/foo',
|
@@ -413,7 +418,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
413
418
|
timing: 123,
|
414
419
|
),
|
415
420
|
)
|
416
|
-
|
421
|
+
perf_notifier.close
|
417
422
|
|
418
423
|
expect(
|
419
424
|
a_request(:put, routes).with(
|
@@ -426,7 +431,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
426
431
|
before { Airbrake::Config.instance.merge(project_id: nil) }
|
427
432
|
|
428
433
|
it "returns a rejected promise" do
|
429
|
-
promise =
|
434
|
+
promise = perf_notifier.notify({})
|
430
435
|
expect(promise).to be_rejected
|
431
436
|
end
|
432
437
|
end
|
@@ -442,7 +447,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
442
447
|
performance_stats_flush_period: flush_period,
|
443
448
|
)
|
444
449
|
|
445
|
-
|
450
|
+
perf_notifier.notify(
|
446
451
|
Airbrake::Request.new(
|
447
452
|
method: 'GET',
|
448
453
|
route: '/foo',
|
@@ -451,7 +456,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
451
456
|
),
|
452
457
|
)
|
453
458
|
|
454
|
-
|
459
|
+
perf_notifier.notify(
|
455
460
|
Airbrake::Query.new(
|
456
461
|
method: 'POST',
|
457
462
|
route: '/foo',
|
@@ -468,10 +473,10 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
468
473
|
end
|
469
474
|
|
470
475
|
context "when an ignore filter was defined" do
|
471
|
-
before {
|
476
|
+
before { perf_notifier.add_filter(&:ignore!) }
|
472
477
|
|
473
478
|
it "doesn't notify airbrake of requests" do
|
474
|
-
|
479
|
+
perf_notifier.notify(
|
475
480
|
Airbrake::Request.new(
|
476
481
|
method: 'GET',
|
477
482
|
route: '/foo',
|
@@ -479,13 +484,13 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
479
484
|
timing: 1,
|
480
485
|
),
|
481
486
|
)
|
482
|
-
|
487
|
+
perf_notifier.close
|
483
488
|
|
484
489
|
expect(a_request(:put, routes)).not_to have_been_made
|
485
490
|
end
|
486
491
|
|
487
492
|
it "doesn't notify airbrake of queries" do
|
488
|
-
|
493
|
+
perf_notifier.notify(
|
489
494
|
Airbrake::Query.new(
|
490
495
|
method: 'POST',
|
491
496
|
route: '/foo',
|
@@ -493,13 +498,13 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
493
498
|
timing: 1,
|
494
499
|
),
|
495
500
|
)
|
496
|
-
|
501
|
+
perf_notifier.close
|
497
502
|
|
498
503
|
expect(a_request(:put, queries)).not_to have_been_made
|
499
504
|
end
|
500
505
|
|
501
506
|
it "returns a rejected promise" do
|
502
|
-
promise =
|
507
|
+
promise = perf_notifier.notify(
|
503
508
|
Airbrake::Query.new(
|
504
509
|
method: 'POST',
|
505
510
|
route: '/foo',
|
@@ -507,7 +512,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
507
512
|
timing: 1,
|
508
513
|
),
|
509
514
|
)
|
510
|
-
|
515
|
+
perf_notifier.close
|
511
516
|
|
512
517
|
expect(promise.value).to eq(
|
513
518
|
'error' => 'Airbrake::Query was ignored by a filter',
|
@@ -517,13 +522,13 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
517
522
|
|
518
523
|
context "when a filter that modifies payload was defined" do
|
519
524
|
before do
|
520
|
-
|
521
|
-
|
525
|
+
perf_notifier.add_filter do |metric|
|
526
|
+
metric.route = '[Filtered]'
|
522
527
|
end
|
523
528
|
end
|
524
529
|
|
525
530
|
it "notifies airbrake with modified payload" do
|
526
|
-
|
531
|
+
perf_notifier.notify(
|
527
532
|
Airbrake::Query.new(
|
528
533
|
method: 'POST',
|
529
534
|
route: '/foo',
|
@@ -531,7 +536,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
531
536
|
timing: 123,
|
532
537
|
),
|
533
538
|
)
|
534
|
-
|
539
|
+
perf_notifier.close
|
535
540
|
|
536
541
|
expect(
|
537
542
|
a_request(:put, queries).with(
|
@@ -541,44 +546,19 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
541
546
|
end
|
542
547
|
end
|
543
548
|
|
544
|
-
context "when :start_time is specified (deprecated)" do
|
545
|
-
before do
|
546
|
-
allow(Kernel).to receive(:warn)
|
547
|
-
end
|
548
|
-
|
549
|
-
it "uses the value of :start_time to update stat" do
|
550
|
-
subject.notify(
|
551
|
-
Airbrake::Query.new(
|
552
|
-
method: 'POST',
|
553
|
-
route: '/foo',
|
554
|
-
query: 'SELECT * FROM things',
|
555
|
-
start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
|
556
|
-
end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
|
557
|
-
),
|
558
|
-
)
|
559
|
-
subject.close
|
560
|
-
|
561
|
-
expect(
|
562
|
-
a_request(:put, queries).with(
|
563
|
-
body: /"count":1,"sum":60000.0,"sumsq":3600000000.0/,
|
564
|
-
),
|
565
|
-
).to have_been_made
|
566
|
-
end
|
567
|
-
end
|
568
|
-
|
569
549
|
context "when provided :timing is zero" do
|
570
550
|
it "doesn't notify" do
|
571
551
|
queue = Airbrake::Queue.new(queue: 'bananas', error_count: 0, timing: 0)
|
572
|
-
|
573
|
-
|
552
|
+
perf_notifier.notify(queue)
|
553
|
+
perf_notifier.close
|
574
554
|
|
575
555
|
expect(a_request(:put, queues)).not_to have_been_made
|
576
556
|
end
|
577
557
|
|
578
558
|
it "returns a rejected promise" do
|
579
559
|
queue = Airbrake::Queue.new(queue: 'bananas', error_count: 0, timing: 0)
|
580
|
-
promise =
|
581
|
-
|
560
|
+
promise = perf_notifier.notify(queue)
|
561
|
+
perf_notifier.close
|
582
562
|
|
583
563
|
expect(promise.value).to eq('error' => ':timing cannot be zero')
|
584
564
|
end
|
@@ -587,7 +567,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
587
567
|
|
588
568
|
describe "#notify_sync" do
|
589
569
|
it "notifies synchronously" do
|
590
|
-
retval =
|
570
|
+
retval = perf_notifier.notify_sync(
|
591
571
|
Airbrake::Query.new(
|
592
572
|
method: 'POST',
|
593
573
|
route: '/foo',
|
@@ -616,7 +596,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
616
596
|
|
617
597
|
it "kills the background thread" do
|
618
598
|
expect_any_instance_of(Thread).to receive(:kill).and_call_original
|
619
|
-
|
599
|
+
perf_notifier.notify(
|
620
600
|
Airbrake::Query.new(
|
621
601
|
method: 'POST',
|
622
602
|
route: '/foo',
|
@@ -624,30 +604,32 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
624
604
|
timing: 123,
|
625
605
|
),
|
626
606
|
)
|
627
|
-
|
607
|
+
perf_notifier.close
|
628
608
|
end
|
629
609
|
|
630
610
|
it "logs the exit message" do
|
631
611
|
allow(Airbrake::Loggable.instance).to receive(:debug)
|
632
|
-
|
633
|
-
|
612
|
+
|
613
|
+
perf_notifier.close
|
614
|
+
|
615
|
+
expect(Airbrake::Loggable.instance).to have_received(:debug).with(
|
616
|
+
/Airbrake::PerformanceNotifier thread pool closed/,
|
634
617
|
)
|
635
|
-
subject.close
|
636
618
|
end
|
637
619
|
end
|
638
620
|
|
639
621
|
describe "#delete_filter" do
|
640
622
|
let(:filter) do
|
641
623
|
Class.new do
|
642
|
-
def call(
|
624
|
+
def call(metric); end
|
643
625
|
end
|
644
626
|
end
|
645
627
|
|
646
|
-
before {
|
628
|
+
before { perf_notifier.add_filter(filter.new) }
|
647
629
|
|
648
630
|
it "deletes a filter" do
|
649
|
-
|
650
|
-
|
631
|
+
perf_notifier.delete_filter(filter)
|
632
|
+
perf_notifier.notify(
|
651
633
|
Airbrake::Request.new(
|
652
634
|
method: 'POST',
|
653
635
|
route: '/foo',
|
@@ -655,7 +637,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
655
637
|
timing: 123,
|
656
638
|
),
|
657
639
|
)
|
658
|
-
|
640
|
+
perf_notifier.close
|
659
641
|
|
660
642
|
expect(a_request(:put, routes)).to have_been_made
|
661
643
|
end
|