airbrake-ruby 4.9.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake-ruby.rb +55 -6
  3. data/lib/airbrake-ruby/async_sender.rb +3 -3
  4. data/lib/airbrake-ruby/backtrace.rb +2 -2
  5. data/lib/airbrake-ruby/code_hunk.rb +1 -1
  6. data/lib/airbrake-ruby/config.rb +1 -1
  7. data/lib/airbrake-ruby/config/validator.rb +3 -3
  8. data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
  9. data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +2 -2
  10. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +2 -2
  11. data/lib/airbrake-ruby/filters/keys_filter.rb +1 -1
  12. data/lib/airbrake-ruby/filters/sql_filter.rb +3 -3
  13. data/lib/airbrake-ruby/filters/thread_filter.rb +1 -1
  14. data/lib/airbrake-ruby/inspectable.rb +2 -2
  15. data/lib/airbrake-ruby/notice.rb +7 -7
  16. data/lib/airbrake-ruby/notice_notifier.rb +1 -1
  17. data/lib/airbrake-ruby/performance_breakdown.rb +1 -1
  18. data/lib/airbrake-ruby/performance_notifier.rb +36 -20
  19. data/lib/airbrake-ruby/query.rb +1 -1
  20. data/lib/airbrake-ruby/queue.rb +2 -2
  21. data/lib/airbrake-ruby/request.rb +1 -1
  22. data/lib/airbrake-ruby/stat.rb +1 -1
  23. data/lib/airbrake-ruby/version.rb +1 -1
  24. data/spec/airbrake_spec.rb +107 -48
  25. data/spec/async_sender_spec.rb +4 -4
  26. data/spec/backtrace_spec.rb +18 -18
  27. data/spec/code_hunk_spec.rb +9 -9
  28. data/spec/config/validator_spec.rb +5 -5
  29. data/spec/config_spec.rb +5 -5
  30. data/spec/deploy_notifier_spec.rb +2 -2
  31. data/spec/filter_chain_spec.rb +1 -1
  32. data/spec/filters/dependency_filter_spec.rb +1 -1
  33. data/spec/filters/gem_root_filter_spec.rb +5 -5
  34. data/spec/filters/git_last_checkout_filter_spec.rb +1 -1
  35. data/spec/filters/git_repository_filter.rb +1 -1
  36. data/spec/filters/git_revision_filter_spec.rb +10 -10
  37. data/spec/filters/keys_blacklist_spec.rb +22 -22
  38. data/spec/filters/keys_whitelist_spec.rb +21 -21
  39. data/spec/filters/root_directory_filter_spec.rb +5 -5
  40. data/spec/filters/sql_filter_spec.rb +53 -53
  41. data/spec/filters/system_exit_filter_spec.rb +1 -1
  42. data/spec/filters/thread_filter_spec.rb +28 -28
  43. data/spec/fixtures/project_root/code.rb +9 -9
  44. data/spec/notice_notifier/options_spec.rb +12 -12
  45. data/spec/notice_notifier_spec.rb +17 -17
  46. data/spec/notice_spec.rb +5 -5
  47. data/spec/performance_notifier_spec.rb +88 -68
  48. data/spec/query_spec.rb +1 -1
  49. data/spec/request_spec.rb +1 -1
  50. data/spec/response_spec.rb +8 -8
  51. data/spec/spec_helper.rb +2 -2
  52. data/spec/stat_spec.rb +2 -2
  53. data/spec/sync_sender_spec.rb +12 -12
  54. data/spec/tdigest_spec.rb +6 -6
  55. data/spec/thread_pool_spec.rb +5 -5
  56. data/spec/timed_trace_spec.rb +1 -1
  57. data/spec/truncator_spec.rb +12 -12
  58. metadata +2 -120
@@ -15,7 +15,7 @@ RSpec.describe Airbrake::NoticeNotifier do
15
15
 
