airbrake-ruby 4.3.0-java → 4.4.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.rb +19 -6
- data/lib/airbrake-ruby/notice.rb +3 -6
- data/lib/airbrake-ruby/performance_breakdown.rb +1 -0
- data/lib/airbrake-ruby/query.rb +1 -0
- data/lib/airbrake-ruby/request.rb +1 -0
- data/lib/airbrake-ruby/stashable.rb +15 -0
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +108 -0
- data/spec/notice_spec.rb +3 -5
- data/spec/performance_breakdown_spec.rb +12 -0
- data/spec/query_spec.rb +11 -0
- data/spec/request_spec.rb +11 -0
- data/spec/stashable_spec.rb +23 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a042baeefd9b06eb7c57113c0281dfa5b5ea6916
|
4
|
+
data.tar.gz: e5cbde788fce2450987c0bb0bdf6246f56566b75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d02a2bd6ac6612a0fead741833f4a2afb44e1544c49bde1f2c2b757a408f28e2f231fb531824707cbc2692581b2348fcb27a9779855221b6e3c58db373a0f54
|
7
|
+
data.tar.gz: f8eb77c77d9727a785f197a23c50824c1e094f404dbe3eb3b115a6c0be343ad65746076e0ce13597c165b096af18cce1c6fce23c4a474e94bb061a02b20d5b90
|
data/lib/airbrake-ruby.rb
CHANGED
@@ -8,6 +8,7 @@ require 'time'
|
|
8
8
|
|
9
9
|
require 'airbrake-ruby/version'
|
10
10
|
require 'airbrake-ruby/loggable'
|
11
|
+
require 'airbrake-ruby/stashable'
|
11
12
|
require 'airbrake-ruby/config'
|
12
13
|
require 'airbrake-ruby/config/validator'
|
13
14
|
require 'airbrake-ruby/promise'
|
@@ -346,11 +347,15 @@ module Airbrake
|
|
346
347
|
# (optional)
|
347
348
|
# @option request_info [Date] :start_time When the request started
|
348
349
|
# @option request_info [Time] :end_time When the request ended (optional)
|
350
|
+
# @param [Hash] stash What needs to be appeneded to the stash, so it's
|
351
|
+
# available in filters
|
349
352
|
# @return [void]
|
350
353
|
# @since v3.0.0
|
351
354
|
# @see Airbrake::PerformanceNotifier#notify
|
352
|
-
def notify_request(request_info)
|
353
|
-
|
355
|
+
def notify_request(request_info, stash = {})
|
356
|
+
request = Request.new(request_info)
|
357
|
+
request.stash.merge!(stash)
|
358
|
+
performance_notifier.notify(request)
|
354
359
|
end
|
355
360
|
|
356
361
|
# Increments SQL statistics of a certain +query+ that was invoked on
|
@@ -377,11 +382,15 @@ module Airbrake
|
|
377
382
|
# @option request_info [String] :query The query that was executed
|
378
383
|
# @option request_info [Date] :start_time When the query started executing
|
379
384
|
# @option request_info [Time] :end_time When the query finished (optional)
|
385
|
+
# @param [Hash] stash What needs to be appeneded to the stash, so it's
|
386
|
+
# available in filters
|
380
387
|
# @return [void]
|
381
388
|
# @since v3.2.0
|
382
389
|
# @see Airbrake::PerformanceNotifier#notify
|
383
|
-
def notify_query(query_info)
|
384
|
-
|
390
|
+
def notify_query(query_info, stash = {})
|
391
|
+
query = Query.new(query_info)
|
392
|
+
query.stash.merge!(stash)
|
393
|
+
performance_notifier.notify(query)
|
385
394
|
end
|
386
395
|
|
387
396
|
# Increments performance breakdown statistics of a certain route.
|
@@ -402,10 +411,14 @@ module Airbrake
|
|
402
411
|
# @option breakdown_info [String] :response_type
|
403
412
|
# @option breakdown_info [Array<Hash{Symbol=>Float}>] :groups
|
404
413
|
# @option breakdown_info [Date] :start_time
|
414
|
+
# @param [Hash] stash What needs to be appeneded to the stash, so it's
|
415
|
+
# available in filters
|
405
416
|
# @return [void]
|
406
417
|
# @since v4.2.0
|
407
|
-
def notify_performance_breakdown(breakdown_info)
|
408
|
-
|
418
|
+
def notify_performance_breakdown(breakdown_info, stash = {})
|
419
|
+
performance_breakdown = PerformanceBreakdown.new(breakdown_info)
|
420
|
+
performance_breakdown.stash.merge!(stash)
|
421
|
+
performance_notifier.notify(performance_breakdown)
|
409
422
|
end
|
410
423
|
|
411
424
|
# Runs a callback before {.notify_request} or {.notify_query} kicks in. This
|
data/lib/airbrake-ruby/notice.rb
CHANGED
@@ -51,11 +51,7 @@ module Airbrake
|
|
51
51
|
|
52
52
|
include Ignorable
|
53
53
|
include Loggable
|
54
|
-
|
55
|
-
# @since v1.7.0
|
56
|
-
# @return [Hash{Symbol=>Object}] the hash with arbitrary objects to be used
|
57
|
-
# in filters
|
58
|
-
attr_reader :stash
|
54
|
+
include Stashable
|
59
55
|
|
60
56
|
# @api private
|
61
57
|
def initialize(exception, params = {})
|
@@ -69,8 +65,9 @@ module Airbrake
|
|
69
65
|
session: {},
|
70
66
|
params: params
|
71
67
|
}
|
72
|
-
@stash = { exception: exception }
|
73
68
|
@truncator = Airbrake::Truncator.new(PAYLOAD_MAX_SIZE)
|
69
|
+
|
70
|
+
stash[:exception] = exception
|
74
71
|
end
|
75
72
|
|
76
73
|
# Converts the notice to JSON. Calls +to_json+ on each object inside
|
data/lib/airbrake-ruby/query.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Airbrake
|
2
|
+
# Stashable should be included in any class that wants the ability to stash
|
3
|
+
# arbitrary objects. It is mainly used by data objects that users can access
|
4
|
+
# through filters.
|
5
|
+
#
|
6
|
+
# @since v4.4.0
|
7
|
+
# @api private
|
8
|
+
module Stashable
|
9
|
+
# @return [Hash{Symbol=>Object}] the hash with arbitrary objects to be used
|
10
|
+
# in filters
|
11
|
+
def stash
|
12
|
+
@stash ||= {}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/airbrake_spec.rb
CHANGED
@@ -195,6 +195,114 @@ RSpec.describe Airbrake do
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
+
describe "#notify_request" do
|
199
|
+
context "when :stash key is not provided" do
|
200
|
+
it "doesn't add anything to the stash of the request" do
|
201
|
+
expect(described_class.performance_notifier).to receive(:notify) do |request|
|
202
|
+
expect(request.stash).to be_empty
|
203
|
+
end
|
204
|
+
|
205
|
+
described_class.notify_request(
|
206
|
+
method: 'GET',
|
207
|
+
route: '/',
|
208
|
+
status_code: 200,
|
209
|
+
start_time: Time.now
|
210
|
+
)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context "when :stash key is provided" do
|
215
|
+
it "adds the value as the stash of the request" do
|
216
|
+
expect(described_class.performance_notifier).to receive(:notify) do |request|
|
217
|
+
expect(request.stash).to eq(request_id: 1)
|
218
|
+
end
|
219
|
+
|
220
|
+
described_class.notify_request(
|
221
|
+
{
|
222
|
+
method: 'GET',
|
223
|
+
route: '/',
|
224
|
+
status_code: 200,
|
225
|
+
start_time: Time.now
|
226
|
+
},
|
227
|
+
request_id: 1
|
228
|
+
)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#notify_query" do
|
234
|
+
context "when :stash key is not provided" do
|
235
|
+
it "doesn't add anything to the stash of the query" do
|
236
|
+
expect(described_class.performance_notifier).to receive(:notify) do |query|
|
237
|
+
expect(query.stash).to be_empty
|
238
|
+
end
|
239
|
+
|
240
|
+
described_class.notify_query(
|
241
|
+
method: 'GET',
|
242
|
+
route: '/',
|
243
|
+
query: '',
|
244
|
+
start_time: Time.now
|
245
|
+
)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context "when :stash key is provided" do
|
250
|
+
it "adds the value as the stash of the query" do
|
251
|
+
expect(described_class.performance_notifier).to receive(:notify) do |query|
|
252
|
+
expect(query.stash).to eq(request_id: 1)
|
253
|
+
end
|
254
|
+
|
255
|
+
described_class.notify_query(
|
256
|
+
{
|
257
|
+
method: 'GET',
|
258
|
+
route: '/',
|
259
|
+
query: '',
|
260
|
+
start_time: Time.now
|
261
|
+
},
|
262
|
+
request_id: 1
|
263
|
+
)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe "#notify_performance_breakdown" do
|
269
|
+
context "when :stash key is not provided" do
|
270
|
+
it "doesn't add anything to the stash of the performance breakdown" do
|
271
|
+
expect(described_class.performance_notifier).to receive(:notify) do |query|
|
272
|
+
expect(query.stash).to be_empty
|
273
|
+
end
|
274
|
+
|
275
|
+
described_class.notify_query(
|
276
|
+
method: 'GET',
|
277
|
+
route: '/',
|
278
|
+
query: '',
|
279
|
+
start_time: Time.now
|
280
|
+
)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
context "when :stash key is provided" do
|
285
|
+
it "adds the value as the stash of the performance breakdown" do
|
286
|
+
expect(
|
287
|
+
described_class.performance_notifier
|
288
|
+
).to receive(:notify) do |performance_breakdown|
|
289
|
+
expect(performance_breakdown.stash).to eq(request_id: 1)
|
290
|
+
end
|
291
|
+
|
292
|
+
described_class.notify_performance_breakdown(
|
293
|
+
{
|
294
|
+
method: 'GET',
|
295
|
+
route: '/',
|
296
|
+
response_type: :html,
|
297
|
+
groups: {},
|
298
|
+
start_time: Time.now
|
299
|
+
},
|
300
|
+
request_id: 1
|
301
|
+
)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
198
306
|
describe ".performance_notifier" do
|
199
307
|
it "returns a performance notifier" do
|
200
308
|
expect(described_class.performance_notifier)
|
data/spec/notice_spec.rb
CHANGED
@@ -289,10 +289,8 @@ RSpec.describe Airbrake::Notice do
|
|
289
289
|
end
|
290
290
|
|
291
291
|
describe "#stash" do
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
expect(notice.stash[:bingo_object]).to eql(obj)
|
296
|
-
end
|
292
|
+
subject { described_class.new(AirbrakeTestError.new) }
|
293
|
+
|
294
|
+
it { is_expected.to respond_to(:stash) }
|
297
295
|
end
|
298
296
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
RSpec.describe Airbrake::PerformanceBreakdown do
|
2
|
+
describe "#stash" do
|
3
|
+
subject do
|
4
|
+
described_class.new(
|
5
|
+
method: 'GET', route: '/', response_type: '', groups: {},
|
6
|
+
start_time: Time.now
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
it { is_expected.to respond_to(:stash) }
|
11
|
+
end
|
12
|
+
end
|
data/spec/query_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
RSpec.describe Airbrake::Stashable do
|
2
|
+
let(:klass) do
|
3
|
+
mod = described_class
|
4
|
+
Class.new { include(mod) }
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "#stash" do
|
8
|
+
subject { klass.new }
|
9
|
+
|
10
|
+
it "returns a hash" do
|
11
|
+
expect(subject.stash).to be_a(Hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns an empty hash" do
|
15
|
+
expect(subject.stash).to be_empty
|
16
|
+
end
|
17
|
+
|
18
|
+
it "remembers what was put in the stash" do
|
19
|
+
subject.stash[:foo] = 1
|
20
|
+
expect(subject.stash[:foo]).to eq(1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
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.4.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-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree-jruby
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/airbrake-ruby/query.rb
|
77
77
|
- lib/airbrake-ruby/request.rb
|
78
78
|
- lib/airbrake-ruby/response.rb
|
79
|
+
- lib/airbrake-ruby/stashable.rb
|
79
80
|
- lib/airbrake-ruby/stat.rb
|
80
81
|
- lib/airbrake-ruby/sync_sender.rb
|
81
82
|
- lib/airbrake-ruby/tdigest.rb
|
@@ -120,10 +121,14 @@ files:
|
|
120
121
|
- spec/notice_notifier_spec.rb
|
121
122
|
- spec/notice_notifier_spec/options_spec.rb
|
122
123
|
- spec/notice_spec.rb
|
124
|
+
- spec/performance_breakdown_spec.rb
|
123
125
|
- spec/performance_notifier_spec.rb
|
124
126
|
- spec/promise_spec.rb
|
127
|
+
- spec/query_spec.rb
|
128
|
+
- spec/request_spec.rb
|
125
129
|
- spec/response_spec.rb
|
126
130
|
- spec/spec_helper.rb
|
131
|
+
- spec/stashable_spec.rb
|
127
132
|
- spec/stat_spec.rb
|
128
133
|
- spec/sync_sender_spec.rb
|
129
134
|
- spec/tdigest_spec.rb
|
@@ -174,6 +179,7 @@ test_files:
|
|
174
179
|
- spec/spec_helper.rb
|
175
180
|
- spec/notice_spec.rb
|
176
181
|
- spec/config_spec.rb
|
182
|
+
- spec/performance_breakdown_spec.rb
|
177
183
|
- spec/tdigest_spec.rb
|
178
184
|
- spec/async_sender_spec.rb
|
179
185
|
- spec/stat_spec.rb
|
@@ -189,6 +195,7 @@ test_files:
|
|
189
195
|
- spec/airbrake_spec.rb
|
190
196
|
- spec/nested_exception_spec.rb
|
191
197
|
- spec/timed_trace_spec.rb
|
198
|
+
- spec/request_spec.rb
|
192
199
|
- spec/filter_chain_spec.rb
|
193
200
|
- spec/response_spec.rb
|
194
201
|
- spec/file_cache.rb
|
@@ -201,4 +208,6 @@ test_files:
|
|
201
208
|
- spec/fixtures/project_root/vendor/bundle/ignored_file.rb
|
202
209
|
- spec/monotonic_time_spec.rb
|
203
210
|
- spec/inspectable_spec.rb
|
211
|
+
- spec/stashable_spec.rb
|
212
|
+
- spec/query_spec.rb
|
204
213
|
- spec/notice_notifier_spec/options_spec.rb
|