bugloco 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bugloco.rb +10 -8
- data/lib/bugloco/configuration.rb +1 -1
- data/lib/bugloco/notice.rb +14 -0
- data/lib/bugloco/rails/middleware.rb +17 -2
- data/lib/bugloco/version.rb +1 -1
- data/spec/bugloco/notice_spec.rb +8 -3
- data/spec/bugloco_spec.rb +1 -1
- 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: 620a8abfc5db039673d1e1d2f839613e6f89c7a7
|
4
|
+
data.tar.gz: 542dea7518cba073ff850e239b79f46e7816a95c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7209e52c1deb733a06f1d9ae64980cb7a13875211e2c87bab4f41391b8971e367519dc466d0fd9edd8b7785ff3d44abb7e4e2cdbe0da4d856ca60699d5e33fb6
|
7
|
+
data.tar.gz: 1c9270bb5e710aa891c05b2ccbd0382155523d31d71d4a17d033b9a4e3cb764de550f90aab6f8c06e1a40a06adccbbd5d9720d95c9996f3bc59dbb10328e241c
|
data/lib/bugloco.rb
CHANGED
@@ -20,16 +20,20 @@ module Bugloco
|
|
20
20
|
Errno::ECONNREFUSED,
|
21
21
|
OpenSSL::SSL::SSLError].freeze
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def report_notice_or_ignore(exception, options = {})
|
24
|
+
notice = Bugloco::Notice.new(exception, options)
|
25
|
+
report_notice(notice) unless notice.ignore?
|
26
|
+
end
|
27
|
+
|
28
|
+
def report_notice(notice)
|
29
|
+
encoded_notice = notice.to_pb
|
30
|
+
encoded_response = send_notice(encoded_notice)
|
27
31
|
|
28
32
|
if encoded_response
|
29
33
|
response = Bugloco::Proto::Response.new.
|
30
34
|
parse_from_string(encoded_response)
|
31
35
|
|
32
|
-
response
|
36
|
+
response
|
33
37
|
else
|
34
38
|
nil
|
35
39
|
end
|
@@ -43,12 +47,10 @@ module Bugloco
|
|
43
47
|
|
44
48
|
private
|
45
49
|
|
46
|
-
def send_notice(encoded_notice
|
50
|
+
def send_notice(encoded_notice)
|
47
51
|
response = http_connection.post(api_url.path, encoded_notice, headers)
|
48
52
|
response.body
|
49
53
|
rescue *HTTP_ERRORS => e
|
50
|
-
# log e
|
51
|
-
|
52
54
|
nil
|
53
55
|
end
|
54
56
|
|
data/lib/bugloco/notice.rb
CHANGED
@@ -7,6 +7,16 @@ module Bugloco
|
|
7
7
|
|
8
8
|
EXCEPTION_REGEX = /^(?<path>[^:]*):(?<line_number>[0-9]*):in `(?<function_name>[^']*)'$/
|
9
9
|
|
10
|
+
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
11
|
+
'ActionController::RoutingError',
|
12
|
+
'ActionController::InvalidAuthenticityToken',
|
13
|
+
'CGI::Session::CookieStore::TamperedWithCookie',
|
14
|
+
'ActionController::UnknownHttpMethod',
|
15
|
+
'ActionController::UnknownAction',
|
16
|
+
'AbstractController::ActionNotFound',
|
17
|
+
'Mongoid::Errors::DocumentNotFound',
|
18
|
+
'ActionController::UnknownFormat']
|
19
|
+
|
10
20
|
def initialize(exception, options = {})
|
11
21
|
@exception = exception
|
12
22
|
@options = options
|
@@ -18,6 +28,10 @@ module Bugloco
|
|
18
28
|
@pb ||= proto_message.serialize_to_string
|
19
29
|
end
|
20
30
|
|
31
|
+
def ignore?
|
32
|
+
IGNORE_DEFAULT.include?(@exception.class.to_s)
|
33
|
+
end
|
34
|
+
|
21
35
|
def proto_message
|
22
36
|
return @proto_message unless @proto_message.nil?
|
23
37
|
|
@@ -9,14 +9,29 @@ module Bugloco
|
|
9
9
|
response = @app.call(env)
|
10
10
|
|
11
11
|
if framework_exception = env["action_dispatch.exception"]
|
12
|
-
env["bugloco.error_id"] =
|
12
|
+
env["bugloco.error_id"] = report_exception_or_ignore(framework_exception, env)
|
13
13
|
end
|
14
14
|
|
15
15
|
response
|
16
16
|
rescue Exception => exception
|
17
|
-
env["bugloco.error_id"] =
|
17
|
+
env["bugloco.error_id"] = report_exception_or_ignore(exception, env)
|
18
|
+
|
18
19
|
raise exception
|
19
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def report_exception_or_ignore(exception, env)
|
25
|
+
response = Bugloco.report_notice_or_ignore(exception, rack_env: env)
|
26
|
+
|
27
|
+
if response
|
28
|
+
if response.status == Bugloco::Proto::Status::SUCCESS
|
29
|
+
response.notice_id
|
30
|
+
else
|
31
|
+
# Report the issue
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
20
35
|
end
|
21
36
|
end
|
22
37
|
end
|
data/lib/bugloco/version.rb
CHANGED
data/spec/bugloco/notice_spec.rb
CHANGED
@@ -43,15 +43,20 @@ describe Bugloco::Notice do
|
|
43
43
|
}
|
44
44
|
|
45
45
|
@rack_env_extra = {}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
46
|
end
|
50
47
|
|
51
48
|
after do
|
52
49
|
@extra_env.each {|k, _| ENV[k] = nil}
|
53
50
|
end
|
54
51
|
|
52
|
+
it "should ignore ActiveRecord::RecordNotFound" do
|
53
|
+
module ::ActiveRecord; class RecordNotFound < Exception; end; end
|
54
|
+
exception = ::ActiveRecord::RecordNotFound.new
|
55
|
+
|
56
|
+
notice = Bugloco::Notice.new(exception)
|
57
|
+
expect(notice.ignore?).to be_truthy
|
58
|
+
end
|
59
|
+
|
55
60
|
it "should include the company" do
|
56
61
|
@api_key = "secret_key"
|
57
62
|
Bugloco.config do |config|
|
data/spec/bugloco_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugloco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wael M. Nasreddine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|