16
16
  Airbrake::Config.instance = Airbrake::Config.new(
17
17
  project_id: project_id,
18
- project_key: project_key
18
+ project_key: project_key,
19
19
  )
20
20
  end
21
21
 
@@ -64,7 +64,7 @@ RSpec.describe Airbrake::NoticeNotifier do
64
64
  describe ":root_directory" do
65
65
  before do
66
66
  subject.add_filter(
67
- Airbrake::Filters::RootDirectoryFilter.new('/home/kyrylo/code')
67
+ Airbrake::Filters::RootDirectoryFilter.new('/home/kyrylo/code'),
68
68
  )
69
69
  end
70
70
 
@@ -73,7 +73,7 @@ RSpec.describe Airbrake::NoticeNotifier do
73
73
 
74
74
  expect(
75
75
  a_request(:post, endpoint)
76
- .with(body: %r|{"file":"/PROJECT_ROOT/airbrake/ruby/spec/airbrake_spec.+|)
76
+ .with(body: %r|{"file":"/PROJECT_ROOT/airbrake/ruby/spec/airbrake_spec.+|),
77
77
  ).to have_been_made.once
78
78
  end
79
79
 
@@ -85,7 +85,7 @@ RSpec.describe Airbrake::NoticeNotifier do
85
85
  subject.notify_sync(ex)
86
86
  expect(
87
87
  a_request(:post, endpoint)
88
- .with(body: %r{"rootDirectory":"/bingo/bango"})
88
+ .with(body: %r{"rootDirectory":"/bingo/bango"}),
89
89
  ).to have_been_made.once
90
90
  end
91
91
  end
@@ -105,7 +105,7 @@ RSpec.describe Airbrake::NoticeNotifier do
105
105
  WEBrick::HTTPServer.new(
106
106
  Port: 0,
107
107
  Logger: WEBrick::Log.new('/dev/null'),
108
- AccessLog: []
108
+ AccessLog: [],
109
109
  )
110
110
  end
111
111
 
@@ -121,7 +121,7 @@ RSpec.describe Airbrake::NoticeNotifier do
121
121
  before do
122
122
  Airbrake::Config.instance.merge(
123
123
  proxy: proxy_params,
124
- host: "http://localhost:#{proxy.config[:Port]}"
124
+ host: "http://localhost:#{proxy.config[:Port]}",
125
125
  )
126
126
 
127
127
  proxy.mount_proc '/' do |req, res|
@@ -139,7 +139,7 @@ RSpec.describe Airbrake::NoticeNotifier do
139
139
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
140
140
  skip(
141
141
  "We use Webmock 2, which doesn't support Ruby 2.6+. It's " \
142
- "safe to run this test on 2.6+ once we upgrade to Webmock 3.5+"
142
+ "safe to run this test on 2.6+ once we upgrade to Webmock 3.5+",
143
143
  )
144
144
  end
145
145
  subject.notify_sync(ex)
@@ -164,7 +164,7 @@ RSpec.describe Airbrake::NoticeNotifier do
164
164
  subject.notify_sync(ex)
165
165
  expect(
166
166
  a_request(:post, endpoint)
167
- .with(body: /"context":{.*"environment":"production".*}/)
167
+ .with(body: /"context":{.*"environment":"production".*}/),
168
168
  ).to have_been_made.once
169
169
  end
170
170
  end
@@ -192,7 +192,7 @@ RSpec.describe Airbrake::NoticeNotifier do
192
192
  context "when env is set and ignore_environments doesn't mention it" do
193
193
  params = {
194
194
  environment: :development,
195
- ignore_environments: [:production]
195
+ ignore_environments: [:production],
196
196
  }
197
197
 
198
198
  include_examples 'sent notice', params
@@ -201,7 +201,7 @@ RSpec.describe Airbrake::NoticeNotifier do
201
201
  context "when the current env and notify envs are the same" do
202
202
  params = {
203
203
  environment: :development,
204
- ignore_environments: %i[production development]
204
+ ignore_environments: %i[production development],
205
205
  }
206
206
 
207
207
  include_examples 'ignored notice', params
@@ -227,7 +227,7 @@ RSpec.describe Airbrake::NoticeNotifier do
227
227
  context "when ignore_environments specifies a Regexp pattern" do
228
228
  params = {
229
229
  environment: :testing,
230
- ignore_environments: ['staging', /test.+/]
230
+ ignore_environments: ['staging', /test.+/],
231
231
  }
232
232
 
233
233
  include_examples 'ignored notice', params
@@ -241,7 +241,7 @@ RSpec.describe Airbrake::NoticeNotifier do
241
241
  before do
242
242
  Airbrake::Config.instance.merge(
243
243
  blacklist_keys: %i[password password_confirmation],
244
- whitelist_keys: [:email, /user/i, 'account_id']
244
+ whitelist_keys: [:email, /user/i, 'account_id'],
245
245
  )
246
246
  end
247
247
 
@@ -4,7 +4,7 @@ RSpec.describe Airbrake::NoticeNotifier do
4
4
  project_id: 1,
5
5
  project_key: 'abc',
6
6
  logger: Logger.new('/dev/null'),
7
- performance_stats: true
7
+ performance_stats: true,
8
8
  )
9
9
  end
10
10
 
@@ -32,7 +32,7 @@ RSpec.describe Airbrake::NoticeNotifier do
32
32
  let(:body) do
33
33
  {
34
34
  'id' => '00054414-b147-6ffa-85d6-1524d83362a6',
35
- 'url' => 'http://localhost/locate/00054414-b147-6ffa-85d6-1524d83362a6'
35
+ 'url' => 'http://localhost/locate/00054414-b147-6ffa-85d6-1524d83362a6',
36
36
  }.to_json
37
37
  end
38
38
 
@@ -110,7 +110,7 @@ RSpec.describe Airbrake::NoticeNotifier do
110
110
  before do
111
111
  Airbrake::Config.instance.merge(
112
112
  environment: 'test',
113
- ignore_environments: %w[test]
113
+ ignore_environments: %w[test],
114
114
  )
115
115
  end
116
116
 
@@ -132,7 +132,7 @@ RSpec.describe Airbrake::NoticeNotifier do
132
132
  let(:body) do
133
133
  {
134
134
  'id' => '00054414-b147-6ffa-85d6-1524d83362a6',
135
- 'url' => 'http://localhost/locate/00054414-b147-6ffa-85d6-1524d83362a6'
135
+ 'url' => 'http://localhost/locate/00054414-b147-6ffa-85d6-1524d83362a6',
136
136
  }
137
137
  end
138
138
 
@@ -153,8 +153,8 @@ RSpec.describe Airbrake::NoticeNotifier do
153
153
  subject.notify_sync('foo', bingo: 'bango')
154
154
  expect(
155
155
  a_request(:post, endpoint).with(
156
- body: /"params":{.*"bingo":"bango".*}/
157
- )
156
+ body: /"params":{.*"bingo":"bango".*}/,
157
+ ),
158
158
  ).to have_been_made.once
159
159
  end
160
160
 
@@ -190,7 +190,7 @@ RSpec.describe Airbrake::NoticeNotifier do
190
190
  context "when the provided environment is ignored" do
191
191
  before do
192
192
  Airbrake::Config.instance.merge(
193
- environment: 'test', ignore_environments: %w[test]
193
+ environment: 'test', ignore_environments: %w[test],
194
194
  )
195
195
  end
196
196
 
@@ -256,7 +256,7 @@ RSpec.describe Airbrake::NoticeNotifier do
256
256
  it "returns the full generated backtrace" do
257
257
  backtrace = [
258
258
  "/lib/airbrake-ruby/a.rb:84:in `build_notice'",
259
- "/lib/airbrake-ruby/b.rb:124:in `send_notice'"
259
+ "/lib/airbrake-ruby/b.rb:124:in `send_notice'",
260
260
  ]
261
261
  allow(Kernel).to receive(:caller).and_return(backtrace)
262
262
 
@@ -265,8 +265,8 @@ RSpec.describe Airbrake::NoticeNotifier do
265
265
  expect(notice[:errors].first[:backtrace]).to eq(
266
266
  [
267
267
  { file: '/lib/airbrake-ruby/a.rb', line: 84, function: 'build_notice' },
268
- { file: '/lib/airbrake-ruby/b.rb', line: 124, function: 'send_notice' }
269
- ]
268
+ { file: '/lib/airbrake-ruby/b.rb', line: 124, function: 'send_notice' },
269
+ ],
270
270
  )
271
271
  end
272
272
  end
@@ -276,7 +276,7 @@ RSpec.describe Airbrake::NoticeNotifier do
276
276
  backtrace = [
277
277
  "/airbrake-ruby/lib/airbrake-ruby/a.rb:84:in `b'",
278
278
  "/airbrake-ruby/lib/foo/b.rb:84:in `build'",
279
- "/airbrake-ruby/lib/bar/c.rb:124:in `send'"
279
+ "/airbrake-ruby/lib/bar/c.rb:124:in `send'",
280
280
  ]
281
281
  allow(Kernel).to receive(:caller).and_return(backtrace)
282
282
 
@@ -285,8 +285,8 @@ RSpec.describe Airbrake::NoticeNotifier do
285
285
  expect(notice[:errors].first[:backtrace]).to eq(
286
286
  [
287
287
  { file: '/airbrake-ruby/lib/foo/b.rb', line: 84, function: 'build' },
288
- { file: '/airbrake-ruby/lib/bar/c.rb', line: 124, function: 'send' }
289
- ]
288
+ { file: '/airbrake-ruby/lib/bar/c.rb', line: 124, function: 'send' },
289
+ ],
290
290
  )
