skylight 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/skylight/cli.rb +1 -2
- data/lib/skylight/config.rb +18 -15
- data/lib/skylight/gc.rb +13 -2
- data/lib/skylight/instrumenter.rb +2 -1
- data/lib/skylight/messages/trace.rb +25 -6
- data/lib/skylight/subscriber.rb +11 -3
- 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: f501ad269f116e66053195e765359bb141347b0d
|
4
|
+
data.tar.gz: 933730962fe952b6928ce50af200825b60cc11fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d40ae02fb550a5fc409079b97d4087006610868589e2254013995df7d0d05e02f125a342258ff2e62747b58c7cdc5f6e4db1485af7bdafebee7659e446968e4
|
7
|
+
data.tar.gz: 6d31c629aee42b171e82c06bd5fa70cc3bc91ee09c346f9a0db91ad54df4c9ea67fe36f635f8f413789c45eee0714f95115ea08e4b0417f4d58c567257980577
|
data/lib/skylight/cli.rb
CHANGED
data/lib/skylight/config.rb
CHANGED
@@ -22,23 +22,26 @@ module Skylight
|
|
22
22
|
'SK_ACCOUNTS_HOST' => :'accounts.host',
|
23
23
|
'SK_ACCOUNTS_PORT' => :'accounts.port',
|
24
24
|
'SK_ACCOUNTS_SSL' => :'accounts.ssl',
|
25
|
-
'SK_ACCOUNTS_DEFLATE' => :'accounts.deflate'
|
25
|
+
'SK_ACCOUNTS_DEFLATE' => :'accounts.deflate',
|
26
|
+
'SK_ME_AUTHENTICATION' => :'me.authentication',
|
27
|
+
'SK_ME_CREDENTIALS_PATH' => :'me.credentials_path' }
|
26
28
|
|
27
29
|
# Default values for Skylight configuration keys
|
28
30
|
DEFAULTS = {
|
29
|
-
:'log'
|
30
|
-
:'log_level'
|
31
|
-
:'agent.keepalive'
|
32
|
-
:'agent.interval'
|
33
|
-
:'agent.sample'
|
34
|
-
:'report.host'
|
35
|
-
:'report.port'
|
36
|
-
:'report.ssl'
|
37
|
-
:'report.deflate'
|
38
|
-
:'accounts.host'
|
39
|
-
:'accounts.port'
|
40
|
-
:'accounts.ssl'
|
41
|
-
:'accounts.deflate'
|
31
|
+
:'log' => '-'.freeze,
|
32
|
+
:'log_level' => 'INFO'.freeze,
|
33
|
+
:'agent.keepalive' => 60,
|
34
|
+
:'agent.interval' => 5,
|
35
|
+
:'agent.sample' => 200,
|
36
|
+
:'report.host' => 'agent.skylight.io'.freeze,
|
37
|
+
:'report.port' => 443,
|
38
|
+
:'report.ssl' => true,
|
39
|
+
:'report.deflate' => true,
|
40
|
+
:'accounts.host' => 'www.skylight.io'.freeze,
|
41
|
+
:'accounts.port' => 443,
|
42
|
+
:'accounts.ssl' => true,
|
43
|
+
:'accounts.deflate' => false,
|
44
|
+
:'me.credentials_path' => '~/.skylight' }.freeze
|
42
45
|
|
43
46
|
REQUIRED = {
|
44
47
|
:'authentication' => "authentication token",
|
@@ -224,7 +227,7 @@ authentication: #{self[:authentication]}
|
|
224
227
|
end
|
225
228
|
|
226
229
|
def gc
|
227
|
-
GC.new(get('gc.profiler', ::GC::Profiler))
|
230
|
+
@gc ||= GC.new(self, get('gc.profiler', ::GC::Profiler))
|
228
231
|
end
|
229
232
|
|
230
233
|
def logger
|
data/lib/skylight/gc.rb
CHANGED
@@ -2,9 +2,11 @@ require 'thread'
|
|
2
2
|
|
3
3
|
module Skylight
|
4
4
|
class GC
|
5
|
-
METHODS = [ :enable, :total_time ]
|
5
|
+
METHODS = [ :enable, :total_time, :clear ]
|
6
6
|
TH_KEY = :SK_GC_CURR_WINDOW
|
7
7
|
|
8
|
+
include Util::Logging
|
9
|
+
|
8
10
|
def self.update
|
9
11
|
if win = Thread.current[TH_KEY]
|
10
12
|
win.update
|
@@ -19,15 +21,24 @@ module Skylight
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
|
24
|
+
attr_reader :config
|
25
|
+
|
26
|
+
def initialize(config, profiler)
|
23
27
|
@listeners = []
|
28
|
+
@config = config
|
24
29
|
@lock = Mutex.new
|
25
30
|
|
26
31
|
if METHODS.all? { |m| profiler.respond_to?(m) }
|
27
32
|
@profiler = profiler
|
33
|
+
else
|
34
|
+
debug "disabling GC profiling"
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
38
|
+
def enable
|
39
|
+
@profiler.enable if @profiler
|
40
|
+
end
|
41
|
+
|
31
42
|
def start_track
|
32
43
|
return if Thread.current[TH_KEY]
|
33
44
|
|
@@ -45,6 +45,7 @@ module Skylight
|
|
45
45
|
|
46
46
|
t { "starting instrumenter" }
|
47
47
|
@config.validate!
|
48
|
+
@config.gc.enable
|
48
49
|
@worker.spawn
|
49
50
|
@subscriber.register!
|
50
51
|
|
@@ -91,7 +92,7 @@ module Skylight
|
|
91
92
|
begin
|
92
93
|
built = trace.build
|
93
94
|
|
94
|
-
if built.valid?
|
95
|
+
if built && built.valid?
|
95
96
|
process(built)
|
96
97
|
else
|
97
98
|
debug "trace invalid -- dropping"
|
@@ -21,6 +21,7 @@ module Skylight
|
|
21
21
|
|
22
22
|
def initialize(endpoint = "Unknown", start = Util::Clock.now, config = nil)
|
23
23
|
@endpoint = endpoint
|
24
|
+
@busted = false
|
24
25
|
@config = config
|
25
26
|
@start = start
|
26
27
|
@spans = []
|
@@ -42,15 +43,19 @@ module Skylight
|
|
42
43
|
begin
|
43
44
|
yield
|
44
45
|
ensure
|
45
|
-
|
46
|
-
|
46
|
+
unless @busted
|
47
|
+
now = Util::Clock.now
|
48
|
+
|
49
|
+
GC.update
|
50
|
+
gc_time = GC.time
|
51
|
+
|
52
|
+
if gc_time > 0
|
53
|
+
start(now - gc_time, 'noise.gc')
|
54
|
+
stop(now)
|
55
|
+
end
|
47
56
|
|
48
|
-
if gc_time > 0
|
49
|
-
start(now - gc_time, 'noise.gc')
|
50
57
|
stop(now)
|
51
58
|
end
|
52
|
-
|
53
|
-
stop(now)
|
54
59
|
end
|
55
60
|
ensure
|
56
61
|
gc.stop_track
|
@@ -58,6 +63,8 @@ module Skylight
|
|
58
63
|
end
|
59
64
|
|
60
65
|
def record(time, cat, title = nil, desc = nil, annot = {})
|
66
|
+
return if @busted
|
67
|
+
|
61
68
|
sp = span(time, cat, title, desc, annot)
|
62
69
|
|
63
70
|
return self if :skip == sp
|
@@ -69,6 +76,8 @@ module Skylight
|
|
69
76
|
end
|
70
77
|
|
71
78
|
def start(time, cat, title = nil, desc = nil, annot = {})
|
79
|
+
return if @busted
|
80
|
+
|
72
81
|
sp = span(time, cat, title, desc, annot)
|
73
82
|
|
74
83
|
push(sp)
|
@@ -77,6 +86,8 @@ module Skylight
|
|
77
86
|
end
|
78
87
|
|
79
88
|
def stop(time)
|
89
|
+
return if @busted
|
90
|
+
|
80
91
|
sp = pop
|
81
92
|
|
82
93
|
return self if :skip == sp
|
@@ -88,6 +99,7 @@ module Skylight
|
|
88
99
|
end
|
89
100
|
|
90
101
|
def build
|
102
|
+
return if @busted
|
91
103
|
raise TraceError, "trace unbalanced" unless @stack.empty?
|
92
104
|
|
93
105
|
Trace.new(
|
@@ -106,6 +118,12 @@ module Skylight
|
|
106
118
|
sp.annotations = to_annotations(annot)
|
107
119
|
sp.started_at = relativize(time)
|
108
120
|
sp.absolute_time = time
|
121
|
+
|
122
|
+
if sp.started_at < 0
|
123
|
+
@busted = true
|
124
|
+
raise TraceError, "[BUG] span started_at negative; event=#{cat}"
|
125
|
+
end
|
126
|
+
|
109
127
|
sp
|
110
128
|
end
|
111
129
|
|
@@ -130,6 +148,7 @@ module Skylight
|
|
130
148
|
|
131
149
|
def pop
|
132
150
|
unless sp = @stack.pop
|
151
|
+
@busted = true
|
133
152
|
raise TraceError, "trace unbalanced"
|
134
153
|
end
|
135
154
|
|
data/lib/skylight/subscriber.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
module Skylight
|
2
2
|
class Subscriber
|
3
|
+
include Util::Logging
|
3
4
|
|
4
5
|
attr_reader :config
|
5
6
|
|
6
7
|
def initialize(config)
|
7
|
-
@config
|
8
|
+
@config = config
|
9
|
+
@subscriber = nil
|
8
10
|
@normalizers = Normalizers.build(config)
|
9
11
|
end
|
10
12
|
|
11
13
|
def register!
|
12
|
-
|
14
|
+
unregister! if @subscriber
|
15
|
+
@subscriber = ActiveSupport::Notifications.subscribe nil, self
|
13
16
|
end
|
14
17
|
|
15
18
|
def unregister!
|
16
|
-
ActiveSupport::Notifications.unsubscribe
|
19
|
+
ActiveSupport::Notifications.unsubscribe @subscriber
|
20
|
+
@subscriber = nil
|
17
21
|
end
|
18
22
|
|
19
23
|
def start(name, id, payload)
|
@@ -23,11 +27,15 @@ module Skylight
|
|
23
27
|
trace.start(now - gc_time, cat, title, desc, annot)
|
24
28
|
|
25
29
|
trace
|
30
|
+
rescue Exception => e
|
31
|
+
error "Subscriber#start error; msg=%s", e.message
|
26
32
|
end
|
27
33
|
|
28
34
|
def finish(name, id, payload)
|
29
35
|
return unless trace = Instrumenter.current_trace
|
30
36
|
trace.stop(now - gc_time)
|
37
|
+
rescue Exception => e
|
38
|
+
error "Subscriber#finish error; msg=%s", e.message
|
31
39
|
end
|
32
40
|
|
33
41
|
def publish(name, *args)
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|