crashbreak 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/crashbreak.gemspec +2 -0
- data/lib/crashbreak.rb +5 -0
- data/lib/crashbreak/async_exception_notifier.rb +16 -0
- data/lib/crashbreak/exception_catcher_middleware.rb +28 -1
- data/lib/crashbreak/tiny_exception_notifier.rb +18 -0
- data/lib/crashbreak/version.rb +1 -1
- data/lib/tasks/crashbreak.rake +4 -1
- data/spec/lib/async_exception_notifier_spec.rb +19 -0
- metadata +34 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d943a7d2f3a78353805545a04922acdf8e841d79
|
4
|
+
data.tar.gz: 5eb0864882ebfcc111be7bfd9e2639b0e449fd67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801a7c44cc6ea929bc54aeecfb0b89b45989c91006a487d215e9b46b7b9d56cf7b9dcff13c1175d326bb763be0a63e99ab3392dad323830aff1b035302dab90b
|
7
|
+
data.tar.gz: 23cc67630df928d9b638a758563c7300115d4eb1bafd507375dada7f1bc2bdf53419603ce97b12249e9150606e9399f9493618bc567495e9435a45bd1c981979
|
data/crashbreak.gemspec
CHANGED
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_runtime_dependency 'request_store', '>= 0'
|
29
29
|
spec.add_runtime_dependency 'octokit', '>= 0'
|
30
30
|
spec.add_runtime_dependency 'aws-sdk', '~> 2'
|
31
|
+
spec.add_runtime_dependency 'sidekiq', '>= 0'
|
32
|
+
spec.add_runtime_dependency 'oj', '>= 0'
|
31
33
|
end
|
data/lib/crashbreak.rb
CHANGED
@@ -3,6 +3,9 @@ require 'faraday'
|
|
3
3
|
require 'request_store'
|
4
4
|
require 'octokit'
|
5
5
|
require 'aws-sdk'
|
6
|
+
require 'sidekiq'
|
7
|
+
require 'oj'
|
8
|
+
|
6
9
|
require 'crashbreak/version'
|
7
10
|
require 'crashbreak/exception_notifier'
|
8
11
|
require 'crashbreak/formatters/basic_formatter'
|
@@ -19,6 +22,8 @@ require 'crashbreak/dumpers_data_repository'
|
|
19
22
|
require 'crashbreak/request_parser'
|
20
23
|
require 'crashbreak/github_integration_service'
|
21
24
|
require 'crashbreak/AWS'
|
25
|
+
require 'crashbreak/async_exception_notifier'
|
26
|
+
require 'crashbreak/tiny_exception_notifier'
|
22
27
|
|
23
28
|
require 'dumpers/database_dumper'
|
24
29
|
require 'dumpers/request_dumper'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Crashbreak
|
2
|
+
class AsyncExceptionNotifier
|
3
|
+
include Sidekiq::Worker
|
4
|
+
|
5
|
+
def perform(request_store_data)
|
6
|
+
RequestStore.store.merge!(Oj.load(request_store_data))
|
7
|
+
exception_notifier.notify
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def exception_notifier
|
13
|
+
@exception_notifier ||= ExceptionNotifier.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -11,13 +11,40 @@ module Crashbreak
|
|
11
11
|
RequestStore.store[:exception] = exception
|
12
12
|
store_variables_from_env env
|
13
13
|
|
14
|
-
|
14
|
+
notify_about_exception
|
15
15
|
raise
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
def notify_about_exception
|
22
|
+
if exception_notifier.respond_to?(:perform_async)
|
23
|
+
prepare_request_store_for_serialization
|
24
|
+
exception_notifier.perform_async Oj.dump(RequestStore.store)
|
25
|
+
else
|
26
|
+
exception_notifier.notify
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepare_request_store_for_serialization
|
31
|
+
request_hash = {}
|
32
|
+
|
33
|
+
RequestStore.store[:request].env.each do |key, value|
|
34
|
+
request_hash[key] = value.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
RequestStore.store[:request] = request(request_hash)
|
38
|
+
|
39
|
+
controller = RequestStore.store[:controller].dup
|
40
|
+
|
41
|
+
[:@_env, :@_request, :@_response, :@_lookup_context].each do |variable_symbol|
|
42
|
+
controller.instance_variable_set(variable_symbol, nil)
|
43
|
+
end
|
44
|
+
|
45
|
+
RequestStore.store[:controller] = controller
|
46
|
+
end
|
47
|
+
|
21
48
|
def exception_notifier
|
22
49
|
Crashbreak.configure.exception_notifier
|
23
50
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Crashbreak
|
2
|
+
class TinyExceptionNotifier < ExceptionNotifier
|
3
|
+
def notify(exception = RequestStore.store[:exception])
|
4
|
+
RequestStore.store[:exception] = exception
|
5
|
+
exceptions_repository.create serialize_exception
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def serializers
|
11
|
+
[BasicInformationFormatter.new]
|
12
|
+
end
|
13
|
+
|
14
|
+
def dumpers
|
15
|
+
[]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/crashbreak/version.rb
CHANGED
data/lib/tasks/crashbreak.rake
CHANGED
@@ -5,7 +5,10 @@ namespace :crashbreak do
|
|
5
5
|
begin
|
6
6
|
raise CrashbreakTestError.new('If you see this message everything works fine!')
|
7
7
|
rescue CrashbreakTestError => error
|
8
|
-
|
8
|
+
RequestStore.store[:exception] = error
|
9
|
+
RequestStore.store[:request] = Rack::Request.new({})
|
10
|
+
|
11
|
+
Crashbreak.configure.exception_notifier.notify
|
9
12
|
end
|
10
13
|
|
11
14
|
puts 'Done, now check if error exists on crashbreak.com!'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe Crashbreak::AsyncExceptionNotifier do
|
2
|
+
subject { described_class.new }
|
3
|
+
let(:request_data) { Oj.dump(Hash[request: 'request_info', current_user: 'current_user_data']) }
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
expect_any_instance_of(Crashbreak::ExceptionNotifier).to receive(:notify).and_return(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'calls notify on exception notifier' do
|
10
|
+
subject.perform(request_data)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'sets request_data in RequestStore' do
|
14
|
+
expect(RequestStore.store[:request]).to eq('request_info')
|
15
|
+
expect(RequestStore.store[:current_user]).to eq('current_user_data')
|
16
|
+
|
17
|
+
subject.perform(request_data)
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crashbreak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Janeczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,34 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '2'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sidekiq
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: oj
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
167
195
|
description: Maybe later... :)
|
168
196
|
email:
|
169
197
|
- michal.janeczek@ymail.com
|
@@ -181,6 +209,7 @@ files:
|
|
181
209
|
- crashbreak.gemspec
|
182
210
|
- lib/crashbreak.rb
|
183
211
|
- lib/crashbreak/AWS.rb
|
212
|
+
- lib/crashbreak/async_exception_notifier.rb
|
184
213
|
- lib/crashbreak/config/configurable.rb
|
185
214
|
- lib/crashbreak/config/configurator.rb
|
186
215
|
- lib/crashbreak/dumpers_data_repository.rb
|
@@ -195,6 +224,7 @@ files:
|
|
195
224
|
- lib/crashbreak/formatters/summary_formatter.rb
|
196
225
|
- lib/crashbreak/github_integration_service.rb
|
197
226
|
- lib/crashbreak/request_parser.rb
|
227
|
+
- lib/crashbreak/tiny_exception_notifier.rb
|
198
228
|
- lib/crashbreak/version.rb
|
199
229
|
- lib/dumpers/database_dumper.rb
|
200
230
|
- lib/dumpers/request_dumper.rb
|
@@ -208,6 +238,7 @@ files:
|
|
208
238
|
- lib/tasks/crashbreak.rake
|
209
239
|
- spec/dumpers/request_dumper_spec.rb
|
210
240
|
- spec/features/sending_error_report_spec.rb
|
241
|
+
- spec/lib/async_exception_notifier_spec.rb
|
211
242
|
- spec/lib/config/configurable_spec.rb
|
212
243
|
- spec/lib/config/configurator_spec.rb
|
213
244
|
- spec/lib/dumpers_data_repository_spec.rb
|
@@ -254,6 +285,7 @@ summary: Take a break from crashes!
|
|
254
285
|
test_files:
|
255
286
|
- spec/dumpers/request_dumper_spec.rb
|
256
287
|
- spec/features/sending_error_report_spec.rb
|
288
|
+
- spec/lib/async_exception_notifier_spec.rb
|
257
289
|
- spec/lib/config/configurable_spec.rb
|
258
290
|
- spec/lib/config/configurator_spec.rb
|
259
291
|
- spec/lib/dumpers_data_repository_spec.rb
|