291
291
  end
292
292
  end
@@ -303,7 +303,7 @@ RSpec.describe Airbrake::NoticeNotifier do
303
303
  backtrace = [
304
304
  "org/jruby/RubyKernel.java:998:in `eval'",
305
305
  "/ruby/stdlib/irb/workspace.rb:87:in `evaluate'",
306
- "/ruby/stdlib/irb.rb:489:in `block in eval_input'"
306
+ "/ruby/stdlib/irb.rb:489:in `block in eval_input'",
307
307
  ]
308
308
  allow(Kernel).to receive(:caller).and_return(backtrace)
309
309
 
@@ -314,8 +314,8 @@ RSpec.describe Airbrake::NoticeNotifier do
314
314
  [
315
315
  { file: 'org/jruby/RubyKernel.java', line: 998, function: 'eval' },
316
316
  { file: '/ruby/stdlib/irb/workspace.rb', line: 87, function: 'evaluate' },
317
- { file: '/ruby/stdlib/irb.rb:489', line: 489, function: 'block in eval_input' }
318
- ]
317
+ { file: '/ruby/stdlib/irb.rb:489', line: 489, function: 'block in eval_input' },
318
+ ],
319
319
  )
320
320
  # rubocop:enable Metrics/LineLength
321
321
  end
@@ -330,7 +330,7 @@ RSpec.describe Airbrake::NoticeNotifier do
330
330
  it "raises error" do
