airbrake-ruby 3.2.4 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0151a765b95213dc4a221547aa4afd2cf7da6c0
4
- data.tar.gz: b13483675acade75535356f679099873ed234888
3
+ metadata.gz: d82d2c4088a9f12a7b9f79f06bbd627e467ca41a
4
+ data.tar.gz: 2d5a844aee8b9566bb707a6ba5b89f6b0534d770
5
5
  SHA512:
6
- metadata.gz: fe9e46d9281e883be340f1648160989c4e8683c52e7dfec8652ba0403d625d70d2d23874134c2fc6000b0a3d8730dfeb01778832e1cd763999278883ad13c115
7
- data.tar.gz: 39a05948f1e8176e7862cda8a02d669a9f2f46e078f1aca1901167814192e1ea1ad62f6b0b81df802f8a2b5686fc6ac6f0295b52daa2a121ddaf8d48eb79fc42
6
+ metadata.gz: c0bda142c168eeca50d9f73d6897c031d20bec58f2c1c9dbc1bbc4778fa3252025bfd56c8f0c1f7593b86fc632ac3f26a7a73d2edd5b84171c2701b4d7a0a94c
7
+ data.tar.gz: 871e4d592b46053d231d5ef6611e7f0736cffd0d4b40dc1ac586c1f3fee86e06bb937b4df0ee6c27a34d1c343d59d161b34b3b76b358683dbfdaad3a7013e1a3
@@ -42,6 +42,8 @@ require 'airbrake-ruby/deploy_notifier'
42
42
  require 'airbrake-ruby/stat'
43
43
  require 'airbrake-ruby/time_truncate'
44
44
  require 'airbrake-ruby/tdigest'
45
+ require 'airbrake-ruby/query'
46
+ require 'airbrake-ruby/request'
45
47
 
46
48
  # This module defines the Airbrake API. The user is meant to interact with
47
49
  # Airbrake via its public class methods. Before using the library, you must to
@@ -450,6 +452,9 @@ module Airbrake
450
452
  # method: 'POST',
451
453
  # route: '/thing/:id/create',
452
454
  # status_code: 200,
455
+ # func: 'do_stuff',
456
+ # file: 'app/models/foo.rb',
457
+ # line: 452,
453
458
  # start_time: timestamp,
454
459
  # end_time: Time.now
455
460
  # )
@@ -457,7 +462,14 @@ module Airbrake
457
462
  # @param [Hash{Symbol=>Object}] request_info
458
463
  # @option request_info [String] :method The HTTP method that was invoked
459
464
  # @option request_info [String] :route The route that was invoked
460
- # @option request_info [Integer] :status_code The respose code that the route returned
465
+ # @option request_info [Integer] :status_code The respose code that the
466
+ # route returned
467
+ # @option request_info [String] :func The function that called the query
468
+ # (optional)
469
+ # @option request_info [String] :file The file that has the function that
470
+ # called the query (optional)
471
+ # @option request_info [Integer] :line The line that executes the query
472
+ # (optional)
461
473
  # @option request_info [Date] :start_time When the request started
462
474
  # @option request_info [Time] :end_time When the request ended (optional)
463
475
  # @return [void]
@@ -484,6 +496,7 @@ module Airbrake
484
496
  # )
485
497
  #
486
498
  # @param [Hash{Symbol=>Object}] query_info
499
+ # @option request_info [String] :environment (optional)
487
500
  # @option request_info [String] :method The HTTP method that triggered this
488
501
  # SQL query (optional)
489
502
  # @option request_info [String] :route The route that triggered this SQL
@@ -103,59 +103,4 @@ module Airbrake
103
103
  end
104
104
  end
105
105
  end
106
-
107
- # Request holds request data that powers route stats.
108
- #
109
- # @see Airbrake.notify_request
110
- # @api public
111
- # @since v3.2.0
112
- Request = Struct.new(:method, :route, :status_code, :start_time, :end_time) do
113
- include HashKeyable
114
- include Ignorable
115
-
116
- def initialize(method:, route:, status_code:, start_time:, end_time: Time.now)
117
- @ignored = false
118
- super(method, route, status_code, start_time, end_time)
119
- end
120
-
121
- def name
122
- 'routes'
123
- end
124
-
125
- def to_h
126
- {
127
- 'method' => method,
128
- 'route' => route,
129
- 'statusCode' => status_code,
130
- 'time' => TimeTruncate.utc_truncate_minutes(start_time)
131
- }
132
- end
133
- end
134
-
135
- # Query holds SQL query data that powers SQL query collection.
136
- #
137
- # @see Airbrake.notify_query
138
- # @api public
139
- # @since v3.2.0
140
- Query = Struct.new(:method, :route, :query, :start_time, :end_time) do
141
- include HashKeyable
142
- include Ignorable
143
-
144
- def initialize(method:, route:, query:, start_time:, end_time: Time.now)
145
- super(method, route, query, start_time, end_time)
146
- end
147
-
148
- def name
149
- 'queries'
150
- end
151
-
152
- def to_h
153
- {
154
- 'method' => method,
155
- 'route' => route,
156
- 'query' => query,
157
- 'time' => TimeTruncate.utc_truncate_minutes(start_time)
158
- }
159
- end
160
- end
161
106
  end
