skylight 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/skylight/cli.rb +5 -5
- data/lib/skylight/config.rb +38 -35
- data/lib/skylight/instrumenter.rb +2 -1
- data/lib/skylight/util/http.rb +2 -2
- data/lib/skylight/version.rb +1 -1
- metadata +1 -1
data/lib/skylight/cli.rb
CHANGED
@@ -8,8 +8,8 @@ require "active_support/inflector"
|
|
8
8
|
|
9
9
|
module Skylight
|
10
10
|
class CLI < Thor
|
11
|
-
desc "
|
12
|
-
def
|
11
|
+
desc "setup", "Sets up a new app"
|
12
|
+
def setup
|
13
13
|
if !SanityChecker.new.smoke_test(File.expand_path("config/skylight.yml"))
|
14
14
|
say "Your app is already on Skylight. http://www.skylight.io", :green
|
15
15
|
return
|
@@ -53,12 +53,12 @@ module Skylight
|
|
53
53
|
|
54
54
|
loop do
|
55
55
|
h = HighLine.new
|
56
|
-
|
56
|
+
email = h.ask("Email: ")
|
57
57
|
password = h.ask("Password: ") { |q| q.echo = "*" }
|
58
58
|
|
59
|
-
response = Util::HTTP.new(http_config).auth(
|
59
|
+
response = Util::HTTP.new(http_config).auth(email, password)
|
60
60
|
if response["authenticated"] == false
|
61
|
-
say "Sorry. That
|
61
|
+
say "Sorry. That email and password was invalid. Please try again", :red
|
62
62
|
puts
|
63
63
|
else
|
64
64
|
token = response["token"]
|
data/lib/skylight/config.rb
CHANGED
@@ -7,6 +7,14 @@ module Skylight
|
|
7
7
|
class Normalizer < Struct.new(:view_paths)
|
8
8
|
end
|
9
9
|
|
10
|
+
# Stub out the GC Profiler in cases when it is not requested
|
11
|
+
GC_PROFILER_STUB = Struct.new(
|
12
|
+
:enable,
|
13
|
+
:disable,
|
14
|
+
:clear,
|
15
|
+
:total_time).
|
16
|
+
new(nil, nil, nil, 0)
|
17
|
+
|
10
18
|
class << self
|
11
19
|
def load_from_yaml(path, env=ENV)
|
12
20
|
new do |config|
|
@@ -48,12 +56,14 @@ module Skylight
|
|
48
56
|
end
|
49
57
|
|
50
58
|
def initialize(attrs = {})
|
59
|
+
# Set defaults
|
51
60
|
@ssl = true
|
52
61
|
@deflate = true
|
53
62
|
@host = "agent.skylight.io"
|
54
63
|
@port = 443
|
55
64
|
@interval = 5
|
56
65
|
@protocol = JsonProto.new(self)
|
66
|
+
@enable_gc_profiler = true
|
57
67
|
@max_pending_traces = 500
|
58
68
|
@samples_per_interval = 100
|
59
69
|
|
@@ -68,48 +78,48 @@ module Skylight
|
|
68
78
|
end
|
69
79
|
end
|
70
80
|
|
71
|
-
@http ||= Util::HTTP.new(self)
|
72
|
-
@gc_profiler ||= GC::Profiler
|
73
|
-
|
74
81
|
yield self if block_given?
|
75
|
-
end
|
76
82
|
|
77
|
-
|
78
|
-
attr_accessor :authentication_token
|
79
|
-
attr_accessor :app_id
|
83
|
+
@http ||= Util::HTTP.new(self)
|
80
84
|
|
81
|
-
|
82
|
-
|
85
|
+
unless @gc_profiler
|
86
|
+
if enable_gc_profiler && GC::Profiler.respond_to?(:enable)
|
87
|
+
@gc_profiler = GC::Profiler
|
88
|
+
else
|
89
|
+
@gc_profiler = GC_PROFILER_STUB
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
83
93
|
|
84
|
-
attr_accessor :
|
94
|
+
attr_accessor :yaml_file,
|
95
|
+
:authentication_token,
|
96
|
+
:app_id,
|
97
|
+
:ssl,
|
98
|
+
:deflate,
|
99
|
+
:host,
|
100
|
+
:port,
|
101
|
+
:http,
|
102
|
+
:samples_per_interval,
|
103
|
+
:interval,
|
104
|
+
:max_pending_traces,
|
105
|
+
:normalizer,
|
106
|
+
:protocol,
|
107
|
+
:logger,
|
108
|
+
:enable_gc_profiler,
|
109
|
+
:gc_profiler
|
110
|
+
|
111
|
+
alias_method :ssl?, :ssl
|
85
112
|
alias_method :deflate?, :deflate
|
86
113
|
|
87
|
-
attr_accessor :host
|
88
|
-
|
89
|
-
attr_accessor :port
|
90
|
-
|
91
|
-
attr_accessor :http
|
92
|
-
|
93
|
-
attr_accessor :samples_per_interval
|
94
|
-
|
95
|
-
attr_accessor :interval
|
96
|
-
|
97
|
-
attr_accessor :max_pending_traces
|
98
|
-
|
99
|
-
attr_reader :normalizer
|
100
|
-
|
101
|
-
attr_reader :protocol
|
102
|
-
|
103
114
|
def protocol=(val)
|
104
115
|
if val.is_a?(String) || val.is_a?(Symbol)
|
105
116
|
class_name = val.to_s.capitalize+"Proto"
|
106
117
|
val = Skylight.const_get(class_name).new(self)
|
107
118
|
end
|
119
|
+
|
108
120
|
@protocol = val
|
109
121
|
end
|
110
122
|
|
111
|
-
attr_accessor :logger
|
112
|
-
|
113
123
|
def log_level
|
114
124
|
logger && logger.level
|
115
125
|
end
|
@@ -123,13 +133,6 @@ module Skylight
|
|
123
133
|
end
|
124
134
|
end
|
125
135
|
|
126
|
-
attr_writer :gc_profiler
|
127
|
-
|
128
|
-
def gc_profiler
|
129
|
-
# TODO: Move this into tests
|
130
|
-
@gc_profiler ||= Struct.new(:enable, :disable, :clear, :total_time).new(nil, nil, nil, 0)
|
131
|
-
end
|
132
|
-
|
133
136
|
def save(filename=yaml_file)
|
134
137
|
FileUtils.mkdir_p File.dirname(filename)
|
135
138
|
|
data/lib/skylight/util/http.rb
CHANGED
@@ -16,9 +16,9 @@ module Skylight
|
|
16
16
|
@config = config
|
17
17
|
end
|
18
18
|
|
19
|
-
def auth(
|
19
|
+
def auth(email, password)
|
20
20
|
req = Net::HTTP::Get.new("/login")
|
21
|
-
req.basic_auth
|
21
|
+
req.basic_auth email, password
|
22
22
|
response = make_request(req, nil, ACCEPT => APPLICATION_JSON)
|
23
23
|
JSON.parse(response)
|
24
24
|
end
|
data/lib/skylight/version.rb
CHANGED