331
331
  expect { subject.build_notice(Exception.new) }.to raise_error(
332
332
  Airbrake::Error,
333
- 'attempted to build Exception with closed Airbrake instance'
333
+ 'attempted to build Exception with closed Airbrake instance',
334
334
  )
335
335
  end
336
336
  end
@@ -17,7 +17,7 @@ RSpec.describe Airbrake::Notice do
17
17
  before do
18
18
  Airbrake::Config.instance.merge(
19
19
  app_version: "1.2.3",
20
- root_directory: "/one/two"
20
+ root_directory: "/one/two",
21
21
  )
22
22
  end
23
23
 
@@ -34,7 +34,7 @@ RSpec.describe Airbrake::Notice do
34
34
  context "when versions is empty" do
35
35
  it "doesn't set the 'versions' payload" do
36
36
  expect(notice.to_json).not_to match(
37
- /"context":{"versions":{"dep":"1.2.3"}}/
37
+ /"context":{"versions":{"dep":"1.2.3"}}/,
38
38
  )
39
39
  end
40
40
  end
@@ -43,7 +43,7 @@ RSpec.describe Airbrake::Notice do
43
43
  it "sets the 'versions' payload" do
44
44
  notice[:context][:versions] = { 'dep' => '1.2.3' }
45
45
  expect(notice.to_json).to match(
46
- /"context":{.*"versions":{"dep":"1.2.3"}.*}/
46
+ /"context":{.*"versions":{"dep":"1.2.3"}.*}/,
47
47
  )
