airbrake-ruby 4.10.1-java → 4.11.0-java

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 992c11be859d889822b3dd338b8f2befcbc91d7a91313fb28e14670d635408d2
4
- data.tar.gz: 343e472ce390b3882543423bdb8ee50a4cc311ff3907f557a553fa57631305d7
3
+ metadata.gz: 2583597d5f9ccbfe09e3d861ebdc75ca8258e24fb829e265501f10b084ac0c32
4
+ data.tar.gz: 2117a15ce8ee4de598ad3da47562614087c76765573e76b66d300fbb85f0a8ea
5
5
  SHA512:
6
- metadata.gz: 6636fa8d3a77792c4edc3ebd436d0e25b87ca628b820588850ab58a82cd3a5944bd7218bccea882bd0a0117d4ea042b576b54e14e06b7d472b0db05b20cf1666
7
- data.tar.gz: '079ac6ce90ab7b885561e7f17ab6d770630d59cbaa066664c2b0c2cabd4c28b2c594101863ef04b8e4a92e369ac5e9f3c886159f227eec370a485544cf035250'
6
+ metadata.gz: d519aacd0c4f2b16e31cf08a45c00db1290a8260e93f5eacc650b96dda8f42930876cd028e0ecc5cae94526d0caaaf0dcd453025b8b909a46e3b2d0f4995bbcf
7
+ data.tar.gz: cdf685b1acae7c8d94103561cf28597775638fb6d8e1a9635775fc3966d91006e46defdb0ac2ed4d917ad168b664ab2c9db1c2f3aab33fb87ec5ff8b929a906c
data/lib/airbrake-ruby.rb CHANGED
@@ -328,9 +328,8 @@ module Airbrake
328
328
  notice_notifier.merge_context(context)
329
329
  end
330
330
 
331
- # Increments request statistics of a certain +route+ that was invoked on
332
- # +start_time+ and ended on +end_time+ with +method+, and returned
333
- # +status_code+.
331
+ # Increments request statistics of a certain +route+ invoked with +method+,
332
+ # which returned +status_code+.
334
333
  #
335
334
  # After a certain amount of time (n seconds) the aggregated route
336
335
  # information will be sent to Airbrake.
@@ -343,8 +342,7 @@ module Airbrake
343
342
  # func: 'do_stuff',
344
343
  # file: 'app/models/foo.rb',
345
344
  # line: 452,
346
- # start_time: timestamp,
347
- # end_time: Time.now
345
+ # timing: 123.45 # ms
348
346
  # )
349
347
  #
350
348
  # @param [Hash{Symbol=>Object}] request_info
@@ -358,8 +356,8 @@ module Airbrake
358
356
  # called the query (optional)
359
357
  # @option request_info [Integer] :line The line that executes the query
360
358
  # (optional)
361
- # @option request_info [Date] :start_time When the request started
362
- # @option request_info [Time] :end_time When the request ended (optional)
359
+ # @option request_info [Float] :timing How much time it took to process the
360
+ # request (in ms)
363
361
  # @param [Hash] stash What needs to be appeneded to the stash, so it's
364
362
  # available in filters
365
363
  # @return [void]
@@ -371,9 +369,8 @@ module Airbrake
371
369
  performance_notifier.notify(request)
372
370
  end
373
371
 
374
- # Synchronously Increments request statistics of a certain +route+ that was
375
- # invoked on +start_time+ and ended on +end_time+ with +method+, and
376
- # returned +status_code+.
372
+ # Synchronously increments request statistics of a certain +route+ invoked
373
+ # with +method+, which returned +status_code+.
377
374
  # @since v4.10.0
378
375
  # @see .notify_request
379
376
  def notify_request_sync(request_info, stash = {})
@@ -382,9 +379,8 @@ module Airbrake
382
379
  performance_notifier.notify_sync(request)
383
380
  end
384
381
 
385
- # Increments SQL statistics of a certain +query+ that was invoked on
386
- # +start_time+ and finished on +end_time+. When +method+ and +route+ are
387
- # provided, the query is grouped by these parameters.
382
+ # Increments SQL statistics of a certain +query+. When +method+ and +route+
383
+ # are provided, the query is grouped by these parameters.
388
384
  #
389
385
  # After a certain amount of time (n seconds) the aggregated query
390
386
  # information will be sent to Airbrake.
