skylight 0.3.0.rc.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skylight/railtie.rb +2 -0
- data/lib/skylight/util/http.rb +15 -9
- data/lib/skylight/version.rb +1 -1
- data/lib/skylight/worker/collector.rb +15 -8
- data/lib/skylight/worker/server.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b4298b0fe8f4bccf1697e4ef0e46812b551cab8
|
4
|
+
data.tar.gz: 1f6b6bdf4a985fb43df3a3a39a4e134e047cdc00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 333807718ef1d39e532506dbae88dd1e5b3a46ec44e87c767ba1673d73547e8a200480fac36267188b49d80f53e5951293eb0f7ee908b496cbc83b6bdc629c97
|
7
|
+
data.tar.gz: c8dfc5041e90345954f94c57afff9314230f7b230bc59e6197ea0aea6b7a7a76f29a3d53c6b001581bac4fbb26362a8ed72193f46ffddbea951b8a27ef6d91b0
|
data/lib/skylight/railtie.rb
CHANGED
@@ -24,6 +24,8 @@ module Skylight
|
|
24
24
|
|
25
25
|
puts "[SKYLIGHT] [#{Skylight::VERSION}] Skylight agent enabled"
|
26
26
|
end
|
27
|
+
elsif !Rails.env.test? && Rails.env.development?
|
28
|
+
puts "[SKYLIGHT] [#{Skylight::VERSION}] You are running in the #{Rails.env} environment but haven't added it to config.skylight.environments, so no data will be sent to skylight.io."
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
data/lib/skylight/util/http.rb
CHANGED
@@ -48,10 +48,6 @@ module Skylight
|
|
48
48
|
def get(endpoint, hdrs = {})
|
49
49
|
request = build_request(Net::HTTP::Get, endpoint, hdrs)
|
50
50
|
execute(request)
|
51
|
-
rescue Exception => e
|
52
|
-
error "http GET failed; error=%s; msg=%s", e.class, e.message
|
53
|
-
t { e.backtrace.join("\n") }
|
54
|
-
nil
|
55
51
|
end
|
56
52
|
|
57
53
|
def post(endpoint, body, hdrs = {})
|
@@ -62,10 +58,6 @@ module Skylight
|
|
62
58
|
|
63
59
|
request = build_request(Net::HTTP::Post, endpoint, hdrs, body.bytesize)
|
64
60
|
execute(request, body)
|
65
|
-
rescue Exception => e
|
66
|
-
error "http POST failed; error=%s; msg=%s", e.class, e.message
|
67
|
-
t { e.backtrace.join("\n") }
|
68
|
-
nil
|
69
61
|
end
|
70
62
|
|
71
63
|
private
|
@@ -113,10 +105,14 @@ module Skylight
|
|
113
105
|
|
114
106
|
Response.new(res.code.to_i, res, res.body)
|
115
107
|
end
|
108
|
+
rescue Exception => e
|
109
|
+
error "http %s failed; error=%s; msg=%s", req.method, e.class, e.message
|
110
|
+
t { e.backtrace.join("\n") }
|
111
|
+
ErrorResponse.new(req.method, e)
|
116
112
|
end
|
117
113
|
|
118
114
|
class Response
|
119
|
-
attr_reader :status, :headers, :body
|
115
|
+
attr_reader :status, :headers, :body, :exception
|
120
116
|
|
121
117
|
def initialize(status, headers, body)
|
122
118
|
@status = status
|
@@ -164,6 +160,16 @@ module Skylight
|
|
164
160
|
end
|
165
161
|
end
|
166
162
|
|
163
|
+
class ErrorResponse < Struct.new(:request_method, :exception)
|
164
|
+
def status
|
165
|
+
nil
|
166
|
+
end
|
167
|
+
|
168
|
+
def success?
|
169
|
+
false
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
167
173
|
end
|
168
174
|
end
|
169
175
|
end
|
data/lib/skylight/version.rb
CHANGED
@@ -66,22 +66,25 @@ module Skylight
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def send_exception(exception)
|
69
|
-
|
69
|
+
data = {class_name: exception.class.name}
|
70
|
+
if Exception === exception
|
71
|
+
data.merge!(message: exception.message, backtrace: exception.backtrace)
|
72
|
+
end
|
73
|
+
post_data(:exception, data, false)
|
70
74
|
end
|
71
75
|
|
72
76
|
private
|
73
77
|
|
74
|
-
def post_data(type, data)
|
78
|
+
def post_data(type, data, notify = true)
|
75
79
|
t { "posting data (#{type}): #{data.inspect}" }
|
76
80
|
|
77
81
|
res = @http_auth.post("/agent/#{type}?hostname=#{escape(config[:'hostname'])}", data)
|
78
82
|
|
79
|
-
# error already handled in Util::HTTP
|
80
|
-
return unless res
|
81
|
-
|
82
83
|
unless res.success?
|
83
84
|
warn "#{type} wasn't sent successfully; status=%s", res.status
|
84
85
|
end
|
86
|
+
|
87
|
+
send_exception(res.exception) if notify && res.exception
|
85
88
|
rescue Exception => e
|
86
89
|
error "exception; msg=%s; class=%s", e.message, e.class
|
87
90
|
t { e.backtrace.join("\n") }
|
@@ -113,14 +116,18 @@ module Skylight
|
|
113
116
|
|
114
117
|
debug "flushing batch; size=%d", batch.sample.count
|
115
118
|
|
116
|
-
@http_report.post(ENDPOINT, batch.encode, CONTENT_TYPE => SKYLIGHT_V2)
|
119
|
+
res = @http_report.post(ENDPOINT, batch.encode, CONTENT_TYPE => SKYLIGHT_V2)
|
120
|
+
send_exception(res.exception) if res.exception
|
121
|
+
nil
|
117
122
|
end
|
118
123
|
|
119
124
|
def refresh_report_token(now)
|
120
125
|
res = @http_auth.get("/agent/authenticate?hostname=#{escape(config[:'hostname'])}")
|
121
126
|
|
122
|
-
|
123
|
-
|
127
|
+
if res.exception
|
128
|
+
send_exception(res.exception)
|
129
|
+
return
|
130
|
+
end
|
124
131
|
|
125
132
|
unless res.success?
|
126
133
|
if (400..499).include? res.status
|
@@ -204,11 +204,11 @@ module Skylight
|
|
204
204
|
@run = false
|
205
205
|
rescue Exception => e
|
206
206
|
error "Loop exception: %s (%s)\n%s", e.message, e.class, e.backtrace.join("\n")
|
207
|
-
@collector.send_exception(
|
207
|
+
@collector.send_exception(e)
|
208
208
|
return false
|
209
209
|
rescue Object => o
|
210
210
|
error "Unknown object thrown: `%s`", o.to_s
|
211
|
-
@collector.send_exception(
|
211
|
+
@collector.send_exception(o)
|
212
212
|
return false
|
213
213
|
end while @run
|
214
214
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skylight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -154,9 +154,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: 1.9.2
|
155
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
162
|
rubygems_version: 2.2.0
|