bugsnag 2.5.1 → 2.6.0
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/CHANGELOG.md +9 -1
- data/README.md +10 -0
- data/VERSION +1 -1
- data/bugsnag.gemspec +1 -0
- data/lib/bugsnag.rb +4 -1
- data/lib/bugsnag/configuration.rb +6 -0
- data/lib/bugsnag/delivery.rb +18 -0
- data/lib/bugsnag/delivery/synchronous.rb +25 -0
- data/lib/bugsnag/delivery/thread_queue.rb +51 -0
- data/lib/bugsnag/notification.rb +55 -37
- data/lib/bugsnag/rack.rb +2 -2
- data/lib/bugsnag/rails.rb +28 -12
- data/lib/bugsnag/rails/action_controller_rescue.rb +28 -0
- data/lib/bugsnag/rake.rb +2 -0
- data/lib/bugsnag/resque.rb +1 -1
- data/spec/code_spec.rb +96 -0
- data/spec/fixtures/crashes/end_of_file.rb +9 -0
- data/spec/fixtures/crashes/short_file.rb +1 -0
- data/spec/fixtures/crashes/start_of_file.rb +9 -0
- data/spec/integration_spec.rb +1 -0
- data/spec/middleware_spec.rb +41 -39
- data/spec/notification_spec.rb +281 -275
- data/spec/rack_spec.rb +10 -9
- data/spec/spec_helper.rb +26 -6
- metadata +23 -3
- data/lib/bugsnag/queue.rb +0 -36
data/spec/rack_spec.rb
CHANGED
@@ -5,9 +5,9 @@ describe Bugsnag::Rack do
|
|
5
5
|
rack_env = {"key" => "value"}
|
6
6
|
app = lambda { |env| ['response', {}, env] }
|
7
7
|
rack_stack = Bugsnag::Rack.new(app)
|
8
|
-
|
8
|
+
|
9
9
|
response = rack_stack.call(rack_env)
|
10
|
-
|
10
|
+
|
11
11
|
expect(response).to eq(['response', {}, rack_env])
|
12
12
|
end
|
13
13
|
|
@@ -23,22 +23,23 @@ describe Bugsnag::Rack do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "delivers an exception if auto_notify is enabled" do
|
26
|
-
|
27
|
-
|
26
|
+
rack_stack.call(rack_env) rescue nil
|
27
|
+
|
28
|
+
expect(Bugsnag).to have_sent_notification{ |payload|
|
29
|
+
exception_class = payload["events"].first["exceptions"].first["errorClass"]
|
28
30
|
expect(exception_class).to eq(exception.class.to_s)
|
29
|
-
|
31
|
+
}
|
30
32
|
|
31
|
-
rack_stack.call(rack_env) rescue nil
|
32
33
|
end
|
33
|
-
|
34
|
+
|
34
35
|
it "does not deliver an exception if auto_notify is disabled" do
|
35
36
|
Bugsnag.configure do |config|
|
36
37
|
config.auto_notify = false
|
37
38
|
end
|
38
39
|
|
39
|
-
expect(Bugsnag::Notification).not_to receive(:deliver_exception_payload)
|
40
|
-
|
41
40
|
rack_stack.call(rack_env) rescue nil
|
41
|
+
|
42
|
+
expect(Bugsnag::Notification).not_to have_sent_notification
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,32 +1,52 @@
|
|
1
1
|
require 'bugsnag'
|
2
2
|
|
3
|
+
require 'webmock/rspec'
|
4
|
+
require 'rspec/expectations'
|
5
|
+
|
3
6
|
class BugsnagTestException < RuntimeError; end
|
4
7
|
|
5
8
|
def get_event_from_payload(payload)
|
6
|
-
expect(payload[
|
7
|
-
payload[
|
9
|
+
expect(payload["events"].size).to eq(1)
|
10
|
+
payload["events"].first
|
8
11
|
end
|
9
12
|
|
10
13
|
def get_exception_from_payload(payload)
|
11
14
|
event = get_event_from_payload(payload)
|
12
|
-
expect(event[
|
13
|
-
event[
|
15
|
+
expect(event["exceptions"].size).to eq(1)
|
16
|
+
event["exceptions"].last
|
17
|
+
end
|
18
|
+
|
19
|
+
def notify_test_exception(*args)
|
20
|
+
Bugsnag.notify(RuntimeError.new("test message"), *args)
|
14
21
|
end
|
15
22
|
|
16
23
|
RSpec.configure do |config|
|
17
24
|
config.order = "random"
|
18
|
-
|
25
|
+
|
19
26
|
config.before(:each) do
|
27
|
+
WebMock.stub_request(:post, "https://notify.bugsnag.com/")
|
28
|
+
|
20
29
|
Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
|
21
30
|
Bugsnag.configure do |config|
|
22
31
|
config.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
|
23
32
|
config.release_stage = "production"
|
33
|
+
config.delivery_method = :synchronous
|
24
34
|
# silence logger in tests
|
25
35
|
config.logger = Logger.new(StringIO.new)
|
26
36
|
end
|
27
37
|
end
|
28
|
-
|
38
|
+
|
29
39
|
config.after(:each) do
|
30
40
|
Bugsnag.configuration.clear_request_data
|
31
41
|
end
|
32
42
|
end
|
43
|
+
|
44
|
+
def have_sent_notification(&matcher)
|
45
|
+
have_requested(:post, "https://notify.bugsnag.com/").with do |request|
|
46
|
+
if matcher
|
47
|
+
matcher.call JSON.parse(request.body)
|
48
|
+
else
|
49
|
+
true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: webmock
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
103
117
|
description: Ruby notifier for bugsnag.com
|
104
118
|
email: james@bugsnag.com
|
105
119
|
executables: []
|
@@ -125,6 +139,9 @@ files:
|
|
125
139
|
- lib/bugsnag/configuration.rb
|
126
140
|
- lib/bugsnag/delay/resque.rb
|
127
141
|
- lib/bugsnag/delayed_job.rb
|
142
|
+
- lib/bugsnag/delivery.rb
|
143
|
+
- lib/bugsnag/delivery/synchronous.rb
|
144
|
+
- lib/bugsnag/delivery/thread_queue.rb
|
128
145
|
- lib/bugsnag/deploy.rb
|
129
146
|
- lib/bugsnag/helpers.rb
|
130
147
|
- lib/bugsnag/mailman.rb
|
@@ -136,7 +153,6 @@ files:
|
|
136
153
|
- lib/bugsnag/middleware/warden_user.rb
|
137
154
|
- lib/bugsnag/middleware_stack.rb
|
138
155
|
- lib/bugsnag/notification.rb
|
139
|
-
- lib/bugsnag/queue.rb
|
140
156
|
- lib/bugsnag/rack.rb
|
141
157
|
- lib/bugsnag/rails.rb
|
142
158
|
- lib/bugsnag/rails/action_controller_rescue.rb
|
@@ -152,6 +168,10 @@ files:
|
|
152
168
|
- lib/bugsnag/version.rb
|
153
169
|
- lib/generators/bugsnag/bugsnag_generator.rb
|
154
170
|
- rails/init.rb
|
171
|
+
- spec/code_spec.rb
|
172
|
+
- spec/fixtures/crashes/end_of_file.rb
|
173
|
+
- spec/fixtures/crashes/short_file.rb
|
174
|
+
- spec/fixtures/crashes/start_of_file.rb
|
155
175
|
- spec/helper_spec.rb
|
156
176
|
- spec/integration_spec.rb
|
157
177
|
- spec/middleware_spec.rb
|
data/lib/bugsnag/queue.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
|
3
|
-
module Bugsnag
|
4
|
-
class Queue < ::Queue
|
5
|
-
MAX_OUTSTANDING_REQUESTS = 100
|
6
|
-
STOP = Object.new
|
7
|
-
|
8
|
-
def push(*)
|
9
|
-
if length > MAX_OUTSTANDING_REQUESTS
|
10
|
-
Bugsnag.warn("Dropping notification, #{length} outstanding requests")
|
11
|
-
return
|
12
|
-
end
|
13
|
-
@thread ||= create_processor
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def create_processor
|
20
|
-
t = Thread.new do
|
21
|
-
while x = pop
|
22
|
-
break if x == STOP
|
23
|
-
x.call
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
at_exit do
|
28
|
-
Bugsnag.warn("Waiting for #{length} outstanding request(s)") unless empty?
|
29
|
-
push STOP
|
30
|
-
t.join
|
31
|
-
end
|
32
|
-
|
33
|
-
t
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|