@@ -0,0 +1,50 @@
1
+ module Airbrake
2
+ # Query holds SQL query data that powers SQL query collection.
3
+ #
4
+ # @see Airbrake.notify_query
5
+ # @api public
6
+ # @since v3.2.0
7
+ # rubocop:disable Metrics/ParameterLists, Metrics/BlockLength
8
+ Query = Struct.new(
9
+ :environment, :method, :route, :query, :func, :file, :line, :start_time,
10
+ :end_time
11
+ ) do
12
+ include HashKeyable
13
+ include Ignorable
14
+
15
+ def initialize(
16
+ environment: nil,
17
+ method:,
18
+ route:,
19
+ query:,
20
+ func: nil,
21
+ file: nil,
22
+ line: nil,
23
+ start_time:,
24
+ end_time: Time.now
25
+ )
26
+ super(
27
+ environment, method, route, query, func, file, line, start_time,
28
+ end_time
29
+ )
30
+ end
31
+
32
+ def name
33
+ 'queries'
34
+ end
35
+
36
+ def to_h
37
+ {
38
+ 'environment' => environment,
39
+ 'method' => method,
40
+ 'route' => route,
41
+ 'query' => query,
42
+ 'time' => TimeTruncate.utc_truncate_minutes(start_time),
43
+ 'function' => func,
44
+ 'file' => file,
45
+ 'line' => line
46
+ }.delete_if { |_key, val| val.nil? }
47
+ end
48
+ # rubocop:enable Metrics/ParameterLists, Metrics/BlockLength
49
+ end
50
+ end
@@ -0,0 +1,40 @@
1
+ module Airbrake
2
+ # Request holds request data that powers route stats.
3
+ #
4
+ # @see Airbrake.notify_request
5
+ # @api public
6
+ # @since v3.2.0
7
+ # rubocop:disable Metrics/ParameterLists
8
+ Request = Struct.new(
9
+ :environment, :method, :route, :status_code, :start_time, :end_time
10
+ ) do
11
+ include HashKeyable
12
+ include Ignorable
13
+
14
+ def initialize(
15
+ environment: nil,
16
+ method:,
17
+ route:,
18
+ status_code:,
19
+ start_time:,
20
+ end_time: Time.now
21
+ )
22
+ super(environment, method, route, status_code, start_time, end_time)
23
+ end
24
+
25
+ def name
26
+ 'routes'
27
+ end
28
+
29
+ def to_h
30
+ {
31
+ 'environment' => environment,
32
+ 'method' => method,
33
+ 'route' => route,
34
+ 'statusCode' => status_code,
35
+ 'time' => TimeTruncate.utc_truncate_minutes(start_time)
36
+ }.delete_if { |_key, val| val.nil? }
37
+ end
38
+ end
39
+ # rubocop:enable Metrics/ParameterLists
40
+ 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 = '3.2.4'.freeze
5
+ AIRBRAKE_RUBY_VERSION = '3.2.5'.freeze
6
6
  end
@@ -19,6 +19,68 @@ RSpec.describe Airbrake::PerformanceNotifier do
19
19
  end
20
20
 
21
21
  describe "#notify" do
22
+ it "sends full query" do
23
+ subject.notify(
24
+ Airbrake::Query.new(
25
+ environment: 'development',
26
+ method: 'POST',
27
+ route: '/foo',
28
+ query: 'SELECT * FROM things',
29
+ func: 'foo',
30
+ file: 'foo.rb',
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)
34
+ )
35
+ )
36
+
37
+ expect(
38
+ a_request(:put, queries).with(body: %r|
39
+ \A{"queries":\[{
40
+ "environment":"development",
41
+ "method":"POST",
42
+ "route":"/foo",
43
+ "query":"SELECT\s\*\sFROM\sthings",
44
+ "time":"2018-01-01T00:49:00\+00:00",
45
+ "function":"foo",
46
+ "file":"foo.rb",
47
+ "line":123,
48
+ "count":1,
49
+ "sum":60000.0,
50
+ "sumsq":3600000000.0,
51
+ "tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"
52
+ }\]}\z|x)
53
+ ).to have_been_made
54
+ end
55
+
56
+ it "sends full request" do
57
+ subject.notify(
58
+ Airbrake::Request.new(
59
+ environment: 'development',
60
+ method: 'POST',
61
+ route: '/foo',
62
+ status_code: 200,
63
+ start_time: Time.new(2018, 1, 1, 0, 49, 0, 0),
64
+ end_time: Time.new(2018, 1, 1, 0, 50, 0, 0)
65
+ )
66
+ )
67
+
68
+ expect(
69
+ a_request(:put, routes).with(body: %r|
70
+ \A{"routes":\[{
71
+ "environment":"development",
72
+ "method":"POST",
73
+ "route":"/foo",
74
+ "statusCode":200,
75
+ "time":"2018-01-01T00:49:00\+00:00",
76
+ "count":1,
77
+ "sum":60000.0,
78
+ "sumsq":3600000000.0,
79
+ "tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"
80
+ }\]}\z|x)
81
+ ).to have_been_made
82
+ end
83
+
22
84
  it "rounds time to the floor minute" do
23
85
  subject.notify(
24
86
  Airbrake::Request.new(
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: 3.2.4
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3
@@ -68,6 +68,8 @@ files:
68
68
  - lib/airbrake-ruby/notice_notifier.rb
69
69
  - lib/airbrake-ruby/performance_notifier.rb
70
70
  - lib/airbrake-ruby/promise.rb
71
+ - lib/airbrake-ruby/query.rb
72
+ - lib/airbrake-ruby/request.rb
71
73
  - lib/airbrake-ruby/response.rb
72
74
  - lib/airbrake-ruby/stat.rb
73
75
  - lib/airbrake-ruby/sync_sender.rb