48
48
  end
49
49
  end
@@ -192,7 +192,7 @@ RSpec.describe Airbrake::Notice do
192
192
  it "doesn't fail" do
193
193
  notice[:params] = { a: { b: { c: ObjectWithIoIvars.new } } }
194
194
  expect(notice.to_json).to match(
195
- /"params":{"a":{"b":{"c":".+ObjectWithIoIvars.+"}}.*}/
195
+ /"params":{"a":{"b":{"c":".+ObjectWithIoIvars.+"}}.*}/,
196
196
  )
197
197
  end
198
198
  end
@@ -201,7 +201,7 @@ RSpec.describe Airbrake::Notice do
201
201
  it "doesn't fail" do
202
202
  notice[:params] = { a: [[ObjectWithIoIvars.new]] }
203
203
  expect(notice.to_json).to match(
204
- /"params":{"a":\[\[".+ObjectWithIoIvars.+"\]\].*}/
204
+ /"params":{"a":\[\[".+ObjectWithIoIvars.+"\]\].*}/,
205
205
  )
206
206
  end
207
207
  end
@@ -15,7 +15,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
15
15
  project_key: 'banana',
16
16
  performance_stats: true,
17
17
  performance_stats_flush_period: 0,
18
- query_stats: true
18
+ query_stats: true,
19
19
  )
20
20
  end
21
21
 
@@ -30,8 +30,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
30
30
  file: 'foo.rb',
31
31
  line: 123,
32
32
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
33
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
34
- )
33
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
34
+ ),
35
35
  )
36
36
  subject.close
37
37
 
@@ -49,7 +49,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
49
49
  "sum":60000.0,
50
50
  "sumsq":3600000000.0,
51
51
  "tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"
52
- }\]}\z|x)
52
+ }\]}\z|x),
53
53
  ).to have_been_made
54
54
  end
55
55
 
@@ -60,8 +60,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
60
60
  route: '/foo',
61
61
  status_code: 200,
62
62
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
63
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
64
- )
63
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
64
+ ),
65
65
  )
66
66
  subject.close
67
67
 
@@ -76,7 +76,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
76
76
  "sum":60000.0,
77
77
  "sumsq":3600000000.0,
78
78
  "tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"
79
- }\]}\z|x)
79
+ }\]}\z|x),
80
80
  ).to have_been_made
81
81
  end
82
82
 
@@ -88,8 +88,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
88
88
  response_type: 'json',
89
89
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
90
90
  end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
91
- groups: { db: 131, view: 421 }
92
- )
91
+ groups: { db: 131, view: 421 },
92
+ ),
93
93
  )
94
94
  subject.close
95
95
 
@@ -118,7 +118,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
118
118
  "tdigest":"AAAAAkA0AAAAAAAAAAAAAUPSgAAB"
119
119
  }
120
120
  }
121
- }\]}\z|x)
121
+ }\]}\z|x),
122
122
  ).to have_been_made
123
123
  end
124
124
 
@@ -129,8 +129,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
129
129
  error_count: 2,
