skylight 0.4.0.beta1 → 0.4.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libskylight.yml +4 -4
- data/lib/skylight/api.rb +19 -0
- data/lib/skylight/config.rb +4 -1
- data/lib/skylight/instrumenter.rb +31 -0
- data/lib/skylight/native.rb +7 -3
- data/lib/skylight/util.rb +1 -1
- data/lib/skylight/util/http.rb +1 -0
- data/lib/skylight/version.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: 5c2c971886aa2187432210157c789a499aa414b3
|
4
|
+
data.tar.gz: 89f8c9dd4bcca24cca6f9cb58871a223bd142bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006fecbbc09d50807beecb2d46dcb21ef2f7750bc719f535cee16200e368f2caf2de8bd1074de133d7e24e44ad1e27cd960bad2cdedb0fffa511fe903e29e0ec
|
7
|
+
data.tar.gz: e6caf8cd228af8c0e61ffd134581e9f7d9639451b3050e07996ef11aacd26ccb5520190654393a1d78772a4ab2226712c227f642824a09ba89e93cc2a65d6e65
|
data/ext/libskylight.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
|
-
version: "0.4.0-
|
2
|
+
version: "0.4.0-e42cc44"
|
3
3
|
checksums:
|
4
|
-
x86-linux: "
|
5
|
-
x86_64-linux: "
|
6
|
-
x86_64-darwin: "
|
4
|
+
x86-linux: "77c56fc8a34ae2b1a1f5af97ce177e59beeff5475410864af9aafbf130dab323"
|
5
|
+
x86_64-linux: "1f16effac4b96f3b214df061927cd6332a913c07b3f1d76b3c8053e9156a5732"
|
6
|
+
x86_64-darwin: "5f95596ccbd720b68b98ba012b7371c18ea674712c52d45a807620e9c5c3d127"
|
data/lib/skylight/api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
1
3
|
module Skylight
|
2
4
|
# @api private
|
3
5
|
class Api
|
@@ -40,6 +42,23 @@ module Skylight
|
|
40
42
|
@http.authentication = token
|
41
43
|
end
|
42
44
|
|
45
|
+
def validate_authentication
|
46
|
+
url = URI.parse(config[:auth_url])
|
47
|
+
|
48
|
+
res = @http.get(url.path)
|
49
|
+
|
50
|
+
case res.status
|
51
|
+
when 200...300
|
52
|
+
:ok
|
53
|
+
when 400...500
|
54
|
+
:invalid
|
55
|
+
else
|
56
|
+
:unknown
|
57
|
+
end
|
58
|
+
rescue
|
59
|
+
:unknown
|
60
|
+
end
|
61
|
+
|
43
62
|
def login(email, password)
|
44
63
|
res = http.get('/me', 'X-Email' => email, 'X-Password' => password)
|
45
64
|
|
data/lib/skylight/config.rb
CHANGED
@@ -81,7 +81,7 @@ module Skylight
|
|
81
81
|
# Default values for Skylight configuration keys
|
82
82
|
DEFAULTS = {
|
83
83
|
:'version' => VERSION,
|
84
|
-
:'auth_url' => 'https://
|
84
|
+
:'auth_url' => 'https://auth.skylight.io/agent',
|
85
85
|
:'daemon.lazy_start' => true,
|
86
86
|
:'daemon.ssl_cert_path' => Util::SSL.ca_cert_file_or_default,
|
87
87
|
:'daemon.ssl_cert_dir' => Util::SSL.ca_cert_dir,
|
@@ -333,6 +333,9 @@ module Skylight
|
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
336
|
+
ret << "SKYLIGHT_VALIDATE_AUTHENTICATION"
|
337
|
+
ret << "false"
|
338
|
+
|
336
339
|
ret
|
337
340
|
end
|
338
341
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'strscan'
|
3
|
+
require 'skylight/api'
|
3
4
|
|
4
5
|
module Skylight
|
5
6
|
# @api private
|
@@ -107,6 +108,11 @@ module Skylight
|
|
107
108
|
t { "starting instrumenter" }
|
108
109
|
@config.validate!
|
109
110
|
|
111
|
+
unless validate_authentication
|
112
|
+
warn "invalid authentication token"
|
113
|
+
return
|
114
|
+
end
|
115
|
+
|
110
116
|
t { "starting native instrumenter" }
|
111
117
|
unless native_start
|
112
118
|
warn "failed to start instrumenter"
|
@@ -251,5 +257,30 @@ module Skylight
|
|
251
257
|
config.key?(:ignored_endpoint) && trace.endpoint == config[:ignored_endpoint]
|
252
258
|
end
|
253
259
|
|
260
|
+
# Validates that the provided authentication token is valid. This is done
|
261
|
+
# by issuing a request for a session token and checking the response
|
262
|
+
def validate_authentication
|
263
|
+
# If a session token is specified, don't bother attempting to validate
|
264
|
+
if config[:session_token]
|
265
|
+
true
|
266
|
+
else
|
267
|
+
api = Api.new(config)
|
268
|
+
api.authentication = config[:authentication]
|
269
|
+
|
270
|
+
case res = api.validate_authentication
|
271
|
+
when :ok
|
272
|
+
true
|
273
|
+
when :invalid
|
274
|
+
false
|
275
|
+
when :unknown
|
276
|
+
warn "unable to validate authentication token"
|
277
|
+
true
|
278
|
+
else
|
279
|
+
error "[BUG] unexpected validate_token result; res=%s", res
|
280
|
+
true
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
254
285
|
end
|
255
286
|
end
|
data/lib/skylight/native.rb
CHANGED
@@ -13,23 +13,27 @@ module Skylight
|
|
13
13
|
ENV['SKYLIGHT_LIB_PATH'] || File.expand_path("../native/#{Util::Platform.tuple}", __FILE__)
|
14
14
|
end
|
15
15
|
|
16
|
+
skylight_required = ENV.key?("SKYLIGHT_REQUIRED") && ENV['SKYLIGHT_REQUIRED'] !~ /^false$/i
|
17
|
+
|
16
18
|
begin
|
17
|
-
unless ENV
|
19
|
+
unless ENV.key?("SKYLIGHT_DISABLE_AGENT") && ENV['SKYLIGHT_DISABLE_AGENT'] !~ /^false$/i
|
18
20
|
lib = "#{libskylight_path}/libskylight.#{Util::Platform.libext}"
|
19
21
|
|
20
22
|
if File.exist?(lib)
|
21
23
|
# First attempt to require the native extension
|
22
|
-
require
|
24
|
+
require "skylight_native"
|
23
25
|
|
24
26
|
# Attempt to link the dylib
|
25
27
|
load_libskylight(lib)
|
26
28
|
|
27
29
|
# If nothing was thrown, then the native extension is present
|
28
30
|
@@has_native_ext = true
|
31
|
+
elsif skylight_required
|
32
|
+
raise LoadError, "Cannot find native extensions in #{libskylight_path}"
|
29
33
|
end
|
30
34
|
end
|
31
35
|
rescue LoadError => e
|
32
|
-
raise if
|
36
|
+
raise if skylight_required
|
33
37
|
end
|
34
38
|
|
35
39
|
unless Skylight.native?
|
data/lib/skylight/util.rb
CHANGED
@@ -7,10 +7,10 @@ module Skylight
|
|
7
7
|
require 'skylight/util/hostname'
|
8
8
|
require 'skylight/util/logging'
|
9
9
|
require 'skylight/util/ssl'
|
10
|
+
require 'skylight/util/http'
|
10
11
|
|
11
12
|
# Used from the CLI
|
12
13
|
autoload :Gzip, 'skylight/util/gzip'
|
13
|
-
autoload :HTTP, 'skylight/util/http'
|
14
14
|
autoload :Inflector, 'skylight/util/inflector'
|
15
15
|
end
|
16
16
|
end
|
data/lib/skylight/util/http.rb
CHANGED
data/lib/skylight/version.rb
CHANGED
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.4.0.
|
4
|
+
version: 0.4.0.beta2
|
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-10-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|