@@ -394,18 +390,17 @@ module Airbrake
394
390
  # method: 'GET',
395
391
  # route: '/things',
396
392
  # query: 'SELECT * FROM things',
397
- # start_time: timestamp,
398
- # end_time: Time.now
393
+ # timing: 123.45 # ms
399
394
  # )
400
395
  #
401
396
  # @param [Hash{Symbol=>Object}] query_info
402
- # @option request_info [String] :method The HTTP method that triggered this
397
+ # @option query_info [String] :method The HTTP method that triggered this
403
398
  # SQL query (optional)
404
- # @option request_info [String] :route The route that triggered this SQL
399
+ # @option query_info [String] :route The route that triggered this SQL
405
400
  # query (optional)
406
- # @option request_info [String] :query The query that was executed
407
- # @option request_info [Date] :start_time When the query started executing
408
- # @option request_info [Time] :end_time When the query finished (optional)
401
+ # @option query_info [String] :query The query that was executed
402
+ # @option query_info [Float] :timing How much time it took to process the
403
+ # query (in ms)
409
404
  # @param [Hash] stash What needs to be appeneded to the stash, so it's
410
405
  # available in filters
411
406
  # @return [void]
@@ -417,9 +412,9 @@ module Airbrake
417
412
  performance_notifier.notify(query)
418
413
  end
419
414
 
420
- # Synchronously increments SQL statistics of a certain +query+ that was
421
- # invoked on +start_time+ and finished on +end_time+. When +method+ and
422
- # +route+ are provided, the query is grouped by these parameters.
415
+ # Synchronously increments SQL statistics of a certain +query+. When
416
+ # +method+ and +route+ are provided, the query is grouped by these
417
+ # parameters.
423
418
  # @since v4.10.0
424
419
  # @see .notify_query
425
420
  def notify_query_sync(query_info, stash = {})
@@ -436,8 +431,7 @@ module Airbrake
436
431
  # route: '/thing/:id/create',
437
432
  # response_type: 'json',
438
433
  # groups: { db: 24.0, view: 0.4 }, # ms
439
- # start_time: timestamp,
440
- # end_time: Time.now
434
+ # timing: 123.45 # ms
441
435
  # )
442
436
  #
443
437
  # @param [Hash{Symbol=>Object}] breakdown_info
@@ -445,7 +439,8 @@ module Airbrake
445
439
  # @option breakdown_info [String] :route
446
440
  # @option breakdown_info [String] :response_type
447
441
  # @option breakdown_info [Array<Hash{Symbol=>Float}>] :groups
448
- # @option breakdown_info [Date] :start_time
442
+ # @option breakdown_info [Float] :timing How much time it took to process
443
+ # the performance breakdown (in ms)
449
444
  # @param [Hash] stash What needs to be appeneded to the stash, so it's
450
445
  # available in filters
451
446
  # @return [void]
@@ -481,6 +476,8 @@ module Airbrake
481
476
  # failed
482
477
  # @option queue_info [Array<Hash{Symbol=>Float}>] :groups Where the job
483
478
  # spent its time
479
+ # @option breakdown_info [Float] :timing How much time it took to process
480
+ # the queue (in ms)
484
481
  # @param [Hash] stash What needs to be appended to the stash, so it's
485
482
  # available in filters
486
483
  # @return [void]
@@ -2,7 +2,7 @@ module Airbrake
2
2
  # Benchmark benchmarks Ruby code.
3
3
  #
4
4
  # @since v4.2.4
5
- # @api private
5
+ # @api public
6
6
  class Benchmark
7
7
  # Measures monotonic time for the given operation.
8
8
  #
@@ -55,7 +55,8 @@ module Airbrake
55
55
  def build_notice(exception, params = {})
56
56
  if @async_sender.closed?
57
57
  raise Airbrake::Error,
58
- "attempted to build #{exception} with closed Airbrake instance"
58
+ "Airbrake is closed; can't build exception: " \
59
+ "#{exception.class}: #{exception}"
59
60
  end
60
61
 
61
62
  if exception.is_a?(Airbrake::Notice)
@@ -7,7 +7,8 @@ module Airbrake
7
7
  # @since v4.2.0
8
8
  # rubocop:disable Metrics/BlockLength, Metrics/ParameterLists
