airbrake-ruby 3.2.4-java → 3.2.5-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 +4 -4
- data/lib/airbrake-ruby.rb +14 -1
- data/lib/airbrake-ruby/performance_notifier.rb +0 -55
- data/lib/airbrake-ruby/query.rb +50 -0
- data/lib/airbrake-ruby/request.rb +40 -0
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/performance_notifier_spec.rb +62 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81c8ffb2b327ead76636d5a37a692bd308f803d4
|
4
|
+
data.tar.gz: efbbef022a81083273153e0ce9a912798061a745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 138cfe86135a7af667c384c7033870a5263138e92b8f6cad552a39284988f78aea401306c960da3c885fbb7096196460e144823370ef345235b7829a292c8649
|
7
|
+
data.tar.gz: 20196765416f33646979b2bb3ebe3dca200a82a32fb5b45e12a7d49c3d849bc0e55b4b7791d4447aae44379047c510fe1c9f4e83f05d739c454564734c1aa415
|
data/lib/airbrake-ruby.rb
CHANGED
@@ -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
|
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
|
@@ -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
|
+
version: 3.2.5
|
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-02-
|
11
|
+
date: 2019-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree-jruby
|
@@ -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
|