airbrake-ruby 4.5.1-java → 4.6.0-java
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/config.rb +24 -3
- data/lib/airbrake-ruby/performance_notifier.rb +2 -4
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/config_spec.rb +45 -0
- data/spec/performance_notifier_spec.rb +8 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9bfac1b8aca0a9932a5c197842b335b1fbfe0c2
|
4
|
+
data.tar.gz: 46ab44d8c2a29ee444f7d1fc332e9a9e3e8cefa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3efe36caa116da7d9f2f77a8655dfa4b7a61ce152f89190c82160cd86258a8353e97d382e78a4c52e4a624f19c712f456143bafe972e3c44cb15feb2114deb21
|
7
|
+
data.tar.gz: 410b1dc3de20748fa1ae020636b5051e1b96fe5f1a35e814152738df8d4a7dfe1425573418a73b8151ebc2fe16947375b281e8e74969deeaa7ba105d43643863
|
data/lib/airbrake-ruby/config.rb
CHANGED
@@ -83,18 +83,24 @@ module Airbrake
|
|
83
83
|
# @since v2.5.0
|
84
84
|
attr_accessor :code_hunks
|
85
85
|
|
86
|
-
# @return [Boolean] true if the library should send performance stats
|
87
|
-
#
|
86
|
+
# @return [Boolean] true if the library should send route performance stats
|
87
|
+
# to Airbrake, false otherwise
|
88
88
|
# @api public
|
89
89
|
# @since v3.2.0
|
90
90
|
attr_accessor :performance_stats
|
91
91
|
|
92
92
|
# @return [Integer] how many seconds to wait before sending collected route
|
93
93
|
# stats
|
94
|
-
# @api
|
94
|
+
# @api private
|
95
95
|
# @since v3.2.0
|
96
96
|
attr_accessor :performance_stats_flush_period
|
97
97
|
|
98
|
+
# @return [Boolean] true if the library should send SQL stats to Airbrake,
|
99
|
+
# false otherwise
|
100
|
+
# @api public
|
101
|
+
# @since v4.6.0
|
102
|
+
attr_accessor :query_stats
|
103
|
+
|
98
104
|
class << self
|
99
105
|
# @return [Config]
|
100
106
|
attr_writer :instance
|
@@ -132,6 +138,7 @@ module Airbrake
|
|
132
138
|
self.versions = {}
|
133
139
|
self.performance_stats = true
|
134
140
|
self.performance_stats_flush_period = 15
|
141
|
+
self.query_stats = false
|
135
142
|
|
136
143
|
merge(user_config)
|
137
144
|
end
|
@@ -197,6 +204,20 @@ module Airbrake
|
|
197
204
|
check_notify_ability
|
198
205
|
end
|
199
206
|
|
207
|
+
# @return [Promise] resolved promise if neither of the performance options
|
208
|
+
# reject it, false otherwise
|
209
|
+
def check_performance_options(resource)
|
210
|
+
promise = Airbrake::Promise.new
|
211
|
+
|
212
|
+
if !performance_stats
|
213
|
+
promise.reject("The Performance Stats feature is disabled")
|
214
|
+
elsif resource.is_a?(Airbrake::Query) && !query_stats
|
215
|
+
promise.reject("The Query Stats feature is disabled")
|
216
|
+
else
|
217
|
+
promise
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
200
221
|
private
|
201
222
|
|
202
223
|
def set_option(option, value)
|
@@ -25,10 +25,8 @@ module Airbrake
|
|
25
25
|
promise = @config.check_configuration
|
26
26
|
return promise if promise.rejected?
|
27
27
|
|
28
|
-
promise =
|
29
|
-
|
30
|
-
return promise.reject("The Performance Stats feature is disabled")
|
31
|
-
end
|
28
|
+
promise = @config.check_performance_options(resource)
|
29
|
+
return promise if promise.rejected?
|
32
30
|
|
33
31
|
@filter_chain.refine(resource)
|
34
32
|
return if resource.ignored?
|
data/spec/config_spec.rb
CHANGED
@@ -21,6 +21,7 @@ RSpec.describe Airbrake::Config do
|
|
21
21
|
its(:whitelist_keys) { is_expected.to be_empty }
|
22
22
|
its(:performance_stats) { is_expected.to eq(true) }
|
23
23
|
its(:performance_stats_flush_period) { is_expected.to eq(15) }
|
24
|
+
its(:query_stats) { is_expected.to eq(false) }
|
24
25
|
|
25
26
|
describe "#new" do
|
26
27
|
context "when user config is passed" do
|
@@ -106,4 +107,48 @@ RSpec.describe Airbrake::Config do
|
|
106
107
|
its(:check_configuration) { is_expected.not_to be_rejected }
|
107
108
|
end
|
108
109
|
end
|
110
|
+
|
111
|
+
describe "#check_performance_options" do
|
112
|
+
it "returns a promise" do
|
113
|
+
resource = Airbrake::Query.new(
|
114
|
+
method: '', route: '', query: '', start_time: Time.now
|
115
|
+
)
|
116
|
+
expect(subject.check_performance_options(resource))
|
117
|
+
.to be_an(Airbrake::Promise)
|
118
|
+
end
|
119
|
+
|
120
|
+
context "when performance stats are disabled" do
|
121
|
+
before { subject.performance_stats = false }
|
122
|
+
|
123
|
+
let(:resource) do
|
124
|
+
Airbrake::Request.new(
|
125
|
+
method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "returns a rejected promise" do
|
130
|
+
promise = subject.check_performance_options(resource)
|
131
|
+
expect(promise.value).to eq(
|
132
|
+
'error' => "The Performance Stats feature is disabled"
|
133
|
+
)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when query stats are disabled" do
|
138
|
+
before { subject.query_stats = false }
|
139
|
+
|
140
|
+
let(:resource) do
|
141
|
+
Airbrake::Query.new(
|
142
|
+
method: 'GET', route: '/foo', query: '', start_time: Time.new
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "returns a rejected promise" do
|
147
|
+
promise = subject.check_performance_options(resource)
|
148
|
+
expect(promise.value).to eq(
|
149
|
+
'error' => "The Query Stats feature is disabled"
|
150
|
+
)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
109
154
|
end
|
@@ -12,7 +12,8 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
12
12
|
project_id: 1,
|
13
13
|
project_key: 'banana',
|
14
14
|
performance_stats: true,
|
15
|
-
performance_stats_flush_period: 0
|
15
|
+
performance_stats_flush_period: 0,
|
16
|
+
query_stats: true
|
16
17
|
)
|
17
18
|
end
|
18
19
|
|
@@ -284,34 +285,13 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
284
285
|
expect(promise.value).to eq('' => nil)
|
285
286
|
end
|
286
287
|
|
287
|
-
it "
|
288
|
-
Airbrake::
|
289
|
-
|
290
|
-
promise = subject.notify(
|
291
|
-
Airbrake::Request.new(
|
292
|
-
method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
|
293
|
-
)
|
288
|
+
it "checks performance stat configuration" do
|
289
|
+
request = Airbrake::Request.new(
|
290
|
+
method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
|
294
291
|
)
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
'error' => "The Performance Stats feature is disabled"
|
299
|
-
)
|
300
|
-
end
|
301
|
-
|
302
|
-
it "doesn't send route stats when current environment is ignored" do
|
303
|
-
Airbrake::Config.instance.merge(
|
304
|
-
performance_stats: true, environment: 'test', ignore_environments: %w[test]
|
305
|
-
)
|
306
|
-
|
307
|
-
promise = subject.notify(
|
308
|
-
Airbrake::Request.new(
|
309
|
-
method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
|
310
|
-
)
|
311
|
-
)
|
312
|
-
|
313
|
-
expect(a_request(:put, routes)).not_to have_been_made
|
314
|
-
expect(promise.value).to eq('error' => "current environment 'test' is ignored")
|
292
|
+
expect(Airbrake::Config.instance).to receive(:check_performance_options)
|
293
|
+
.with(request).and_return(Airbrake::Promise.new)
|
294
|
+
subject.notify(request)
|
315
295
|
end
|
316
296
|
|
317
297
|
it "sends environment when it's specified" do
|
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.
|
4
|
+
version: 4.6.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-
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree-jruby
|