9
9
  PerformanceBreakdown = Struct.new(
10
- :method, :route, :response_type, :groups, :start_time, :end_time
10
+ :method, :route, :response_type, :groups, :start_time, :end_time, :timing,
11
+ :time
11
12
  ) do
12
13
  include HashKeyable
13
14
  include Ignorable
@@ -19,11 +20,15 @@ module Airbrake
19
20
  route:,
20
21
  response_type:,
21
22
  groups:,
22
- start_time:,
23
- end_time: start_time + 1
23
+ start_time: Time.now,
24
+ end_time: start_time + 1,
25
+ timing: nil,
26
+ time: Time.now
24
27
  )
25
- @start_time_utc = TimeTruncate.utc_truncate_minutes(start_time)
26
- super(method, route, response_type, groups, start_time, end_time)
28
+ @time_utc = TimeTruncate.utc_truncate_minutes(time)
29
+ super(
30
+ method, route, response_type, groups, start_time, end_time, timing, time
31
+ )
27
32
  end
28
33
 
29
34
  def destination
@@ -39,7 +44,7 @@ module Airbrake
39
44
  'method' => method,
40
45
  'route' => route,
41
46
  'responseType' => response_type,
42
- 'time' => @start_time_utc,
47
+ 'time' => @time_utc,
43
48
  }.delete_if { |_key, val| val.nil? }
44
49
  end
45
50
  end
@@ -62,7 +62,7 @@ module Airbrake
62
62
  @payload[resource] = { total: Airbrake::Stat.new }
63
63
  end
64
64
 
65
- @payload[resource][:total].increment(resource.start_time, resource.end_time)
65
+ update_total(resource, @payload[resource][:total])
66
66
 
67
67
  resource.groups.each do |name, ms|
68
68
  @payload[resource][name] ||= Airbrake::Stat.new
@@ -70,6 +70,19 @@ module Airbrake
70
70
  end
71
71
  end
72
72
 
73
+ def update_total(resource, total)
74
+ if resource.timing
75
+ total.increment_ms(resource.timing)
76
+ else
77
+ loc = caller_locations(6..6).first
78
+ Kernel.warn(
79
+ "#{loc.path}:#{loc.lineno}: warning: :start_time and :end_time are " \
80
+ "deprecated. Use :timing & :time instead",
81
+ )
82
+ total.increment(resource.start_time, resource.end_time)
83
+ end
84
+ end
85
+
73
86
  def schedule_flush
74
87
  return if @payload.empty?
75
88
 
@@ -6,7 +6,8 @@ module Airbrake
6
6
  # @since v3.2.0
7
7
  # rubocop:disable Metrics/ParameterLists, Metrics/BlockLength
8
8
  Query = Struct.new(
9
- :method, :route, :query, :func, :file, :line, :start_time, :end_time
9
+ :method, :route, :query, :func, :file, :line, :start_time, :end_time,
10
+ :timing, :time
10
11
  ) do
11
12
  include HashKeyable
12
13
  include Ignorable
@@ -21,11 +22,16 @@ module Airbrake
21
22
  func: nil,
22
23
  file: nil,
23
24
  line: nil,
24
- start_time:,
25
- end_time: start_time + 1
25
+ start_time: Time.now,
26
+ end_time: start_time + 1,
27
+ timing: nil,
28
+ time: Time.now
26
29
  )
27
- @start_time_utc = TimeTruncate.utc_truncate_minutes(start_time)
28
- super(method, route, query, func, file, line, start_time, end_time)
30
+ @time_utc = TimeTruncate.utc_truncate_minutes(time)
31
+ super(
32
+ method, route, query, func, file, line, start_time, end_time, timing,
33
+ time
34
+ )
29
35
  end
30
36
 
31
37
  def destination
@@ -41,7 +47,7 @@ module Airbrake
41
47
  'method' => method,
42
48
  'route' => route,
43
49
  'query' => query,
44
- 'time' => @start_time_utc,
50
+ 'time' => @time_utc,
45
51
  'function' => func,
46
52
  'file' => file,
47
53
  'line' => line,
@@ -4,8 +4,10 @@ module Airbrake
4
4
  # @see Airbrake.notify_queue
5
5
  # @api public
6
6
  # @since v4.9.0