130
130
  groups: { redis: 131, sql: 421 },
131
131
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
132
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
133
- )
132
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
133
+ ),
134
134
  )
135
135
  subject.close
136
136
 
@@ -158,7 +158,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
158
158
  "tdigest":"AAAAAkA0AAAAAAAAAAAAAUPSgAAB"
159
159
  }
160
160
  }
161
- }\]}\z/x)
161
+ }\]}\z/x),
162
162
  ).to have_been_made
163
163
  end
164
164
 
@@ -168,13 +168,13 @@ RSpec.describe Airbrake::PerformanceNotifier do
168
168
  method: 'GET',
169
169
  route: '/foo',
170
170
  status_code: 200,
171
- start_time: Time.new(2018, 1, 1, 0, 0, 20, 0)
172
- )
171
+ start_time: Time.new(2018, 1, 1, 0, 0, 20, 0),
172
+ ),
173
173
  )
174
174
  subject.close
175
175
 
176
176
  expect(
177
- a_request(:put, routes).with(body: /"time":"2018-01-01T00:00:00\+00:00"/)
177
+ a_request(:put, routes).with(body: /"time":"2018-01-01T00:00:00\+00:00"/),
178
178
  ).to have_been_made
179
179
  end
180
180
 
@@ -184,21 +184,21 @@ RSpec.describe Airbrake::PerformanceNotifier do
184
184
  method: 'GET',
185
185
  route: '/foo',
186
186
  status_code: 200,
187
- start_time: Time.new(2018, 1, 1, 0, 0, 20, 0)
188
- )
187
+ start_time: Time.new(2018, 1, 1, 0, 0, 20, 0),
188
+ ),
189
189
  )
190
190
  subject.notify(
191
191
  Airbrake::Request.new(
192
192
  method: 'GET',
193
193
  route: '/foo',
194
194
  status_code: 200,
195
- start_time: Time.new(2018, 1, 1, 0, 0, 50, 0)
196
- )
195
+ start_time: Time.new(2018, 1, 1, 0, 0, 50, 0),
196
+ ),
197
197
  )
198
198
  subject.close
199
199
 
200
200
  expect(
201
- a_request(:put, routes).with(body: /"count":2/)
201
+ a_request(:put, routes).with(body: /"count":2/),
202
202
  ).to have_been_made
203
203
  end
204
204
 
@@ -209,8 +209,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
209
209
  route: '/foo',
210
210
  status_code: 200,
211
211
  start_time: Time.new(2018, 1, 1, 0, 0, 49, 0),
212
- end_time: Time.new(2018, 1, 1, 0, 0, 50, 0)
213
- )
212
+ end_time: Time.new(2018, 1, 1, 0, 0, 50, 0),
213
+ ),
214
214
  )
215
215
  subject.notify(
216
216
  Airbrake::Request.new(
@@ -218,8 +218,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
218
218
  route: '/foo',
219
219
  status_code: 200,
220
220
  start_time: Time.new(2018, 1, 1, 0, 1, 49, 0),
221
- end_time: Time.new(2018, 1, 1, 0, 1, 55, 0)
222
- )
221
+ end_time: Time.new(2018, 1, 1, 0, 1, 55, 0),
222
+ ),
223
223
  )
224
224
  subject.close
225
225
 
@@ -233,8 +233,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
233
233
  {"method":"GET","route":"/foo","statusCode":200,
234
234
  "time":"2018-01-01T00:01:00\+00:00","count":1,"sum":6000.0,
235
235
  "sumsq":36000000.0,"tdigest":"AAAAAkA0AAAAAAAAAAAAAUW7gAAB"}\]}
236
- \z|x
237
- )
236
+ \z|x,
237
+ ),
238
238
  ).to have_been_made
239
239
  end
240
240
 
@@ -245,8 +245,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
245
245
  route: '/foo',
246
246
  status_code: 200,
247
247
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
248
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
249
- )
248
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
249
+ ),
250
250
  )
