airbrake 7.1.1 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake.rb +1 -0
- data/lib/airbrake/sneakers.rb +19 -0
- data/lib/airbrake/version.rb +1 -1
- data/spec/unit/sneakers_spec.rb +71 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae253901ad2046c651692e110071b8754cbb129c
|
4
|
+
data.tar.gz: cc9f1fd544132f817105e4cebdd52a593e4c0a60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08ff586c61450878a3412b1f5ba56fa7a7fe9a10987bd1fc40c188a9d5d9122be9c6e8ccf35a8e53aebb2423dcc02e5b85091b6fa7947b7ab8e81293b306c89c'
|
7
|
+
data.tar.gz: af881b6164a18675dae6e8b9004b7c751c8927843dd9d5489b04cce1b821c10535c909dadc5304c7a7e514fa676310033b0ca673ea1a3bfbd26a4812e4d1030c
|
data/lib/airbrake.rb
CHANGED
@@ -19,6 +19,7 @@ require 'airbrake/resque' if defined?(Resque)
|
|
19
19
|
require 'airbrake/sidekiq' if defined?(Sidekiq)
|
20
20
|
require 'airbrake/shoryuken' if defined?(Shoryuken)
|
21
21
|
require 'airbrake/delayed_job' if defined?(Delayed)
|
22
|
+
require 'airbrake/sneakers' if defined?(Sneakers)
|
22
23
|
|
23
24
|
require 'airbrake/logger'
|
24
25
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Airbrake
|
2
|
+
module Sneakers
|
3
|
+
##
|
4
|
+
# Provides integration with Sneakers.
|
5
|
+
#
|
6
|
+
# @see https://github.com/jondot/sneakers
|
7
|
+
# @since v7.2.0
|
8
|
+
class ErrorReporter
|
9
|
+
def call(exception, worker = nil, **context)
|
10
|
+
Airbrake.notify(exception, context) do |notice|
|
11
|
+
notice[:context][:component] = 'sneakers'
|
12
|
+
notice[:context][:action] = worker.class.to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Sneakers.error_reporters << Airbrake::Sneakers::ErrorReporter.new
|
data/lib/airbrake/version.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sneakers'
|
3
|
+
require 'airbrake/sneakers'
|
4
|
+
|
5
|
+
RSpec.describe Airbrake::Sneakers::ErrorReporter do
|
6
|
+
let(:worker) do
|
7
|
+
queue = instance_double('queue')
|
8
|
+
allow(queue).to receive_messages(
|
9
|
+
name: 'test-queue',
|
10
|
+
opts: {},
|
11
|
+
exchange: instance_double('exchange')
|
12
|
+
)
|
13
|
+
|
14
|
+
Class.new do
|
15
|
+
include Sneakers::Worker
|
16
|
+
from_queue 'defaults'
|
17
|
+
|
18
|
+
def work(_)
|
19
|
+
raise 'oops error'
|
20
|
+
end
|
21
|
+
end.new(queue)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:error) { StandardError.new('Something is wrong') }
|
25
|
+
|
26
|
+
let(:endpoint) { 'https://airbrake.io/api/v3/projects/113743/notices' }
|
27
|
+
|
28
|
+
def wait_for_a_request_with_body(body)
|
29
|
+
wait_for(a_request(:post, endpoint).with(body: body)).to have_been_made.once
|
30
|
+
end
|
31
|
+
|
32
|
+
before do
|
33
|
+
stub_request(:post, endpoint).to_return(status: 201, body: '{}')
|
34
|
+
|
35
|
+
Sneakers.configure(daemonize: true, log: '/dev/null')
|
36
|
+
Sneakers::Worker.configure_metrics
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
Sneakers.clear!
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should send a notice" do
|
44
|
+
handler = instance_double('handler')
|
45
|
+
expect(handler).to receive(:error).once
|
46
|
+
allow(worker.logger).to receive(:error)
|
47
|
+
worker.do_work(nil, nil, "msg", handler)
|
48
|
+
|
49
|
+
wait_for_a_request_with_body(/"message":"oops\serror"/)
|
50
|
+
wait_for_a_request_with_body(/test-queue/)
|
51
|
+
wait_for_a_request_with_body(/"component":"sneakers"/)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should support call without worker" do
|
55
|
+
Airbrake::Sneakers::ErrorReporter.new.call(error, message: 'my_glorious_message')
|
56
|
+
wait_for_a_request_with_body(/"message":"Something is wrong"/)
|
57
|
+
wait_for_a_request_with_body(/"params":{"message":"my_glorious_message"}/)
|
58
|
+
# worker class is nil so action is NilClass
|
59
|
+
wait_for_a_request_with_body(/"action":"NilClass"/)
|
60
|
+
wait_for_a_request_with_body(/"component":"sneakers"/)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should support call with worker" do
|
64
|
+
Airbrake::Sneakers::ErrorReporter.new.call(error, '', message: 'my_special_message')
|
65
|
+
wait_for_a_request_with_body(/"message":"Something is wrong"/)
|
66
|
+
wait_for_a_request_with_body(/"params":{"message":"my_special_message"}/)
|
67
|
+
# worker class is a String so action is String
|
68
|
+
wait_for_a_request_with_body(/"action":"String"/)
|
69
|
+
wait_for_a_request_with_body(/"component":"sneakers"/)
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.2.0
|
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:
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake-ruby
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sneakers
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: nokogiri
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,6 +251,7 @@ files:
|
|
237
251
|
- lib/airbrake/resque.rb
|
238
252
|
- lib/airbrake/shoryuken.rb
|
239
253
|
- lib/airbrake/sidekiq.rb
|
254
|
+
- lib/airbrake/sneakers.rb
|
240
255
|
- lib/airbrake/version.rb
|
241
256
|
- lib/generators/airbrake_generator.rb
|
242
257
|
- lib/generators/airbrake_initializer.rb.erb
|
@@ -268,6 +283,7 @@ files:
|
|
268
283
|
- spec/unit/rake/tasks_spec.rb
|
269
284
|
- spec/unit/shoryuken_spec.rb
|
270
285
|
- spec/unit/sidekiq_spec.rb
|
286
|
+
- spec/unit/sneakers_spec.rb
|
271
287
|
homepage: https://airbrake.io
|
272
288
|
licenses:
|
273
289
|
- MIT
|
@@ -322,3 +338,4 @@ test_files:
|
|
322
338
|
- spec/unit/rake/tasks_spec.rb
|
323
339
|
- spec/unit/shoryuken_spec.rb
|
324
340
|
- spec/unit/sidekiq_spec.rb
|
341
|
+
- spec/unit/sneakers_spec.rb
|