7
- # rubocop:disable Metrics/BlockLength
8
- Queue = Struct.new(:queue, :error_count, :groups, :start_time, :end_time) do
7
+ # rubocop:disable Metrics/BlockLength, Metrics/ParameterLists
8
+ Queue = Struct.new(
9
+ :queue, :error_count, :groups, :start_time, :end_time, :timing, :time
10
+ ) do
9
11
  include HashKeyable
10
12
  include Ignorable
11
13
  include Stashable
@@ -15,10 +17,12 @@ module Airbrake
15
17
  error_count:,
16
18
  groups: {},
17
19
  start_time: Time.now,
18
- end_time: start_time + 1
20
+ end_time: start_time + 1,
21
+ timing: nil,
22
+ time: Time.now
19
23
  )
20
- @start_time_utc = TimeTruncate.utc_truncate_minutes(start_time)
21
- super(queue, error_count, groups, start_time, end_time)
24
+ @time_utc = TimeTruncate.utc_truncate_minutes(time)
25
+ super(queue, error_count, groups, start_time, end_time, timing, time)
22
26
  end
23
27
 
24
28
  def destination
@@ -33,14 +37,14 @@ module Airbrake
33
37
  {
34
38
  'queue' => queue,
35
39
  'errorCount' => error_count,
36
- 'time' => @start_time_utc,
40
+ 'time' => @time_utc,
37
41
  }
38
42
  end
39
43
 
40
44
  def hash
41
45
  {
42
46
  'queue' => queue,
43
- 'time' => @start_time_utc,
47
+ 'time' => @time_utc,
44
48
  }.hash
45
49
  end
46
50
 
@@ -48,5 +52,5 @@ module Airbrake
48
52
  self.error_count += other.error_count
49
53
  end
50
54
  end
51
- # rubocop:enable Metrics/BlockLength
55
+ # rubocop:enable Metrics/BlockLength, Metrics/ParameterLists
52
56
  end
@@ -4,8 +4,10 @@ module Airbrake
4
4
  # @see Airbrake.notify_request
5
5
  # @api public
6
6
  # @since v3.2.0
7
- # rubocop:disable Metrics/BlockLength
8
- Request = Struct.new(:method, :route, :status_code, :start_time, :end_time) do
7
+ # rubocop:disable Metrics/BlockLength, Metrics/ParameterLists
8
+ Request = Struct.new(
9
+ :method, :route, :status_code, :start_time, :end_time, :timing, :time
10
+ ) do
9
11
  include HashKeyable
10
12
  include Ignorable
11
13
  include Stashable
@@ -16,11 +18,13 @@ module Airbrake
16
18
  method:,
17
19
  route:,
18
20
  status_code:,
19
- start_time:,
20
- end_time: start_time + 1
21
+ start_time: Time.now,
22
+ end_time: start_time + 1,
23
+ timing: nil,
24
+ time: Time.now
21
25
  )
22
- @start_time_utc = TimeTruncate.utc_truncate_minutes(start_time)
23
- super(method, route, status_code, start_time, end_time)
26
+ @time_utc = TimeTruncate.utc_truncate_minutes(time)
27
+ super(method, route, status_code, start_time, end_time, timing, time)
24
28
  end
25
29
 
26
30
  def destination
@@ -36,9 +40,9 @@ module Airbrake
36
40
  'method' => method,
37
41
  'route' => route,
38
42
  'statusCode' => status_code,
39
- 'time' => @start_time_utc,
43
+ 'time' => @time_utc,
40
44
  }.delete_if { |_key, val| val.nil? }
41
45
  end
42
46
  end
43
- # rubocop:enable Metrics/BlockLength
47
+ # rubocop:enable Metrics/BlockLength, Metrics/ParameterLists
44
48
  end
@@ -2,5 +2,5 @@
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
- AIRBRAKE_RUBY_VERSION = '4.10.1'.freeze
5
+ AIRBRAKE_RUBY_VERSION = '4.11.0'.freeze
6
6
  end
@@ -328,9 +328,9 @@ RSpec.describe Airbrake::NoticeNotifier do
328
328
  end
329
329
 
330
330
  it "raises error" do
331
- expect { subject.build_notice(Exception.new) }.to raise_error(
331
+ expect { subject.build_notice(Exception.new('oops')) }.to raise_error(
332
332
  Airbrake::Error,
333
- 'attempted to build Exception with closed Airbrake instance',
333
+ "Airbrake is closed; can't build exception: Exception: oops",
334
334
  )
335
335
  end
336
336
  end
@@ -29,8 +29,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
29
29
  func: 'foo',
30
30
  file: 'foo.rb',
31
31
  line: 123,
32
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
33
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
32
+ timing: 60000,
33
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
34
34
  ),
