skylight 0.3.3 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/ext/checksums.yml +2 -2
- data/ext/extconf.rb +1 -1
- data/ext/skylight_native.c +10 -6
- data/lib/skylight.rb +23 -9
- data/lib/skylight/cli.rb +8 -0
- data/lib/skylight/config.rb +31 -3
- data/lib/skylight/instrumenter.rb +10 -0
- data/lib/skylight/probes.rb +0 -2
- data/lib/skylight/railtie.rb +10 -8
- data/lib/skylight/util/http.rb +8 -1
- data/lib/skylight/version.rb +1 -1
- data/lib/skylight/worker.rb +0 -3
- data/lib/skylight/worker/builder.rb +3 -2
- data/lib/skylight/worker/collector.rb +1 -1
- data/lib/skylight/worker/standalone.rb +29 -7
- 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: 3b26b3f575af56669c5257a37d8d7ca11544aba4
|
4
|
+
data.tar.gz: 5fb2964195f3d146693f62b6593ff2b0bbf3944d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e9759155ce35d86bd96b058788b153544dff9aa73d08cfb4f742ddd5dc2871b4c4c8bc4e4799eb006b59e3e8bb99b89920b98a67698fd601d612793b2f68ec3
|
7
|
+
data.tar.gz: 0009517b20943ce01703c10210b925f3d687b16e471f7b57af1066bbdeb28e88f3f91937b00a4c4942167f2d7983d89b1621d10891f16962c644965dbf573fb8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## 0.3.6 (March 27, 2014)
|
2
|
+
|
3
|
+
* Shorter token validation timeout
|
4
|
+
* Allow validation to be skipped
|
5
|
+
|
6
|
+
## 0.3.5 (March 26, 2014)
|
7
|
+
|
8
|
+
* Update Rust component
|
9
|
+
* Return true from Task#handle to avoid sutdown
|
10
|
+
* Fix numeric check that caused crash on some 32-bit systems
|
11
|
+
* Improve error message for missing Skylight ext
|
12
|
+
* Better config error messages
|
13
|
+
* Validate authentication token before starting
|
14
|
+
* Add proxy support
|
15
|
+
|
16
|
+
## 0.3.4 (March 13, 2014)
|
17
|
+
|
18
|
+
* Don't try to boot Skylight without native agent
|
19
|
+
* Make exception classes always available
|
20
|
+
* CLI should require railtie before loading application.rb
|
21
|
+
|
1
22
|
## 0.3.3 (March 12, 2014)
|
2
23
|
|
3
24
|
* Load the railtie even without native agent
|
data/ext/checksums.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
x86_64-linux: "
|
3
|
-
i686-linux : "
|
2
|
+
x86_64-linux: "98b04f7d73c1894cc79621a135b4598a679c421f5ff3eecc652f84ba07258d9c"
|
3
|
+
i686-linux : "1d4bbd58e319237b18752607d087ce0c895fe99c58482e994abe62a9f07d41dd"
|
data/ext/extconf.rb
CHANGED
data/ext/skylight_native.c
CHANGED
@@ -26,7 +26,9 @@
|
|
26
26
|
} while(0) \
|
27
27
|
|
28
28
|
#define CHECK_NUMERIC(VAL) \
|
29
|
-
CHECK(VAL
|
29
|
+
CHECK(TYPE(VAL) == T_BIGNUM || \
|
30
|
+
TYPE(VAL) == T_FIXNUM, \
|
31
|
+
#VAL " is not numeric") \
|
30
32
|
|
31
33
|
#define My_Struct(name, Type, msg) \
|
32
34
|
Get_Struct(name, self, Type, msg); \
|
@@ -109,7 +111,7 @@ bool skylight_high_res_time(uint64_t*);
|
|
109
111
|
bool skylight_trace_new(uint64_t, RustSlice, RustTrace*);
|
110
112
|
bool skylight_trace_free(RustTrace);
|
111
113
|
bool skylight_trace_load(RustSlice, RustTrace*);
|
112
|
-
bool skylight_trace_name_from_serialized_into_new_buffer(RustSlice,
|
114
|
+
bool skylight_trace_name_from_serialized_into_new_buffer(RustSlice, RustString*);
|
113
115
|
bool skylight_trace_get_started_at(RustTrace, uint64_t*);
|
114
116
|
bool skylight_trace_set_name(RustTrace, RustSlice);
|
115
117
|
bool skylight_trace_get_name(RustTrace, RustSlice*);
|
@@ -344,7 +346,7 @@ static VALUE error_serialize(VALUE self) {
|
|
344
346
|
static const char* freedTrace = "You can't do anything with a Trace once it's been serialized or moved into a Batch";
|
345
347
|
|
346
348
|
static VALUE trace_new(VALUE self, VALUE started_at, VALUE uuid) {
|
347
|
-
|
349
|
+
CHECK_NUMERIC(started_at);
|
348
350
|
CHECK_TYPE(uuid, T_STRING);
|
349
351
|
|
350
352
|
RustTrace trace;
|
@@ -367,11 +369,13 @@ static VALUE trace_load(VALUE self, VALUE protobuf) {
|
|
367
369
|
static VALUE trace_name_from_serialized(VALUE self, VALUE protobuf) {
|
368
370
|
CHECK_TYPE(protobuf, T_STRING);
|
369
371
|
|
370
|
-
|
372
|
+
RustString trace_name;
|
371
373
|
|
372
374
|
CHECK_FFI(skylight_trace_name_from_serialized_into_new_buffer(STR2SLICE(protobuf), &trace_name), "Could not read name from serialized Trace");
|
373
375
|
|
374
|
-
|
376
|
+
VALUE ret = VEC2STR(trace_name);
|
377
|
+
skylight_free_buf(trace_name);
|
378
|
+
return ret;
|
375
379
|
}
|
376
380
|
|
377
381
|
static VALUE trace_get_started_at(VALUE self) {
|
@@ -522,7 +526,7 @@ VALUE batch_new(VALUE klass, VALUE rb_timestamp, VALUE rb_hostname) {
|
|
522
526
|
CHECK_NUMERIC(rb_timestamp);
|
523
527
|
|
524
528
|
RustString hostname = NULL;
|
525
|
-
uint32_t timestamp = NUM2ULONG(rb_timestamp);
|
529
|
+
uint32_t timestamp = (uint32_t) NUM2ULONG(rb_timestamp);
|
526
530
|
|
527
531
|
if (rb_hostname != Qnil) {
|
528
532
|
CHECK_TYPE(rb_hostname, T_STRING);
|
data/lib/skylight.rb
CHANGED
@@ -9,7 +9,13 @@ begin
|
|
9
9
|
has_native_ext = true
|
10
10
|
end
|
11
11
|
rescue LoadError
|
12
|
-
|
12
|
+
if defined?(Rails) && !Rails.env.development? && !Rails.env.test?
|
13
|
+
puts "[SKYLIGHT] [#{Skylight::VERSION}] The Skylight native extension for your platform wasn't found. We currently support monitoring in 32- and 64-bit Linux only. If you are on a supported platform, please contact support at support@skylight.io. The missing extension will not affect the functioning of your application."
|
14
|
+
elsif defined?(Rails)
|
15
|
+
puts "[SKYLIGHT] [#{Skylight::VERSION}] Running Skylight in #{Rails.env} mode. No data will be reported until you deploy your app."
|
16
|
+
else
|
17
|
+
puts "[SKYLIGHT] [#{Skylight::VERSION}] Running Skylight in development mode."
|
18
|
+
end
|
13
19
|
raise if ENV.key?("SKYLIGHT_REQUIRED")
|
14
20
|
end
|
15
21
|
|
@@ -26,6 +32,13 @@ module Skylight
|
|
26
32
|
autoload :HTTP, 'skylight/util/http'
|
27
33
|
end
|
28
34
|
|
35
|
+
# ==== Exceptions ====
|
36
|
+
class IpcProtoError < RuntimeError; end
|
37
|
+
class WorkerStateError < RuntimeError; end
|
38
|
+
class ConfigError < RuntimeError; end
|
39
|
+
class TraceError < RuntimeError; end
|
40
|
+
class SerializeError < RuntimeError; end
|
41
|
+
|
29
42
|
if defined?(Rails)
|
30
43
|
require 'skylight/railtie'
|
31
44
|
end
|
@@ -37,6 +50,10 @@ module Skylight
|
|
37
50
|
STANDALONE_ENV_KEY = 'SKYLIGHT_STANDALONE'.freeze
|
38
51
|
STANDALONE_ENV_VAL = 'server'.freeze
|
39
52
|
|
53
|
+
def self.native?
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
40
57
|
def self.daemon?
|
41
58
|
ENV[STANDALONE_ENV_KEY] == STANDALONE_ENV_VAL
|
42
59
|
end
|
@@ -73,13 +90,6 @@ module Skylight
|
|
73
90
|
autoload :HTTP, 'skylight/formatters/http'
|
74
91
|
end
|
75
92
|
|
76
|
-
# ==== Exceptions ====
|
77
|
-
class IpcProtoError < RuntimeError; end
|
78
|
-
class WorkerStateError < RuntimeError; end
|
79
|
-
class ConfigError < RuntimeError; end
|
80
|
-
class TraceError < RuntimeError; end
|
81
|
-
class SerializeError < RuntimeError; end
|
82
|
-
|
83
93
|
TIERS = %w(
|
84
94
|
api
|
85
95
|
app
|
@@ -164,6 +174,10 @@ end
|
|
164
174
|
else
|
165
175
|
|
166
176
|
module Skylight
|
177
|
+
def self.native?
|
178
|
+
false
|
179
|
+
end
|
180
|
+
|
167
181
|
def self.start!(*)
|
168
182
|
end
|
169
183
|
|
@@ -186,4 +200,4 @@ module Skylight
|
|
186
200
|
end
|
187
201
|
end
|
188
202
|
|
189
|
-
end
|
203
|
+
end
|
data/lib/skylight/cli.rb
CHANGED
@@ -51,6 +51,14 @@ repository and deploy from there. You can learn more about the process at:
|
|
51
51
|
@app_name ||=
|
52
52
|
begin
|
53
53
|
if File.exist?("config/application.rb")
|
54
|
+
# This looks like a Rails app, lets make sure we have the railtie loaded
|
55
|
+
# skylight.rb checks for Rails, but when running the CLI, Skylight loads before Rails does
|
56
|
+
begin
|
57
|
+
require "skylight/railtie"
|
58
|
+
rescue LoadError => e
|
59
|
+
error "Unable to load Railtie. Please notify support@skylight.io."
|
60
|
+
end
|
61
|
+
|
54
62
|
require "./config/application"
|
55
63
|
Rails.application.class.name.split("::").first.underscore.humanize
|
56
64
|
else
|
data/lib/skylight/config.rb
CHANGED
@@ -25,6 +25,7 @@ module Skylight
|
|
25
25
|
'APPLICATION' => :'application',
|
26
26
|
'AUTHENTICATION' => :'authentication',
|
27
27
|
'HOSTNAME' => :'hostname',
|
28
|
+
'SKIP_VALIDATION' => :'skip_validation',
|
28
29
|
'AGENT_INTERVAL' => :'agent.interval',
|
29
30
|
'AGENT_KEEPALIVE' => :'agent.keepalive',
|
30
31
|
'AGENT_SAMPLE_SIZE' => :'agent.sample',
|
@@ -70,7 +71,7 @@ module Skylight
|
|
70
71
|
:'report.port' => "skylight remote port" }
|
71
72
|
|
72
73
|
VALIDATORS = {
|
73
|
-
:'agent.interval' => lambda { |v, c| Integer === v && v > 0 }
|
74
|
+
:'agent.interval' => [lambda { |v, c| Integer === v && v > 0 }, "must be an integer greater than 0"]
|
74
75
|
}
|
75
76
|
|
76
77
|
def self.load(path = nil, environment = nil, env = ENV)
|
@@ -151,7 +152,13 @@ module Skylight
|
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
155
|
+
def skip_validation?
|
156
|
+
!!get(:skip_validation)
|
157
|
+
end
|
158
|
+
|
154
159
|
def validate!
|
160
|
+
return true if skip_validation?
|
161
|
+
|
155
162
|
REQUIRED.each do |k, v|
|
156
163
|
unless get(k)
|
157
164
|
raise ConfigError, "#{v} required"
|
@@ -161,6 +168,23 @@ module Skylight
|
|
161
168
|
true
|
162
169
|
end
|
163
170
|
|
171
|
+
def validate_token
|
172
|
+
return :ok if skip_validation?
|
173
|
+
|
174
|
+
http_auth = Util::HTTP.new(self, :accounts)
|
175
|
+
|
176
|
+
res = http_auth.get("/agent/authenticate?hostname=#{URI.escape(self[:'hostname'])}")
|
177
|
+
|
178
|
+
case res.status
|
179
|
+
when 200...300
|
180
|
+
:ok
|
181
|
+
when 400...500
|
182
|
+
:invalid
|
183
|
+
else
|
184
|
+
:unknown
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
164
188
|
def key?(key)
|
165
189
|
key = key.to_sym
|
166
190
|
@priority.key?(key) || @values.key?(key)
|
@@ -197,8 +221,12 @@ module Skylight
|
|
197
221
|
k = key.to_sym
|
198
222
|
|
199
223
|
if validator = VALIDATORS[k]
|
200
|
-
|
201
|
-
|
224
|
+
blk, msg = validator
|
225
|
+
|
226
|
+
unless blk.call(val, self)
|
227
|
+
error_msg = "invalid value for #{k} (#{val})"
|
228
|
+
error_msg << ", #{msg}" if msg
|
229
|
+
raise ConfigError, error_msg
|
202
230
|
end
|
203
231
|
end
|
204
232
|
|
@@ -72,6 +72,16 @@ module Skylight
|
|
72
72
|
|
73
73
|
t { "starting instrumenter" }
|
74
74
|
@config.validate!
|
75
|
+
|
76
|
+
case @config.validate_token
|
77
|
+
when :ok
|
78
|
+
# Good to go
|
79
|
+
when :unknown
|
80
|
+
log_warn "unable to validate authentication token"
|
81
|
+
else
|
82
|
+
raise ConfigError, "authentication token is invalid"
|
83
|
+
end
|
84
|
+
|
75
85
|
@config.gc.enable
|
76
86
|
@worker.spawn
|
77
87
|
@subscriber.register!
|
data/lib/skylight/probes.rb
CHANGED
data/lib/skylight/railtie.rb
CHANGED
@@ -15,17 +15,19 @@ module Skylight
|
|
15
15
|
config.skylight.probes = []
|
16
16
|
|
17
17
|
initializer 'skylight.configure' do |app|
|
18
|
-
if
|
19
|
-
|
18
|
+
if Skylight.native?
|
19
|
+
if activate?
|
20
|
+
load_probes
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
if config = load_skylight_config(app)
|
23
|
+
Instrumenter.start!(config)
|
24
|
+
app.middleware.insert 0, Middleware
|
24
25
|
|
25
|
-
|
26
|
+
puts "[SKYLIGHT] [#{Skylight::VERSION}] Skylight agent enabled"
|
27
|
+
end
|
28
|
+
elsif !Rails.env.test? && Rails.env.development?
|
29
|
+
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."
|
26
30
|
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."
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
data/lib/skylight/util/http.rb
CHANGED
@@ -26,6 +26,10 @@ module Skylight
|
|
26
26
|
@ssl = config["#{service}.ssl"]
|
27
27
|
@host = config["#{service}.host"]
|
28
28
|
@port = config["#{service}.port"]
|
29
|
+
@proxy_addr = config["#{service}.proxy_addr"]
|
30
|
+
@proxy_port = config["#{service}.proxy_port"]
|
31
|
+
@proxy_user = config["#{service}.proxy_user"]
|
32
|
+
@proxy_pass = config["#{service}.proxy_pass"]
|
29
33
|
@deflate = config["#{service}.deflate"]
|
30
34
|
@authentication = config[:'authentication']
|
31
35
|
end
|
@@ -87,7 +91,10 @@ module Skylight
|
|
87
91
|
req.body = body
|
88
92
|
end
|
89
93
|
|
90
|
-
http = Net::HTTP.new
|
94
|
+
http = Net::HTTP.new(@host, @port, @proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
|
95
|
+
|
96
|
+
# Default is 60, but that's also the Heroku boot timeout and we don't want to slow boot
|
97
|
+
http.read_timeout = 15
|
91
98
|
|
92
99
|
if @ssl
|
93
100
|
http.use_ssl = true
|
data/lib/skylight/version.rb
CHANGED
data/lib/skylight/worker.rb
CHANGED
@@ -24,7 +24,7 @@ module Skylight
|
|
24
24
|
trace "building standalone worker"
|
25
25
|
|
26
26
|
unless config[:'agent.sockfile_path']
|
27
|
-
raise
|
27
|
+
raise ConfigError, 'agent.sockfile_path required'
|
28
28
|
end
|
29
29
|
|
30
30
|
Standalone.new(
|
@@ -32,7 +32,8 @@ module Skylight
|
|
32
32
|
lockfile,
|
33
33
|
server)
|
34
34
|
else
|
35
|
-
|
35
|
+
# We can assume that if it's unknown it's from the config
|
36
|
+
raise ConfigError, "unknown agent.strategy: `#{s}`"
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'socket'
|
2
2
|
require 'thread'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'rbconfig'
|
4
5
|
|
5
6
|
# TODO: Handle cool-off
|
6
7
|
module Skylight
|
@@ -12,11 +13,29 @@ module Skylight
|
|
12
13
|
class Standalone
|
13
14
|
include Util::Logging
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# Locates skylight_native so that it can be included in the standalone agent startup command
|
17
|
+
def self.locate_skylight_native
|
18
|
+
$LOADED_FEATURES.each do |feature|
|
19
|
+
return feature if feature =~ /skylight_native\.#{RbConfig::CONFIG['DLEXT']}/
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.build_subprocess_cmd
|
24
|
+
paths = [
|
25
|
+
File.expand_path('../../..', __FILE__), # Ruby code root
|
26
|
+
File.dirname(locate_skylight_native) # Native extension location
|
27
|
+
].uniq.compact
|
28
|
+
|
29
|
+
ret = [ RUBYBIN ]
|
30
|
+
paths.each { |path| ret << "-I" << path }
|
31
|
+
ret << File.expand_path('../../../skylight.rb', __FILE__) # The agent startup script
|
32
|
+
ret
|
33
|
+
end
|
34
|
+
|
35
|
+
# Used to start the standalone agent as well as included in the hello message
|
36
|
+
SUBPROCESS_CMD = build_subprocess_cmd
|
19
37
|
|
38
|
+
# Used to handle starting the thread
|
20
39
|
LOCK = Mutex.new
|
21
40
|
|
22
41
|
attr_reader \
|
@@ -172,8 +191,10 @@ module Skylight
|
|
172
191
|
trace "shuting down agent connection"
|
173
192
|
@sock.close if @sock
|
174
193
|
@pid = nil
|
194
|
+
|
195
|
+
return false
|
175
196
|
elsif msg
|
176
|
-
handle(msg)
|
197
|
+
return handle(msg)
|
177
198
|
else
|
178
199
|
begin
|
179
200
|
@sock.read_nonblock(1)
|
@@ -185,11 +206,11 @@ module Skylight
|
|
185
206
|
end
|
186
207
|
end
|
187
208
|
|
188
|
-
true
|
209
|
+
return true
|
189
210
|
end
|
190
211
|
rescue WorkerStateError => e
|
191
212
|
error "skylight shutting down: %s", e.message
|
192
|
-
false
|
213
|
+
return false
|
193
214
|
end
|
194
215
|
|
195
216
|
def handle(msg)
|
@@ -299,6 +320,7 @@ module Skylight
|
|
299
320
|
sf = sockfile(pid)
|
300
321
|
File.unlink(sf) rescue nil
|
301
322
|
|
323
|
+
t { fmt "opening a new socket; %s", sf }
|
302
324
|
srv = UNIXServer.new(sf)
|
303
325
|
|
304
326
|
unless ENV[TRACE_ENV_KEY]
|
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.
|
4
|
+
version: 0.3.6
|
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-03-
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|