251
251
  subject.notify(
252
252
  Airbrake::Request.new(
@@ -254,8 +254,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
254
254
  route: '/foo',
255
255
  status_code: 200,
256
256
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
257
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
258
- )
257
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
258
+ ),
259
259
  )
260
260
  subject.close
261
261
 
@@ -269,8 +269,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
269
269
  {"method":"POST","route":"/foo","statusCode":200,
270
270
  "time":"2018-01-01T00:49:00\+00:00","count":1,"sum":60000.0,
271
271
  "sumsq":3600000000.0,"tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"}\]}
272
- \z|x
273
- )
272
+ \z|x,
273
+ ),
274
274
  ).to have_been_made
275
275
  end
276
276
 
@@ -282,8 +282,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
282
282
  response_type: 'json',
283
283
  start_time: Time.new(2018, 1, 1, 0, 0, 20, 0),
284
284
  end_time: Time.new(2018, 1, 1, 0, 0, 22, 0),
285
- groups: { db: 131, view: 421 }
286
- )
285
+ groups: { db: 131, view: 421 },
286
+ ),
287
287
  )
288
288
  subject.notify(
289
289
  Airbrake::PerformanceBreakdown.new(
@@ -292,8 +292,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
292
292
  response_type: 'json',
293
293
  start_time: Time.new(2018, 1, 1, 0, 0, 30, 0),
294
294
  end_time: Time.new(2018, 1, 1, 0, 0, 32, 0),
295
- groups: { db: 55, view: 11 }
296
- )
295
+ groups: { db: 55, view: 11 },
296
+ ),
297
297
  )
298
298
  subject.close
299
299
 
@@ -322,7 +322,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
322
322
  "tdigest":"AAAAAkA0AAAAAAAAAAAAAkEwAABDzQAAAQE="
323
323
  }
324
324
  }
325
- }\]}\z|x)
325
+ }\]}\z|x),
326
326
  ).to have_been_made
327
327
  end
328
328
 
@@ -333,8 +333,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
333
333
  error_count: 2,
334
334
  groups: { redis: 131, sql: 421 },
335
335
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
336
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
337
- )
336
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
337
+ ),
338
338
  )
339
339
  subject.notify(
340
340
  Airbrake::Queue.new(
@@ -342,8 +342,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
342
342
  error_count: 3,
343
343
  groups: { redis: 131, sql: 421 },
344
344
  start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
345
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
346
- )
345
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
346
+ ),
347
347
  )
348
348
  subject.close
349
349
 
@@ -371,7 +371,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
371
371
  "tdigest":"AAAAAkA0AAAAAAAAAAAAAUPSgAAC"
372
372
  }
373
373
  }
374
- }\]}\z/x)
374
+ }\]}\z/x),
375
375
  ).to have_been_made
376
376
  end
377
377
 
@@ -381,8 +381,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
381
381
  method: 'GET',
382
382
  route: '/foo',
383
383
  status_code: 200,
384
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
385
- )
384
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
385
+ ),
386
386
  )
387
387
  subject.close
388
388
 
@@ -392,7 +392,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
392
392
 
393
393
  it "checks performance stat configuration" do
394
394
  request = Airbrake::Request.new(
395
- method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
395
+ method: 'GET', route: '/foo', status_code: 200, start_time: Time.new,
396
396
  )
397
397
  expect(Airbrake::Config.instance).to receive(:check_performance_options)
398
398
  .with(request).and_return(Airbrake::Promise.new)
@@ -408,15 +408,15 @@ RSpec.describe Airbrake::PerformanceNotifier do
408
408
  method: 'POST',
409
409
  route: '/foo',
410
410
  status_code: 200,
411
- start_time: Time.new
412
- )
411
+ start_time: Time.new,
412
+ ),
413
413
  )
414
414
  subject.close
415
415
 