35
35
  )
36
36
  subject.close
@@ -59,8 +59,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
59
59
  method: 'POST',
60
60
  route: '/foo',
61
61
  status_code: 200,
62
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
63
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
62
+ timing: 60000,
63
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
64
64
  ),
65
65
  )
66
66
  subject.close
@@ -86,8 +86,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
86
86
  method: 'DELETE',
87
87
  route: '/routes-breakdowns',
88
88
  response_type: 'json',
89
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
90
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
89
+ timing: 60000,
90
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
91
91
  groups: { db: 131, view: 421 },
92
92
  ),
93
93
  )
@@ -128,8 +128,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
128
128
  queue: 'emails',
129
129
  error_count: 2,
130
130
  groups: { redis: 131, sql: 421 },
131
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
132
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
131
+ timing: 60000,
132
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
133
133
  ),
134
134
  )
135
135
  subject.close
@@ -168,7 +168,8 @@ 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),
171
+ timing: 60000,
172
+ time: Time.new(2018, 1, 1, 0, 0, 20, 0),
172
173
  ),
173
174
  )
174
175
  subject.close
@@ -184,7 +185,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
184
185
  method: 'GET',
185
186
  route: '/foo',
186
187
  status_code: 200,
187
- start_time: Time.new(2018, 1, 1, 0, 0, 20, 0),
188
+ timing: 213,
188
189
  ),
189
190
  )
190
191
  subject.notify(
@@ -192,7 +193,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
192
193
  method: 'GET',
193
194
  route: '/foo',
194
195
  status_code: 200,
195
- start_time: Time.new(2018, 1, 1, 0, 0, 50, 0),
196
+ timing: 123,
196
197
  ),
197
198
  )
198
199
  subject.close
@@ -208,8 +209,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
208
209
  method: 'GET',
209
210
  route: '/foo',
210
211
  status_code: 200,
211
- start_time: Time.new(2018, 1, 1, 0, 0, 49, 0),
212
- end_time: Time.new(2018, 1, 1, 0, 0, 50, 0),
212
+ timing: 1000,
213
+ time: Time.new(2018, 1, 1, 0, 0, 49, 0),
213
214
  ),
214
215
  )
215
216
  subject.notify(
@@ -217,8 +218,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
217
218
  method: 'GET',
218
219
  route: '/foo',
219
220
  status_code: 200,
220
- start_time: Time.new(2018, 1, 1, 0, 1, 49, 0),
221
- end_time: Time.new(2018, 1, 1, 0, 1, 55, 0),
221
+ timing: 6000,
222
+ time: Time.new(2018, 1, 1, 0, 1, 49, 0),
222
223
  ),
223
224
  )
224
225
  subject.close
@@ -244,8 +245,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
244
245
  method: 'GET',
245
246
  route: '/foo',
246
247
  status_code: 200,
247
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
248
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
248
+ timing: 60000,
249
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
249
250
  ),
250
251
  )
251
252
  subject.notify(
@@ -253,8 +254,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
253
254
  method: 'POST',
254
255
  route: '/foo',
255
256
  status_code: 200,
256
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
257
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
257
+ timing: 60000,
258
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
258
259
  ),
259
260
  )
260
261
  subject.close
@@ -280,8 +281,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
280
281
  method: 'DELETE',
281
282
  route: '/routes-breakdowns',
282
283
  response_type: 'json',
283
- start_time: Time.new(2018, 1, 1, 0, 0, 20, 0),
284
- end_time: Time.new(2018, 1, 1, 0, 0, 22, 0),
284
+ timing: 2000,
285
+ time: Time.new(2018, 1, 1, 0, 0, 20, 0),
285
286
  groups: { db: 131, view: 421 },
286
287
  ),
287
288
  )
@@ -290,8 +291,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
290
291
  method: 'DELETE',
291
292
  route: '/routes-breakdowns',
292
293
  response_type: 'json',
