airbrake-ruby 5.2.0 → 5.2.1
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.rb +3 -2
- data/lib/airbrake-ruby/async_sender.rb +3 -1
- data/lib/airbrake-ruby/context.rb +51 -0
- data/lib/airbrake-ruby/filter_chain.rb +2 -0
- data/lib/airbrake-ruby/filters/context_filter.rb +4 -5
- data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/keys_filter.rb +2 -2
- data/lib/airbrake-ruby/filters/sql_filter.rb +2 -2
- data/lib/airbrake-ruby/filters/thread_filter.rb +1 -1
- data/lib/airbrake-ruby/ignorable.rb +0 -2
- data/lib/airbrake-ruby/notice_notifier.rb +3 -4
- data/lib/airbrake-ruby/performance_notifier.rb +1 -2
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +1 -1
- data/lib/airbrake-ruby/tdigest.rb +7 -6
- data/lib/airbrake-ruby/thread_pool.rb +5 -3
- data/lib/airbrake-ruby/timed_trace.rb +1 -3
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +139 -76
- data/spec/async_sender_spec.rb +10 -8
- data/spec/backtrace_spec.rb +13 -10
- data/spec/benchmark_spec.rb +5 -3
- data/spec/code_hunk_spec.rb +24 -15
- data/spec/config/processor_spec.rb +12 -4
- data/spec/config/validator_spec.rb +5 -2
- data/spec/config_spec.rb +24 -16
- 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 +5 -2
- data/spec/filters/git_last_checkout_filter_spec.rb +10 -12
- data/spec/filters/git_repository_filter.rb +9 -9
- data/spec/filters/git_revision_filter_spec.rb +19 -19
- data/spec/filters/keys_allowlist_spec.rb +25 -16
- data/spec/filters/keys_blocklist_spec.rb +25 -18
- data/spec/filters/root_directory_filter_spec.rb +3 -3
- data/spec/filters/sql_filter_spec.rb +26 -26
- data/spec/filters/system_exit_filter_spec.rb +4 -2
- data/spec/filters/thread_filter_spec.rb +15 -13
- 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 +23 -13
- data/spec/notice_notifier_spec.rb +52 -47
- data/spec/notice_spec.rb +6 -2
- data/spec/performance_notifier_spec.rb +67 -60
- data/spec/promise_spec.rb +38 -32
- data/spec/remote_settings/callback_spec.rb +27 -8
- data/spec/remote_settings/settings_data_spec.rb +4 -4
- data/spec/remote_settings_spec.rb +18 -8
- data/spec/response_spec.rb +34 -12
- data/spec/stashable_spec.rb +5 -5
- data/spec/stat_spec.rb +7 -5
- data/spec/sync_sender_spec.rb +49 -16
- data/spec/tdigest_spec.rb +60 -55
- data/spec/thread_pool_spec.rb +65 -55
- data/spec/time_truncate_spec.rb +4 -2
- data/spec/timed_trace_spec.rb +32 -30
- data/spec/truncator_spec.rb +72 -43
- metadata +51 -48
data/spec/notice_spec.rb
CHANGED
@@ -85,7 +85,7 @@ RSpec.describe Airbrake::Notice do
|
|
85
85
|
|
86
86
|
context "when truncation failed" do
|
87
87
|
it "returns nil" do
|
88
|
-
|
88
|
+
allow_any_instance_of(Airbrake::Truncator)
|
89
89
|
.to receive(:reduce_max_size).and_return(0)
|
90
90
|
|
91
91
|
encoded = Base64.encode64("\xD3\xE6\xBC\x9D\xBA").encode!('ASCII-8BIT')
|
@@ -103,7 +103,7 @@ RSpec.describe Airbrake::Notice do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
describe "object replacement with its string version" do
|
106
|
-
let(:klass) { Class.new
|
106
|
+
let(:klass) { Class.new }
|
107
107
|
let(:ex) { AirbrakeTestError.new }
|
108
108
|
let(:params) { { bingo: [Object.new, klass.new] } }
|
109
109
|
let(:notice) { described_class.new(ex, params) }
|
@@ -152,6 +152,7 @@ RSpec.describe Airbrake::Notice do
|
|
152
152
|
# serialize them.
|
153
153
|
#
|
154
154
|
# @see https://goo.gl/0A3xNC
|
155
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
|
155
156
|
class ObjectWithIoIvars
|
156
157
|
def initialize
|
157
158
|
@bongo = Tempfile.new('bongo').tap(&:close)
|
@@ -162,8 +163,10 @@ RSpec.describe Airbrake::Notice do
|
|
162
163
|
raise NotImplementedError
|
163
164
|
end
|
164
165
|
end
|
166
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
|
165
167
|
|
166
168
|
# @see ObjectWithIoIvars
|
169
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
|
167
170
|
class ObjectWithNestedIoIvars
|
168
171
|
def initialize
|
169
172
|
@bish = ObjectWithIoIvars.new
|
@@ -174,6 +177,7 @@ RSpec.describe Airbrake::Notice do
|
|
174
177
|
raise NotImplementedError
|
175
178
|
end
|
176
179
|
end
|
180
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
|
177
181
|
|
178
182
|
context "and also when it's a closed Tempfile" do
|
179
183
|
it "doesn't fail" do
|
@@ -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
|
-
|
525
|
+
perf_notifier.add_filter do |resource|
|
521
526
|
resource.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(
|
@@ -544,16 +549,16 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
544
549
|
context "when provided :timing is zero" do
|
545
550
|
it "doesn't notify" do
|
546
551
|
queue = Airbrake::Queue.new(queue: 'bananas', error_count: 0, timing: 0)
|
547
|
-
|
548
|
-
|
552
|
+
perf_notifier.notify(queue)
|
553
|
+
perf_notifier.close
|
549
554
|
|
550
555
|
expect(a_request(:put, queues)).not_to have_been_made
|
551
556
|
end
|
552
557
|
|
553
558
|
it "returns a rejected promise" do
|
554
559
|
queue = Airbrake::Queue.new(queue: 'bananas', error_count: 0, timing: 0)
|
555
|
-
promise =
|
556
|
-
|
560
|
+
promise = perf_notifier.notify(queue)
|
561
|
+
perf_notifier.close
|
557
562
|
|
558
563
|
expect(promise.value).to eq('error' => ':timing cannot be zero')
|
559
564
|
end
|
@@ -562,7 +567,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
562
567
|
|
563
568
|
describe "#notify_sync" do
|
564
569
|
it "notifies synchronously" do
|
565
|
-
retval =
|
570
|
+
retval = perf_notifier.notify_sync(
|
566
571
|
Airbrake::Query.new(
|
567
572
|
method: 'POST',
|
568
573
|
route: '/foo',
|
@@ -591,7 +596,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
591
596
|
|
592
597
|
it "kills the background thread" do
|
593
598
|
expect_any_instance_of(Thread).to receive(:kill).and_call_original
|
594
|
-
|
599
|
+
perf_notifier.notify(
|
595
600
|
Airbrake::Query.new(
|
596
601
|
method: 'POST',
|
597
602
|
route: '/foo',
|
@@ -599,15 +604,17 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
599
604
|
timing: 123,
|
600
605
|
),
|
601
606
|
)
|
602
|
-
|
607
|
+
perf_notifier.close
|
603
608
|
end
|
604
609
|
|
605
610
|
it "logs the exit message" do
|
606
611
|
allow(Airbrake::Loggable.instance).to receive(:debug)
|
607
|
-
|
608
|
-
|
612
|
+
|
613
|
+
perf_notifier.close
|
614
|
+
|
615
|
+
expect(Airbrake::Loggable.instance).to have_received(:debug).with(
|
616
|
+
/Airbrake::PerformanceNotifier thread pool closed/,
|
609
617
|
)
|
610
|
-
subject.close
|
611
618
|
end
|
612
619
|
end
|
613
620
|
|
@@ -618,11 +625,11 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
618
625
|
end
|
619
626
|
end
|
620
627
|
|
621
|
-
before {
|
628
|
+
before { perf_notifier.add_filter(filter.new) }
|
622
629
|
|
623
630
|
it "deletes a filter" do
|
624
|
-
|
625
|
-
|
631
|
+
perf_notifier.delete_filter(filter)
|
632
|
+
perf_notifier.notify(
|
626
633
|
Airbrake::Request.new(
|
627
634
|
method: 'POST',
|
628
635
|
route: '/foo',
|
@@ -630,7 +637,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
630
637
|
timing: 123,
|
631
638
|
),
|
632
639
|
)
|
633
|
-
|
640
|
+
perf_notifier.close
|
634
641
|
|
635
642
|
expect(a_request(:put, routes)).to have_been_made
|
636
643
|
end
|