416
416
  expect(
417
417
  a_request(:put, routes).with(
418
- body: /\A{"routes":\[.+\],"environment":"test"}\z/x
419
- )
418
+ body: /\A{"routes":\[.+\],"environment":"test"}\z/x,
419
+ ),
420
420
  ).to have_been_made
421
421
  end
422
422
 
@@ -437,7 +437,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
437
437
  project_id: 1,
438
438
  project_key: 'banana',
439
439
  performance_stats: true,
440
- performance_stats_flush_period: flush_period
440
+ performance_stats_flush_period: flush_period,
441
441
  )
442
442
 
443
443
  subject.notify(
@@ -445,8 +445,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
445
445
  method: 'GET',
446
446
  route: '/foo',
447
447
  status_code: 200,
448
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
449
- )
448
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
449
+ ),
450
450
  )
451
451
 
452
452
  subject.notify(
@@ -454,8 +454,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
454
454
  method: 'POST',
455
455
  route: '/foo',
456
456
  query: 'SELECT * FROM things',
457
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
458
- )
457
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
458
+ ),
459
459
  )
460
460
 
461
461
  sleep(flush_period + 0.5)
@@ -474,8 +474,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
474
474
  method: 'GET',
475
475
  route: '/foo',
476
476
  status_code: 200,
477
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
478
- )
477
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
478
+ ),
479
479
  )
480
480
  subject.close
481
481
 
@@ -488,8 +488,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
488
488
  method: 'POST',
489
489
  route: '/foo',
490
490
  query: 'SELECT * FROM things',
491
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
492
- )
491
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
492
+ ),
493
493
  )
494
494
  subject.close
495
495
 
@@ -510,20 +510,40 @@ RSpec.describe Airbrake::PerformanceNotifier do
510
510
  method: 'POST',
511
511
  route: '/foo',
512
512
  query: 'SELECT * FROM things',
513
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
514
- )
513
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
514
+ ),
515
515
  )
516
516
  subject.close
517
517
 
518
518
  expect(
519
519
  a_request(:put, queries).with(
520
- body: /\A{"queries":\[{"method":"POST","route":"\[Filtered\]"/
521
- )
520
+ body: /\A{"queries":\[{"method":"POST","route":"\[Filtered\]"/,
521
+ ),
522
522
  ).to have_been_made
523
523
  end
524
524
  end
525
525
  end
526
526
 
527
+ describe "#notify_sync" do
528
+ it "notifies synchronously" do
529
+ retval = subject.notify_sync(
530
+ Airbrake::Query.new(
531
+ method: 'POST',
532
+ route: '/foo',
533
+ query: 'SELECT * FROM things',
534
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
535
+ ),
536
+ )
537
+
538
+ expect(
539
+ a_request(:put, queries).with(
540
+ body: %r|\A{"queries":\[{"method":"POST","route":"/foo"|,
541
+ ),
542
+ ).to have_been_made
543
+ expect(retval).to eq('' => nil)
544
+ end
545
+ end
546
+
527
547
  describe "#close" do
528
548
  before do
529
549
  Airbrake::Config.instance.merge(performance_stats_flush_period: 0.1)
@@ -540,8 +560,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
540
560
  method: 'POST',
541
561
  route: '/foo',
542
562
  query: 'SELECT * FROM things',
543
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
544
- )
563
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
564
+ ),
545
565
  )
546
566
  subject.close
547
567
  end
@@ -549,7 +569,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
549
569
  it "logs the exit message" do
550
570
  allow(Airbrake::Loggable.instance).to receive(:debug)
551
571
  expect(Airbrake::Loggable.instance).to receive(:debug).with(
552
- /performance notifier closed/
572
+ /performance notifier closed/,
553
573
  )
554
574
  subject.close
555
575
  end
@@ -571,8 +591,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
571
591
  method: 'POST',
572
592
  route: '/foo',
573
593
  status_code: 200,
574
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0)
575
- )
594
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
595
+ ),
576
596
  )
577
597
  subject.close
578
598