skylight 0.5.2 → 0.6.0.beta.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/CHANGELOG.md +12 -0
- data/lib/skylight.rb +2 -124
- data/lib/skylight/cli.rb +5 -0
- data/lib/skylight/config.rb +0 -3
- data/lib/skylight/core.rb +122 -0
- data/lib/skylight/normalizers/active_record/sql.rb +3 -1
- data/lib/skylight/probes/sequel.rb +29 -0
- data/lib/skylight/probes/sinatra.rb +74 -0
- data/lib/skylight/probes/tilt.rb +26 -0
- data/lib/skylight/sinatra.rb +4 -0
- data/lib/skylight/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5fe0175d64d6a4fa8ee48ee5fb11f7c12229419
|
4
|
+
data.tar.gz: 57bc045e5555aae042471c7920854ac1c022fcfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1f45b52db2a62340ab610b4fa5658032105212950cf8bf8a40fad751930b7b4d63690b799b5fd88af959674017ce08e9fe03b017007e76c187ee6393edaa49e
|
7
|
+
data.tar.gz: 172582d67e1c2ad1420f02a63b32874feee80eb19cacfd7565509de8aa5df9437daa7543096cac8b0ffcad846660e2573d025958850aaebf5007bea7c47bb54e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 0.6.0 - Beta 1 (January 5, 2014)
|
2
|
+
|
3
|
+
* [IMPROVEMENT] Eliminates runtime dependency on the Rails
|
4
|
+
constant across the entire codebase
|
5
|
+
* [FEATURE] Support for Sinatra applications. During the
|
6
|
+
beta period, this requires an opt-in via
|
7
|
+
`require "skylight/sinatra". See http://docs.skylight.io/sinatra/
|
8
|
+
* [FEATURE] Support for the Sequel ORM (off by default for Rails apps
|
9
|
+
during the beta)
|
10
|
+
* [FEATURE] Support for Tilt templates (off by default for Rails apps
|
11
|
+
during the beta)
|
12
|
+
|
1
13
|
## 0.5.2 (December 15, 2014)
|
2
14
|
|
3
15
|
* [IMPROVEMENT] Support ignoring multiple heartbeat endpoints
|
data/lib/skylight.rb
CHANGED
@@ -1,124 +1,2 @@
|
|
1
|
-
require 'skylight/
|
2
|
-
|
3
|
-
module Skylight
|
4
|
-
# @api private
|
5
|
-
TRACE_ENV_KEY = 'SKYLIGHT_ENABLE_TRACE_LOGS'.freeze
|
6
|
-
|
7
|
-
# Load the native agent
|
8
|
-
require 'skylight/native'
|
9
|
-
|
10
|
-
if defined?(Rails)
|
11
|
-
require 'skylight/railtie'
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'active_support/notifications'
|
15
|
-
require 'skylight/compat' # Require after AS::N
|
16
|
-
|
17
|
-
# Require VM specific things
|
18
|
-
require 'skylight/config'
|
19
|
-
require 'skylight/gc'
|
20
|
-
require 'skylight/helpers'
|
21
|
-
require 'skylight/instrumenter'
|
22
|
-
require 'skylight/middleware'
|
23
|
-
require 'skylight/trace'
|
24
|
-
require 'skylight/vm/gc'
|
25
|
-
require 'skylight/util'
|
26
|
-
|
27
|
-
# Used from the CLI
|
28
|
-
autoload :Api, 'skylight/api'
|
29
|
-
autoload :CLI, 'skylight/cli'
|
30
|
-
autoload :Normalizers, 'skylight/normalizers'
|
31
|
-
autoload :Subscriber, 'skylight/subscriber'
|
32
|
-
|
33
|
-
# @api private
|
34
|
-
class ConfigError < RuntimeError; end
|
35
|
-
|
36
|
-
# @api private
|
37
|
-
TIERS = %w(
|
38
|
-
api
|
39
|
-
app
|
40
|
-
view
|
41
|
-
db
|
42
|
-
noise
|
43
|
-
other)
|
44
|
-
|
45
|
-
# @api private
|
46
|
-
TIER_REGEX = /^(?:#{TIERS.join('|')})(?:\.|$)/u
|
47
|
-
|
48
|
-
# @api private
|
49
|
-
CATEGORY_REGEX = /^[a-z0-9_-]+(?:\.[a-z0-9_-]+)*$/iu
|
50
|
-
|
51
|
-
# @api private
|
52
|
-
DEFAULT_CATEGORY = "app.block".freeze
|
53
|
-
|
54
|
-
# @api private
|
55
|
-
DEFAULT_OPTIONS = { category: DEFAULT_CATEGORY }
|
56
|
-
|
57
|
-
# Start instrumenting
|
58
|
-
def self.start!(*args)
|
59
|
-
Instrumenter.start!(*args)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Stop instrumenting
|
63
|
-
def self.stop!(*args)
|
64
|
-
Instrumenter.stop!(*args)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Start a trace
|
68
|
-
def self.trace(endpoint=nil, cat=nil, title=nil)
|
69
|
-
unless inst = Instrumenter.instance
|
70
|
-
return yield if block_given?
|
71
|
-
return
|
72
|
-
end
|
73
|
-
|
74
|
-
if block_given?
|
75
|
-
inst.trace(endpoint, cat || DEFAULT_CATEGORY, title) { yield }
|
76
|
-
else
|
77
|
-
inst.trace(endpoint, cat || DEFAULT_CATEGORY, title)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# End a trace
|
82
|
-
def self.done(span)
|
83
|
-
return unless inst = Instrumenter.instance
|
84
|
-
inst.done(span)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Instrument
|
88
|
-
def self.instrument(opts = DEFAULT_OPTIONS)
|
89
|
-
unless inst = Instrumenter.instance
|
90
|
-
return yield if block_given?
|
91
|
-
return
|
92
|
-
end
|
93
|
-
|
94
|
-
if Hash === opts
|
95
|
-
category = opts[:category] || DEFAULT_CATEGORY
|
96
|
-
title = opts[:title]
|
97
|
-
desc = opts[:description]
|
98
|
-
annotations = opts[:annotations]
|
99
|
-
else
|
100
|
-
category = DEFAULT_CATEGORY
|
101
|
-
title = opts.to_s
|
102
|
-
desc = nil
|
103
|
-
annotations = nil
|
104
|
-
end
|
105
|
-
|
106
|
-
if block_given?
|
107
|
-
inst.instrument(category, title, desc, annotations) { yield }
|
108
|
-
else
|
109
|
-
inst.instrument(category, title, desc, annotations)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# Temporarily disable
|
114
|
-
def self.disable
|
115
|
-
unless inst = Instrumenter.instance
|
116
|
-
return yield if block_given?
|
117
|
-
return
|
118
|
-
end
|
119
|
-
|
120
|
-
inst.disable { yield }
|
121
|
-
end
|
122
|
-
|
123
|
-
require 'skylight/probes'
|
124
|
-
end
|
1
|
+
require 'skylight/core'
|
2
|
+
require 'skylight/probes'
|
data/lib/skylight/cli.rb
CHANGED
@@ -41,6 +41,11 @@ repository and deploy from there. You can learn more about the process at:
|
|
41
41
|
|
42
42
|
http://docs.skylight.io/getting-started/#deploy
|
43
43
|
|
44
|
+
If you want to specify the authentication token as an environment variable,
|
45
|
+
you should set the `SKYLIGHT_AUTHENTICATION` variable to:
|
46
|
+
|
47
|
+
#{config[:authentication]}
|
48
|
+
|
44
49
|
OUT
|
45
50
|
rescue Api::CreateFailed => e
|
46
51
|
say "Could not create the application", :red
|
data/lib/skylight/config.rb
CHANGED
@@ -387,9 +387,6 @@ module Skylight
|
|
387
387
|
File.open(path, 'w') do |f|
|
388
388
|
f.puts <<-YAML
|
389
389
|
---
|
390
|
-
# The Skylight ID for the application.
|
391
|
-
application: #{self[:application]}
|
392
|
-
|
393
390
|
# The authentication token for the application.
|
394
391
|
authentication: #{self[:authentication]}
|
395
392
|
YAML
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'skylight/version'
|
2
|
+
|
3
|
+
module Skylight
|
4
|
+
# @api private
|
5
|
+
TRACE_ENV_KEY = 'SKYLIGHT_ENABLE_TRACE_LOGS'.freeze
|
6
|
+
|
7
|
+
# Load the native agent
|
8
|
+
require 'skylight/native'
|
9
|
+
|
10
|
+
if defined?(Rails)
|
11
|
+
require 'skylight/railtie'
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'active_support/notifications'
|
15
|
+
require 'skylight/compat' # Require after AS::N
|
16
|
+
|
17
|
+
# Require VM specific things
|
18
|
+
require 'skylight/config'
|
19
|
+
require 'skylight/gc'
|
20
|
+
require 'skylight/helpers'
|
21
|
+
require 'skylight/instrumenter'
|
22
|
+
require 'skylight/middleware'
|
23
|
+
require 'skylight/trace'
|
24
|
+
require 'skylight/vm/gc'
|
25
|
+
require 'skylight/util'
|
26
|
+
|
27
|
+
# Used from the CLI
|
28
|
+
autoload :Api, 'skylight/api'
|
29
|
+
autoload :CLI, 'skylight/cli'
|
30
|
+
autoload :Normalizers, 'skylight/normalizers'
|
31
|
+
autoload :Subscriber, 'skylight/subscriber'
|
32
|
+
|
33
|
+
# @api private
|
34
|
+
class ConfigError < RuntimeError; end
|
35
|
+
|
36
|
+
# @api private
|
37
|
+
TIERS = %w(
|
38
|
+
api
|
39
|
+
app
|
40
|
+
view
|
41
|
+
db
|
42
|
+
noise
|
43
|
+
other)
|
44
|
+
|
45
|
+
# @api private
|
46
|
+
TIER_REGEX = /^(?:#{TIERS.join('|')})(?:\.|$)/u
|
47
|
+
|
48
|
+
# @api private
|
49
|
+
CATEGORY_REGEX = /^[a-z0-9_-]+(?:\.[a-z0-9_-]+)*$/iu
|
50
|
+
|
51
|
+
# @api private
|
52
|
+
DEFAULT_CATEGORY = "app.block".freeze
|
53
|
+
|
54
|
+
# @api private
|
55
|
+
DEFAULT_OPTIONS = { category: DEFAULT_CATEGORY }
|
56
|
+
|
57
|
+
# Start instrumenting
|
58
|
+
def self.start!(*args)
|
59
|
+
Instrumenter.start!(*args)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Stop instrumenting
|
63
|
+
def self.stop!(*args)
|
64
|
+
Instrumenter.stop!(*args)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Start a trace
|
68
|
+
def self.trace(endpoint=nil, cat=nil, title=nil)
|
69
|
+
unless inst = Instrumenter.instance
|
70
|
+
return yield if block_given?
|
71
|
+
return
|
72
|
+
end
|
73
|
+
|
74
|
+
if block_given?
|
75
|
+
inst.trace(endpoint, cat || DEFAULT_CATEGORY, title) { yield }
|
76
|
+
else
|
77
|
+
inst.trace(endpoint, cat || DEFAULT_CATEGORY, title)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# End a trace
|
82
|
+
def self.done(span)
|
83
|
+
return unless inst = Instrumenter.instance
|
84
|
+
inst.done(span)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Instrument
|
88
|
+
def self.instrument(opts = DEFAULT_OPTIONS)
|
89
|
+
unless inst = Instrumenter.instance
|
90
|
+
return yield if block_given?
|
91
|
+
return
|
92
|
+
end
|
93
|
+
|
94
|
+
if Hash === opts
|
95
|
+
category = opts[:category] || DEFAULT_CATEGORY
|
96
|
+
title = opts[:title]
|
97
|
+
desc = opts[:description]
|
98
|
+
annotations = opts[:annotations]
|
99
|
+
else
|
100
|
+
category = DEFAULT_CATEGORY
|
101
|
+
title = opts.to_s
|
102
|
+
desc = nil
|
103
|
+
annotations = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
if block_given?
|
107
|
+
inst.instrument(category, title, desc, annotations) { yield }
|
108
|
+
else
|
109
|
+
inst.instrument(category, title, desc, annotations)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Temporarily disable
|
114
|
+
def self.disable
|
115
|
+
unless inst = Instrumenter.instance
|
116
|
+
return yield if block_given?
|
117
|
+
return
|
118
|
+
end
|
119
|
+
|
120
|
+
inst.disable { yield }
|
121
|
+
end
|
122
|
+
end
|
@@ -6,6 +6,8 @@ module Skylight
|
|
6
6
|
module ActiveRecord
|
7
7
|
class SQL < Normalizer
|
8
8
|
register "sql.active_record"
|
9
|
+
register "sql.sequel"
|
10
|
+
register "sql.data_mapper"
|
9
11
|
|
10
12
|
CAT = "db.sql.query".freeze
|
11
13
|
|
@@ -24,7 +26,7 @@ module Skylight
|
|
24
26
|
binds = binds.map { |col, val| val.inspect }
|
25
27
|
end
|
26
28
|
|
27
|
-
extracted_title, sql, binds,
|
29
|
+
extracted_title, sql, binds, _ = extract_binds(payload, binds)
|
28
30
|
title = extracted_title if extracted_title
|
29
31
|
|
30
32
|
if sql
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Probes
|
3
|
+
module Sequel
|
4
|
+
class Probe
|
5
|
+
def install
|
6
|
+
require 'sequel/database/logging'
|
7
|
+
::Sequel::Database.class_eval do
|
8
|
+
alias log_yield_without_sk log_yield
|
9
|
+
|
10
|
+
def log_yield(sql, args=nil, &block)
|
11
|
+
log_yield_without_sk(sql, *args) do
|
12
|
+
::ActiveSupport::Notifications.instrument(
|
13
|
+
"sql.sequel",
|
14
|
+
sql: sql,
|
15
|
+
name: "SQL",
|
16
|
+
binds: args
|
17
|
+
) do
|
18
|
+
block.call
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
register("Sequel", "sequel", Sequel::Probe.new)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Probes
|
3
|
+
module Sinatra
|
4
|
+
class Probe
|
5
|
+
def install
|
6
|
+
class << ::Sinatra::Base
|
7
|
+
alias build_without_sk build
|
8
|
+
alias compile_without_sk! compile!
|
9
|
+
|
10
|
+
def compile!(verb, path, *args, &block)
|
11
|
+
compile_without_sk!(verb, path, *args, &block).tap do |_, _, _, wrapper|
|
12
|
+
# Deal with the situation where the path is a regex, and the default behavior
|
13
|
+
# of Ruby stringification produces an unreadable mess
|
14
|
+
if path.is_a?(Regexp)
|
15
|
+
human_readable = "<sk-regex>%r{#{path.source}}</sk-regex>"
|
16
|
+
wrapper.instance_variable_set(:@route_name, "#{verb} #{human_readable}")
|
17
|
+
else
|
18
|
+
wrapper.instance_variable_set(:@route_name, "#{verb} #{path}")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Newer versions of Sinatra populate env['sinatra.route']. Polyfill older
|
22
|
+
# versions in a targeted but hackish way.
|
23
|
+
if ::Sinatra::VERSION < '1.4.0'
|
24
|
+
def wrapper.[](app, args)
|
25
|
+
app.env['sinatra.route'] = @route_name
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def build(*args, &block)
|
33
|
+
self.use Skylight::Middleware
|
34
|
+
build_without_sk(*args, &block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
::Sinatra::Base.class_eval do
|
39
|
+
alias dispatch_without_sk! dispatch!
|
40
|
+
alias compile_template_without_sk compile_template
|
41
|
+
|
42
|
+
def dispatch!(*args, &block)
|
43
|
+
dispatch_without_sk!(*args, &block).tap do
|
44
|
+
instrumenter = Skylight::Instrumenter.instance
|
45
|
+
next unless instrumenter
|
46
|
+
trace = instrumenter.current_trace
|
47
|
+
next unless trace
|
48
|
+
|
49
|
+
# Set the endpoint name to the route name
|
50
|
+
route = env['sinatra.route']
|
51
|
+
trace.endpoint = route if route
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def compile_template(engine, data, options, *args, &block)
|
56
|
+
# Pass along a useful "virtual path" to Tilt. The Tilt probe will handle
|
57
|
+
# instrumenting correctly.
|
58
|
+
case data
|
59
|
+
when Symbol
|
60
|
+
options[:sky_virtual_path] = data.to_s
|
61
|
+
else
|
62
|
+
options[:sky_virtual_path] = "Inline template (#{engine})"
|
63
|
+
end
|
64
|
+
|
65
|
+
compile_template_without_sk(engine, data, options, *args, &block)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
register("Sinatra::Base", "sinatra/base", Sinatra::Probe.new)
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Probes
|
3
|
+
module Tilt
|
4
|
+
class Probe
|
5
|
+
def install
|
6
|
+
::Tilt::Template.class_eval do
|
7
|
+
alias render_without_sk render
|
8
|
+
|
9
|
+
def render(*args, &block)
|
10
|
+
opts = {
|
11
|
+
category: "view.render.template",
|
12
|
+
title: options[:sky_virtual_path] || "Unknown template name"
|
13
|
+
}
|
14
|
+
|
15
|
+
Skylight.instrument(opts) do
|
16
|
+
render_without_sk(*args, &block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
register("Tilt::Template", "tilt/template", Tilt::Probe.new)
|
25
|
+
end
|
26
|
+
end
|
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
|
+
version: 0.6.0.beta.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:
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/skylight/cli.rb
|
50
50
|
- lib/skylight/compat.rb
|
51
51
|
- lib/skylight/config.rb
|
52
|
+
- lib/skylight/core.rb
|
52
53
|
- lib/skylight/data/cacert.pem
|
53
54
|
- lib/skylight/formatters/http.rb
|
54
55
|
- lib/skylight/gc.rb
|
@@ -81,7 +82,11 @@ files:
|
|
81
82
|
- lib/skylight/probes/excon/middleware.rb
|
82
83
|
- lib/skylight/probes/net_http.rb
|
83
84
|
- lib/skylight/probes/redis.rb
|
85
|
+
- lib/skylight/probes/sequel.rb
|
86
|
+
- lib/skylight/probes/sinatra.rb
|
87
|
+
- lib/skylight/probes/tilt.rb
|
84
88
|
- lib/skylight/railtie.rb
|
89
|
+
- lib/skylight/sinatra.rb
|
85
90
|
- lib/skylight/subscriber.rb
|
86
91
|
- lib/skylight/trace.rb
|
87
92
|
- lib/skylight/util.rb
|
@@ -162,9 +167,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
167
|
version: 1.9.2
|
163
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
169
|
requirements:
|
165
|
-
- - "
|
170
|
+
- - ">"
|
166
171
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
172
|
+
version: 1.3.1
|
168
173
|
requirements: []
|
169
174
|
rubyforge_project:
|
170
175
|
rubygems_version: 2.2.2
|
@@ -172,4 +177,3 @@ signing_key:
|
|
172
177
|
specification_version: 4
|
173
178
|
summary: Skylight is a smart profiler for Rails apps
|
174
179
|
test_files: []
|
175
|
-
has_rdoc:
|