skylight 1.7.2 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -33
- data/ext/extconf.rb +32 -6
- data/ext/libskylight.yml +6 -9
- data/ext/skylight_native.c +49 -18
- data/lib/skylight.rb +35 -1
- data/lib/skylight/api.rb +4 -2
- data/lib/skylight/cli.rb +1 -1
- data/lib/skylight/cli/doctor.rb +6 -4
- data/lib/skylight/config.rb +149 -518
- data/lib/skylight/data/cacert.pem +236 -812
- data/lib/skylight/helpers.rb +5 -1
- data/lib/skylight/instrumenter.rb +10 -241
- data/lib/skylight/middleware.rb +1 -89
- data/lib/skylight/native.rb +8 -6
- data/lib/skylight/native_ext_fetcher.rb +251 -0
- data/lib/skylight/normalizers/active_job/enqueue_at.rb +2 -20
- data/lib/skylight/probes/sinatra_add_middleware.rb +22 -0
- data/lib/skylight/railtie.rb +11 -131
- data/lib/skylight/sinatra.rb +1 -5
- data/lib/skylight/trace.rb +1 -229
- data/lib/skylight/util/http.rb +3 -3
- data/lib/skylight/vendor/cli/thor/actions/directory.rb +5 -15
- data/lib/skylight/version.rb +1 -1
- metadata +114 -91
- data/lib/skylight/compat.rb +0 -76
- data/lib/skylight/core.rb +0 -149
- data/lib/skylight/deprecation.rb +0 -55
- data/lib/skylight/formatters/http.rb +0 -20
- data/lib/skylight/gc.rb +0 -107
- data/lib/skylight/normalizers.rb +0 -192
- data/lib/skylight/normalizers/action_controller/process_action.rb +0 -50
- data/lib/skylight/normalizers/action_controller/send_file.rb +0 -50
- data/lib/skylight/normalizers/action_view/render_collection.rb +0 -22
- data/lib/skylight/normalizers/action_view/render_partial.rb +0 -21
- data/lib/skylight/normalizers/action_view/render_template.rb +0 -21
- data/lib/skylight/normalizers/active_model_serializers/render.rb +0 -26
- data/lib/skylight/normalizers/active_record/instantiation.rb +0 -17
- data/lib/skylight/normalizers/active_record/sql.rb +0 -55
- data/lib/skylight/normalizers/active_support/cache.rb +0 -51
- data/lib/skylight/normalizers/active_support/cache_clear.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_decrement.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_delete.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_exist.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_generate.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_increment.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_read.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_read_multi.rb +0 -16
- data/lib/skylight/normalizers/active_support/cache_write.rb +0 -16
- data/lib/skylight/normalizers/coach/handler_finish.rb +0 -36
- data/lib/skylight/normalizers/coach/middleware_finish.rb +0 -23
- data/lib/skylight/normalizers/couch_potato/query.rb +0 -20
- data/lib/skylight/normalizers/default.rb +0 -27
- data/lib/skylight/normalizers/elasticsearch/request.rb +0 -20
- data/lib/skylight/normalizers/faraday/request.rb +0 -38
- data/lib/skylight/normalizers/grape/endpoint.rb +0 -30
- data/lib/skylight/normalizers/grape/endpoint_render.rb +0 -26
- data/lib/skylight/normalizers/grape/endpoint_run.rb +0 -33
- data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +0 -23
- data/lib/skylight/normalizers/moped/query.rb +0 -100
- data/lib/skylight/probes.rb +0 -129
- data/lib/skylight/probes/action_controller.rb +0 -64
- data/lib/skylight/probes/action_dispatch.rb +0 -30
- data/lib/skylight/probes/action_view.rb +0 -43
- data/lib/skylight/probes/active_model_serializers.rb +0 -55
- data/lib/skylight/probes/elasticsearch.rb +0 -37
- data/lib/skylight/probes/excon.rb +0 -26
- data/lib/skylight/probes/excon/middleware.rb +0 -68
- data/lib/skylight/probes/faraday.rb +0 -22
- data/lib/skylight/probes/grape.rb +0 -88
- data/lib/skylight/probes/httpclient.rb +0 -46
- data/lib/skylight/probes/middleware.rb +0 -68
- data/lib/skylight/probes/mongo.rb +0 -161
- data/lib/skylight/probes/mongoid.rb +0 -21
- data/lib/skylight/probes/moped.rb +0 -39
- data/lib/skylight/probes/net_http.rb +0 -58
- data/lib/skylight/probes/redis.rb +0 -71
- data/lib/skylight/probes/sequel.rb +0 -37
- data/lib/skylight/probes/sinatra.rb +0 -76
- data/lib/skylight/probes/tilt.rb +0 -31
- data/lib/skylight/subscriber.rb +0 -122
- data/lib/skylight/user_config.rb +0 -60
- data/lib/skylight/util.rb +0 -17
- data/lib/skylight/util/allocation_free.rb +0 -26
- data/lib/skylight/util/clock.rb +0 -54
- data/lib/skylight/util/deploy.rb +0 -132
- data/lib/skylight/util/gzip.rb +0 -21
- data/lib/skylight/util/inflector.rb +0 -112
- data/lib/skylight/util/logging.rb +0 -127
- data/lib/skylight/util/multi_io.rb +0 -21
- data/lib/skylight/util/native_ext_fetcher.rb +0 -253
- data/lib/skylight/util/platform.rb +0 -75
- data/lib/skylight/util/proxy.rb +0 -13
- data/lib/skylight/vendor/active_support/notifications.rb +0 -207
- data/lib/skylight/vendor/active_support/notifications/fanout.rb +0 -159
- data/lib/skylight/vendor/active_support/notifications/instrumenter.rb +0 -72
- data/lib/skylight/vendor/active_support/per_thread_registry.rb +0 -52
- data/lib/skylight/vendor/thread_safe.rb +0 -126
- data/lib/skylight/vendor/thread_safe/non_concurrent_cache_backend.rb +0 -133
- data/lib/skylight/vendor/thread_safe/synchronized_cache_backend.rb +0 -76
- data/lib/skylight/vm/gc.rb +0 -70
@@ -1,20 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
module Skylight
|
4
|
-
module Normalizers
|
5
|
-
module CouchPotato
|
6
|
-
class Query < Normalizer
|
7
|
-
register "couch_potato.load"
|
8
|
-
register "couch_potato.view"
|
9
|
-
|
10
|
-
CAT = "db.couch_db.query".freeze
|
11
|
-
|
12
|
-
def normalize(trace, name, payload)
|
13
|
-
description = payload[:name] if payload
|
14
|
-
_name = name.sub('couch_potato.', '')
|
15
|
-
[CAT, _name, description]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
|
4
|
-
# The default normalizer, used if no other is found.
|
5
|
-
class Default
|
6
|
-
|
7
|
-
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
8
|
-
# @param name [String]
|
9
|
-
# @param payload [Hash]
|
10
|
-
# @option payload [String] :title
|
11
|
-
# @option payload [String] :description
|
12
|
-
# @return [Array, :skip] the normalized array or `:skip` if `name` is not part of a known {Skylight::TIERS tier}
|
13
|
-
def normalize(trace, name, payload)
|
14
|
-
if name =~ TIER_REGEX
|
15
|
-
[
|
16
|
-
name,
|
17
|
-
payload[:title],
|
18
|
-
payload[:description]
|
19
|
-
]
|
20
|
-
else
|
21
|
-
:skip
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Elasticsearch
|
4
|
-
class Request < Normalizer
|
5
|
-
register "request.elasticsearch"
|
6
|
-
|
7
|
-
CAT = "db.elasticsearch.request".freeze
|
8
|
-
|
9
|
-
def normalize(trace, name, payload)
|
10
|
-
path = payload[:path].split('/')
|
11
|
-
title = [payload[:method], path[0]].compact.join(' ')
|
12
|
-
desc = {}
|
13
|
-
desc[:type] = path[1] if path[1]
|
14
|
-
desc[:id] = '?' if path[2]
|
15
|
-
[ CAT, title, desc.presence.try(:to_json) ]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Faraday
|
4
|
-
class Request < Normalizer
|
5
|
-
register "request.faraday"
|
6
|
-
|
7
|
-
DISABLED_KEY = :__skylight_faraday_disabled
|
8
|
-
|
9
|
-
def self.disable
|
10
|
-
Thread.current[DISABLED_KEY] = true
|
11
|
-
yield
|
12
|
-
ensure
|
13
|
-
Thread.current[DISABLED_KEY] = false
|
14
|
-
end
|
15
|
-
|
16
|
-
def disabled?
|
17
|
-
!!Thread.current[DISABLED_KEY]
|
18
|
-
end
|
19
|
-
|
20
|
-
def normalize(_trace, _name, payload)
|
21
|
-
uri = payload[:url]
|
22
|
-
|
23
|
-
if disabled?
|
24
|
-
return :skip
|
25
|
-
end
|
26
|
-
|
27
|
-
opts = Formatters::HTTP.build_opts(payload[:method], uri.scheme,
|
28
|
-
uri.host, uri.port, uri.path, uri.query)
|
29
|
-
description = opts[:title]
|
30
|
-
|
31
|
-
# We use "Faraday" as the title to differentiate it in the UI in
|
32
|
-
# case it's wrapping or is wrapped by another HTTP backend
|
33
|
-
[opts[:category], "Faraday", description]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Grape
|
4
|
-
class Endpoint < Normalizer
|
5
|
-
%w(run
|
6
|
-
render
|
7
|
-
run_filters).each do |type|
|
8
|
-
require "skylight/normalizers/grape/endpoint_#{type}"
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def get_method(endpoint)
|
14
|
-
method = endpoint.options[:method].first
|
15
|
-
method = "#{method}..." if endpoint.options[:method].length > 1
|
16
|
-
method
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_path(endpoint)
|
20
|
-
endpoint.options[:path].join("/")
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_namespace(endpoint)
|
24
|
-
::Grape::Namespace.joined_space(endpoint.namespace_stackable(:namespace))
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Grape
|
4
|
-
class EndpointRender < Endpoint
|
5
|
-
register "endpoint_render.grape"
|
6
|
-
|
7
|
-
CAT = "app.grape.endpoint".freeze
|
8
|
-
|
9
|
-
def normalize(trace, name, payload)
|
10
|
-
if endpoint = payload[:endpoint]
|
11
|
-
path = get_path(endpoint)
|
12
|
-
namespace = get_namespace(endpoint)
|
13
|
-
method = get_method(endpoint)
|
14
|
-
|
15
|
-
title = [method, namespace, path].join(' ').gsub(/\s+/, ' ')
|
16
|
-
|
17
|
-
[CAT, title, nil]
|
18
|
-
else
|
19
|
-
:skip
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Grape
|
4
|
-
class EndpointRun < Endpoint
|
5
|
-
register "endpoint_run.grape"
|
6
|
-
|
7
|
-
def normalize(trace, name, payload)
|
8
|
-
trace.endpoint = get_endpoint_name(payload[:endpoint]) if payload[:endpoint]
|
9
|
-
|
10
|
-
# We don't necessarily want this to be all instrumented since it's fairly internal.
|
11
|
-
# However, it is a good place to get the endpoint name.
|
12
|
-
:skip
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def get_endpoint_name(endpoint)
|
18
|
-
method = get_method(endpoint)
|
19
|
-
path = get_path(endpoint)
|
20
|
-
namespace = get_namespace(endpoint)
|
21
|
-
|
22
|
-
if namespace && !namespace.empty?
|
23
|
-
path = "/#{path}" if path[0] != '/'
|
24
|
-
path = "#{namespace}#{path}"
|
25
|
-
end
|
26
|
-
|
27
|
-
"#{endpoint.options[:for]} [#{method}] #{path}"
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Grape
|
4
|
-
class EndpointRunFilters < Endpoint
|
5
|
-
register "endpoint_run_filters.grape"
|
6
|
-
|
7
|
-
CAT = "app.grape.filters".freeze
|
8
|
-
|
9
|
-
def normalize(trace, name, payload)
|
10
|
-
filters = payload[:filters]
|
11
|
-
type = payload[:type]
|
12
|
-
|
13
|
-
if (!filters || filters.empty?) || !type
|
14
|
-
return :skip
|
15
|
-
end
|
16
|
-
|
17
|
-
[CAT, "#{type.to_s.capitalize} Filters", nil]
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Normalizers
|
3
|
-
module Moped
|
4
|
-
class Query < Normalizer
|
5
|
-
register "query.moped"
|
6
|
-
|
7
|
-
CAT = "db.mongo.query".freeze
|
8
|
-
|
9
|
-
# Normalizes a Moped operation
|
10
|
-
#
|
11
|
-
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
12
|
-
# @param name [String] ignored, only present to match API
|
13
|
-
# @param payload [Hash]
|
14
|
-
# @option payload [Array<Moped::Protocol::*>] :ops array of performed operations. Supported operations are
|
15
|
-
# `Query`, `GetMore`, `Insert`, `Update`, and `Delete`.
|
16
|
-
# @option payload [String] :prefix ignored, provided by Moped
|
17
|
-
# @return [Array, :skip] the normalized array or `:skip` if not a known operation type
|
18
|
-
def normalize(trace, name, payload)
|
19
|
-
# payload: { prefix: " MOPED: #{address.resolved}", ops: operations }
|
20
|
-
|
21
|
-
# We can sometimes have multiple operations. However, it seems like this only happens when doing things
|
22
|
-
# like an insert, followed by a get last error, so we can probably ignore all but the first.
|
23
|
-
operation = payload[:ops] ? payload[:ops].first : nil
|
24
|
-
type = operation && operation.class.to_s =~ /^Moped::Protocol::(.+)$/ ? $1 : nil
|
25
|
-
|
26
|
-
case type
|
27
|
-
when "Query".freeze then normalize_query(operation)
|
28
|
-
when "GetMore".freeze then normalize_get_more(operation)
|
29
|
-
when "Insert".freeze then normalize_insert(operation)
|
30
|
-
when "Update".freeze then normalize_update(operation)
|
31
|
-
when "Delete".freeze then normalize_delete(operation)
|
32
|
-
else :skip
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def normalize_query(operation)
|
39
|
-
title = normalize_title("QUERY".freeze, operation)
|
40
|
-
|
41
|
-
hash = extract_binds(operation.selector)
|
42
|
-
description = hash.to_json
|
43
|
-
|
44
|
-
[CAT, title, description]
|
45
|
-
end
|
46
|
-
|
47
|
-
def normalize_get_more(operation)
|
48
|
-
title = normalize_title("GET_MORE".freeze, operation)
|
49
|
-
|
50
|
-
[CAT, title, nil]
|
51
|
-
end
|
52
|
-
|
53
|
-
def normalize_insert(operation)
|
54
|
-
title = normalize_title("INSERT".freeze, operation)
|
55
|
-
|
56
|
-
[CAT, title, nil]
|
57
|
-
end
|
58
|
-
|
59
|
-
def normalize_update(operation)
|
60
|
-
title = normalize_title("UPDATE".freeze, operation)
|
61
|
-
|
62
|
-
selector_hash = extract_binds(operation.selector)
|
63
|
-
update_hash = extract_binds(operation.update)
|
64
|
-
|
65
|
-
description = { selector: selector_hash, update: update_hash }.to_json
|
66
|
-
|
67
|
-
[CAT, title, description]
|
68
|
-
end
|
69
|
-
|
70
|
-
def normalize_delete(operation)
|
71
|
-
title = normalize_title("DELETE".freeze, operation)
|
72
|
-
|
73
|
-
hash = extract_binds(operation.selector)
|
74
|
-
description = hash.to_json
|
75
|
-
|
76
|
-
[CAT, title, description]
|
77
|
-
end
|
78
|
-
|
79
|
-
def normalize_title(type, operation)
|
80
|
-
"#{type} #{operation.collection}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def extract_binds(hash)
|
84
|
-
ret = {}
|
85
|
-
|
86
|
-
hash.each do |k,v|
|
87
|
-
if v.is_a?(Hash)
|
88
|
-
ret[k] = extract_binds(v)
|
89
|
-
else
|
90
|
-
ret[k] = '?'.freeze
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
ret
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
data/lib/skylight/probes.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
|
3
|
-
module Skylight
|
4
|
-
# @api private
|
5
|
-
module Probes
|
6
|
-
class ProbeRegistration
|
7
|
-
attr_reader :name, :klass_name, :require_paths, :probe
|
8
|
-
|
9
|
-
def initialize(name, klass_name, require_paths, probe)
|
10
|
-
@name = name
|
11
|
-
@klass_name = klass_name
|
12
|
-
@require_paths = Array(require_paths)
|
13
|
-
@probe = probe
|
14
|
-
end
|
15
|
-
|
16
|
-
def install
|
17
|
-
probe.install
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.available
|
22
|
-
unless @available
|
23
|
-
root = Pathname.new(File.expand_path("../probes", __FILE__))
|
24
|
-
@available = {}
|
25
|
-
Dir["#{root}/**/*.rb"].each do |f|
|
26
|
-
name = Pathname.new(f).relative_path_from(root).sub_ext('').to_s
|
27
|
-
@available[name] = "skylight/probes/#{name}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
@available
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.probe(*probes)
|
34
|
-
unknown = probes.map(&:to_s) - available.keys
|
35
|
-
unless unknown.empty?
|
36
|
-
raise ArgumentError, "unknown probes: #{unknown.join(', ')}"
|
37
|
-
end
|
38
|
-
|
39
|
-
probes.each do |p|
|
40
|
-
begin
|
41
|
-
@via_api = true
|
42
|
-
require available[p.to_s]
|
43
|
-
ensure
|
44
|
-
@via_api = false
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.require_hooks
|
50
|
-
@require_hooks ||= {}
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.installed
|
54
|
-
@installed ||= {}
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.is_available?(klass_name)
|
58
|
-
!!Skylight::Util::Inflector.safe_constantize(klass_name)
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.register(name, *args)
|
62
|
-
unless @via_api
|
63
|
-
DEPRECATOR.deprecation_warning("Enabling probes via `require` alone",
|
64
|
-
"use `Skylight.probe(:#{name})` instead")
|
65
|
-
end
|
66
|
-
|
67
|
-
registration = ProbeRegistration.new(name, *args)
|
68
|
-
|
69
|
-
if is_available?(registration.klass_name)
|
70
|
-
installed[registration.klass_name] = registration
|
71
|
-
registration.install
|
72
|
-
else
|
73
|
-
register_require_hook(registration)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.require_hook(require_path)
|
78
|
-
return unless Skylight.native?
|
79
|
-
|
80
|
-
registration = lookup_by_require_path(require_path)
|
81
|
-
return unless registration
|
82
|
-
|
83
|
-
# Double check constant is available
|
84
|
-
if is_available?(registration.klass_name)
|
85
|
-
installed[registration.klass_name] = registration
|
86
|
-
registration.install
|
87
|
-
|
88
|
-
# Don't need this to be called again
|
89
|
-
unregister_require_hook(registration)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.register_require_hook(registration)
|
94
|
-
registration.require_paths.each do |p|
|
95
|
-
require_hooks[p] = registration
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.unregister_require_hook(registration)
|
100
|
-
registration.require_paths.each do |p|
|
101
|
-
require_hooks.delete(p)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.lookup_by_require_path(require_path)
|
106
|
-
require_hooks[require_path]
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# Allow hooking require
|
112
|
-
# @api private
|
113
|
-
module ::Kernel
|
114
|
-
private
|
115
|
-
|
116
|
-
alias require_without_sk require
|
117
|
-
|
118
|
-
def require(name)
|
119
|
-
ret = require_without_sk(name)
|
120
|
-
|
121
|
-
begin
|
122
|
-
Skylight::Probes.require_hook(name)
|
123
|
-
rescue Exception
|
124
|
-
# FIXME: Log these errors
|
125
|
-
end
|
126
|
-
|
127
|
-
ret
|
128
|
-
end
|
129
|
-
end
|