293
- start_time: Time.new(2018, 1, 1, 0, 0, 30, 0),
294
- end_time: Time.new(2018, 1, 1, 0, 0, 32, 0),
294
+ timing: 2000,
295
+ time: Time.new(2018, 1, 1, 0, 0, 30, 0),
295
296
  groups: { db: 55, view: 11 },
296
297
  ),
297
298
  )
@@ -332,8 +333,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
332
333
  queue: 'emails',
333
334
  error_count: 2,
334
335
  groups: { redis: 131, sql: 421 },
335
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
336
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
336
+ timing: 60000,
337
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
337
338
  ),
338
339
  )
339
340
  subject.notify(
@@ -341,8 +342,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
341
342
  queue: 'emails',
342
343
  error_count: 3,
343
344
  groups: { redis: 131, sql: 421 },
344
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
345
- end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
345
+ timing: 60000,
346
+ time: Time.new(2018, 1, 1, 0, 49, 0, 0),
346
347
  ),
347
348
  )
348
349
  subject.close
@@ -381,7 +382,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
381
382
  method: 'GET',
382
383
  route: '/foo',
383
384
  status_code: 200,
384
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
385
+ timing: 123,
385
386
  ),
386
387
  )
387
388
  subject.close
@@ -392,7 +393,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
392
393
 
393
394
  it "checks performance stat configuration" do
394
395
  request = Airbrake::Request.new(
395
- method: 'GET', route: '/foo', status_code: 200, start_time: Time.new,
396
+ method: 'GET', route: '/foo', status_code: 200, timing: 123,
396
397
  )
397
398
  expect(Airbrake::Config.instance).to receive(:check_performance_options)
398
399
  .with(request).and_return(Airbrake::Promise.new)
@@ -408,7 +409,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
408
409
  method: 'POST',
409
410
  route: '/foo',
410
411
  status_code: 200,
411
- start_time: Time.new,
412
+ timing: 123,
412
413
  ),
413
414
  )
414
415
  subject.close
@@ -445,7 +446,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
445
446
  method: 'GET',
446
447
  route: '/foo',
447
448
  status_code: 200,
448
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
449
+ timing: 123,
449
450
  ),
450
451
  )
451
452
 
@@ -454,7 +455,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
454
455
  method: 'POST',
455
456
  route: '/foo',
456
457
  query: 'SELECT * FROM things',
457
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
458
+ timing: 123,
458
459
  ),
459
460
  )
460
461
 
@@ -510,7 +511,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
510
511
  method: 'POST',
511
512
  route: '/foo',
512
513
  query: 'SELECT * FROM things',
513
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
514
+ timing: 123,
514
515
  ),
515
516
  )
516
517
  subject.close
@@ -522,6 +523,31 @@ RSpec.describe Airbrake::PerformanceNotifier do
522
523
  ).to have_been_made
523
524
  end
524
525
  end
526
+
527
+ context "when :start_time is specified (deprecated)" do
528
+ before do
529
+ allow(Kernel).to receive(:warn)
530
+ end
531
+
532
+ it "uses the value of :start_time to update stat" do
533
+ subject.notify(
534
+ Airbrake::Query.new(
535
+ method: 'POST',
536
+ route: '/foo',
537
+ query: 'SELECT * FROM things',
538
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
539
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0),
540
+ ),
541
+ )
542
+ subject.close
543
+
544
+ expect(
545
+ a_request(:put, queries).with(
546
+ body: /"count":1,"sum":60000.0,"sumsq":3600000000.0/,
547
+ ),
548
+ ).to have_been_made
549
+ end
550
+ end
525
551
  end
526
552
 
527
553
  describe "#notify_sync" do
@@ -531,7 +557,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
531
557
  method: 'POST',
532
558
  route: '/foo',
533
559
  query: 'SELECT * FROM things',
534
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
560
+ timing: 123,
535
561
  ),
536
562
  )
537
563
 
@@ -560,7 +586,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
560
586
  method: 'POST',
561
587
  route: '/foo',
562
588
  query: 'SELECT * FROM things',
563
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
589
+ timing: 123,
564
590
  ),
565
591
  )
566
592
  subject.close
@@ -591,7 +617,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
591
617
  method: 'POST',
592
618
  route: '/foo',
593
619
  status_code: 200,
594
- start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
620
+ timing: 123,
595
621
  ),
596
622
  )
597
623
  subject.close
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.1
4
+ version: 4.11.0
5
5
  platform: java
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-12 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree-jruby