skylight-core 3.1.5 → 4.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skylight/core/config.rb +103 -108
- data/lib/skylight/core/deprecation.rb +3 -3
- data/lib/skylight/core/fanout.rb +3 -3
- data/lib/skylight/core/formatters/http.rb +1 -2
- data/lib/skylight/core/gc.rb +31 -36
- data/lib/skylight/core/instrumentable.rb +17 -16
- data/lib/skylight/core/instrumenter.rb +25 -23
- data/lib/skylight/core/middleware.rb +11 -10
- data/lib/skylight/core/normalizers/action_controller/process_action.rb +9 -9
- data/lib/skylight/core/normalizers/action_controller/send_file.rb +16 -16
- data/lib/skylight/core/normalizers/action_view/render_collection.rb +2 -2
- data/lib/skylight/core/normalizers/action_view/render_partial.rb +2 -2
- data/lib/skylight/core/normalizers/action_view/render_template.rb +2 -2
- data/lib/skylight/core/normalizers/active_job/perform.rb +11 -23
- data/lib/skylight/core/normalizers/active_model_serializers/render.rb +6 -6
- data/lib/skylight/core/normalizers/active_record/instantiation.rb +2 -3
- data/lib/skylight/core/normalizers/active_record/sql.rb +1 -2
- data/lib/skylight/core/normalizers/active_support/cache.rb +12 -10
- data/lib/skylight/core/normalizers/active_support/cache_clear.rb +2 -2
- data/lib/skylight/core/normalizers/active_support/cache_decrement.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_delete.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_exist.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_fetch_hit.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_generate.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_increment.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_read.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_read_multi.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_write.rb +3 -3
- data/lib/skylight/core/normalizers/coach/handler_finish.rb +6 -6
- data/lib/skylight/core/normalizers/coach/middleware_finish.rb +2 -2
- data/lib/skylight/core/normalizers/couch_potato/query.rb +20 -0
- data/lib/skylight/core/normalizers/data_mapper/sql.rb +1 -1
- data/lib/skylight/core/normalizers/default.rb +1 -4
- data/lib/skylight/core/normalizers/elasticsearch/request.rb +5 -5
- data/lib/skylight/core/normalizers/grape/endpoint.rb +6 -5
- data/lib/skylight/core/normalizers/grape/endpoint_render.rb +3 -4
- data/lib/skylight/core/normalizers/grape/endpoint_run.rb +2 -3
- data/lib/skylight/core/normalizers/grape/endpoint_run_filters.rb +1 -2
- data/lib/skylight/core/normalizers/grape/format_response.rb +1 -2
- data/lib/skylight/core/normalizers/moped/query.rb +38 -43
- data/lib/skylight/core/normalizers/render.rb +26 -25
- data/lib/skylight/core/normalizers/sequel/sql.rb +1 -1
- data/lib/skylight/core/normalizers/sql.rb +5 -5
- data/lib/skylight/core/normalizers.rb +11 -12
- data/lib/skylight/core/probes/action_controller.rb +15 -14
- data/lib/skylight/core/probes/action_dispatch/request_id.rb +2 -3
- data/lib/skylight/core/probes/action_dispatch/routing/route_set.rb +2 -3
- data/lib/skylight/core/probes/action_dispatch.rb +2 -2
- data/lib/skylight/core/probes/action_view.rb +11 -17
- data/lib/skylight/core/probes/active_job.rb +8 -4
- data/lib/skylight/core/probes/active_job_enqueue.rb +2 -2
- data/lib/skylight/core/probes/active_model_serializers.rb +7 -6
- data/lib/skylight/core/probes/delayed_job.rb +46 -0
- data/lib/skylight/core/probes/elasticsearch.rb +3 -4
- data/lib/skylight/core/probes/excon/middleware.rb +4 -7
- data/lib/skylight/core/probes/excon.rb +2 -2
- data/lib/skylight/core/probes/faraday.rb +1 -2
- data/lib/skylight/core/probes/httpclient.rb +4 -4
- data/lib/skylight/core/probes/middleware.rb +1 -1
- data/lib/skylight/core/probes/mongo.rb +29 -34
- data/lib/skylight/core/probes/mongoid.rb +2 -3
- data/lib/skylight/core/probes/moped.rb +10 -11
- data/lib/skylight/core/probes/net_http.rb +5 -5
- data/lib/skylight/core/probes/redis.rb +3 -4
- data/lib/skylight/core/probes/sequel.rb +4 -4
- data/lib/skylight/core/probes/sinatra.rb +6 -11
- data/lib/skylight/core/probes/tilt.rb +1 -1
- data/lib/skylight/core/probes.rb +16 -17
- data/lib/skylight/core/railtie.rb +120 -119
- data/lib/skylight/core/sidekiq.rb +8 -4
- data/lib/skylight/core/subscriber.rb +25 -29
- data/lib/skylight/core/test.rb +13 -17
- data/lib/skylight/core/trace.rb +76 -76
- data/lib/skylight/core/user_config.rb +9 -11
- data/lib/skylight/core/util/allocation_free.rb +0 -1
- data/lib/skylight/core/util/clock.rb +16 -16
- data/lib/skylight/core/util/gzip.rb +1 -2
- data/lib/skylight/core/util/inflector.rb +5 -4
- data/lib/skylight/core/util/logging.rb +11 -14
- data/lib/skylight/core/util/platform.rb +52 -49
- data/lib/skylight/core/util/proxy.rb +3 -3
- data/lib/skylight/core/util.rb +5 -5
- data/lib/skylight/core/version.rb +1 -2
- data/lib/skylight/core/vm/gc.rb +1 -3
- data/lib/skylight/core.rb +21 -21
- metadata +47 -44
@@ -4,32 +4,26 @@ module Skylight::Core
|
|
4
4
|
class Probe
|
5
5
|
def install
|
6
6
|
::ActionView::TemplateRenderer.class_eval do
|
7
|
-
|
8
|
-
|
9
|
-
def render_with_layout(*args, &block) #:nodoc:
|
10
|
-
path, locals = case args.length
|
11
|
-
when 2
|
12
|
-
args
|
13
|
-
when 4
|
14
|
-
[args[1], args[3]]
|
15
|
-
end
|
7
|
+
alias_method :render_with_layout_without_sk, :render_with_layout
|
16
8
|
|
9
|
+
def render_with_layout(path, locals, *args, &block) #:nodoc:
|
17
10
|
layout = nil
|
18
11
|
|
19
12
|
if path
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
layout =
|
14
|
+
if ::ActionView.gem_version >= Gem::Version.new("5.x")
|
15
|
+
find_layout(path, locals.keys, [formats.first])
|
16
|
+
else
|
17
|
+
find_layout(path, locals.keys)
|
18
|
+
end
|
25
19
|
end
|
26
20
|
|
27
21
|
if layout
|
28
|
-
instrument(:template, :
|
29
|
-
render_with_layout_without_sk(*args, &block)
|
22
|
+
instrument(:template, identifier: layout.identifier) do
|
23
|
+
render_with_layout_without_sk(path, locals, *args, &block)
|
30
24
|
end
|
31
25
|
else
|
32
|
-
render_with_layout_without_sk(*args, &block)
|
26
|
+
render_with_layout_without_sk(path, locals, *args, &block)
|
33
27
|
end
|
34
28
|
end
|
35
29
|
end
|
@@ -2,15 +2,19 @@ module Skylight::Core
|
|
2
2
|
module Probes
|
3
3
|
module ActiveJob
|
4
4
|
class Probe
|
5
|
-
TITLE = 'ActiveJob.execute'.freeze
|
6
|
-
|
7
5
|
def install
|
8
6
|
::ActiveJob::Base.instance_eval do
|
9
7
|
alias execute_without_sk execute
|
10
8
|
|
11
9
|
def execute(*args)
|
12
|
-
Skylight.trace(
|
13
|
-
|
10
|
+
Skylight.trace("ActiveJob.execute", "app.job.execute") do |trace|
|
11
|
+
# See normalizers/active_job/perform for endpoint/segment assignment
|
12
|
+
begin
|
13
|
+
execute_without_sk(*args)
|
14
|
+
rescue Exception
|
15
|
+
trace.segment = "error" if trace
|
16
|
+
raise
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -21,14 +21,14 @@ module Skylight::Core
|
|
21
21
|
end
|
22
22
|
|
23
23
|
self.class.instance_eval do
|
24
|
-
if ::ActiveJob.gem_version >= Gem::Version.new(
|
24
|
+
if ::ActiveJob.gem_version >= Gem::Version.new("5.2")
|
25
25
|
def normalize_adapter_name(job_class)
|
26
26
|
job_class.queue_adapter_name
|
27
27
|
end
|
28
28
|
else
|
29
29
|
def normalize_adapter_name(job_class)
|
30
30
|
adapter_class = job_class.queue_adapter.is_a?(Class) ? job_class.queue_adapter : job_class.queue_adapter.class
|
31
|
-
adapter_class.name.demodulize.remove(
|
31
|
+
adapter_class.name.demodulize.remove("Adapter").underscore
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -6,15 +6,17 @@ module Skylight::Core
|
|
6
6
|
version = nil
|
7
7
|
|
8
8
|
# File moved location between version
|
9
|
-
%w
|
9
|
+
%w[serializer serializers].each do |dir|
|
10
|
+
# rubocop:disable Lint/HandleExceptions
|
10
11
|
begin
|
11
12
|
require "active_model/#{dir}/version"
|
12
13
|
rescue LoadError
|
13
14
|
end
|
15
|
+
# rubocop:enable Lint/HandleExceptions
|
14
16
|
end
|
15
17
|
|
16
|
-
if Gem.loaded_specs[
|
17
|
-
version = Gem.loaded_specs[
|
18
|
+
if Gem.loaded_specs["active_model_serializers"]
|
19
|
+
version = Gem.loaded_specs["active_model_serializers"].version
|
18
20
|
end
|
19
21
|
|
20
22
|
if !version || version < Gem::Version.new("0.5.0")
|
@@ -36,16 +38,15 @@ module Skylight::Core
|
|
36
38
|
|
37
39
|
[::ActiveModel::Serializer, ::ActiveModel::ArraySerializer].each do |klass|
|
38
40
|
klass.class_eval do
|
39
|
-
|
41
|
+
alias_method :as_json_without_sk, :as_json
|
40
42
|
def as_json(*args)
|
41
43
|
payload = { serializer: self.class }
|
42
|
-
ActiveSupport::Notifications.instrument(
|
44
|
+
ActiveSupport::Notifications.instrument("render.active_model_serializers", payload) do
|
43
45
|
as_json_without_sk(*args)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
48
|
-
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Skylight::Core
|
2
|
+
module Probes
|
3
|
+
module DelayedJob
|
4
|
+
class Probe
|
5
|
+
def install
|
6
|
+
return unless validate_version
|
7
|
+
::Delayed::Worker.class_eval do
|
8
|
+
include Skylight::Core::Util::Logging
|
9
|
+
alias_method :run_without_sk, :run
|
10
|
+
alias_method :handle_failed_job_without_sk, :handle_failed_job
|
11
|
+
|
12
|
+
def run(job, *args)
|
13
|
+
t { "Delayed::Job beginning trace" }
|
14
|
+
Skylight.trace(job.name, "app.delayed_job.worker", "Delayed::Worker#run", segment: job.queue) do
|
15
|
+
run_without_sk(job, *args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle_failed_job(job, error, *args)
|
20
|
+
handle_failed_job_without_sk(job, error, *args)
|
21
|
+
return unless Skylight.trace
|
22
|
+
Skylight.trace.segment = "error"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def validate_version
|
30
|
+
spec = Gem.loaded_specs["delayed_job"]
|
31
|
+
version = spec && spec.version
|
32
|
+
|
33
|
+
if !version || version < Gem::Version.new("4.0.0")
|
34
|
+
$stderr.puts "[SKYLIGHT::CORE] [#{Skylight::Core::VERSION}] The installed version of DelayedJob is not supported on Skylight. Your jobs will not be tracked."
|
35
|
+
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
register(:delayed_job, "Delayed::Worker", "delayed_job", DelayedJob::Probe.new)
|
45
|
+
end
|
46
|
+
end
|
@@ -4,14 +4,13 @@ module Skylight::Core
|
|
4
4
|
class Probe
|
5
5
|
def install
|
6
6
|
::Elasticsearch::Transport::Transport::Base.class_eval do
|
7
|
-
|
7
|
+
alias_method :perform_request_without_sk, :perform_request
|
8
8
|
def perform_request(method, path, *args, &block)
|
9
9
|
ActiveSupport::Notifications.instrument "request.elasticsearch",
|
10
|
-
name:
|
10
|
+
name: "Request",
|
11
11
|
method: method,
|
12
12
|
path: path do
|
13
13
|
|
14
|
-
|
15
14
|
# Prevent HTTP-related probes from firing
|
16
15
|
Skylight::Core::Normalizers::Faraday::Request.disable do
|
17
16
|
disable_skylight_probe(:NetHTTP) do
|
@@ -25,7 +24,7 @@ module Skylight::Core
|
|
25
24
|
|
26
25
|
def disable_skylight_probe(class_name, &block)
|
27
26
|
klass = Probes.const_get(class_name).const_get(:Probe) rescue nil
|
28
|
-
klass ? klass.disable(&block) :
|
27
|
+
klass ? klass.disable(&block) : yield
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "skylight/core/formatters/http"
|
2
2
|
|
3
3
|
module Skylight::Core
|
4
4
|
module Probes
|
5
5
|
module Excon
|
6
|
-
|
7
6
|
# Middleware for Excon that instruments requests
|
8
7
|
class Middleware < ::Excon::Middleware::Base
|
9
|
-
|
10
8
|
# This probably won't work since config isn't defined
|
11
9
|
include Util::Logging
|
12
10
|
|
@@ -15,7 +13,7 @@ module Skylight::Core
|
|
15
13
|
super
|
16
14
|
end
|
17
15
|
|
18
|
-
# TODO:
|
16
|
+
# TODO: Review the following:
|
19
17
|
# - Consider whether a LIFO queue would be sufficient
|
20
18
|
# - Check that errors can't be called without a request
|
21
19
|
|
@@ -55,8 +53,8 @@ module Skylight::Core
|
|
55
53
|
end
|
56
54
|
|
57
55
|
def end_instrumentation(datum)
|
58
|
-
if request = @requests.delete(datum.object_id)
|
59
|
-
meta = {
|
56
|
+
if (request = @requests.delete(datum.object_id))
|
57
|
+
meta = {}
|
60
58
|
if datum[:error].is_a?(Exception)
|
61
59
|
meta[:exception_object] = datum[:error]
|
62
60
|
end
|
@@ -65,7 +63,6 @@ module Skylight::Core
|
|
65
63
|
rescue Exception => e
|
66
64
|
error "failed to end instrumentation for Excon; msg=%s", e.message
|
67
65
|
end
|
68
|
-
|
69
66
|
end
|
70
67
|
end
|
71
68
|
end
|
@@ -6,7 +6,7 @@ module Skylight::Core
|
|
6
6
|
def install
|
7
7
|
if defined?(::Excon::Middleware)
|
8
8
|
# Don't require until installation since it depends on Excon being loaded
|
9
|
-
require
|
9
|
+
require "skylight/core/probes/excon/middleware"
|
10
10
|
|
11
11
|
idx = ::Excon.defaults[:middlewares].index(::Excon::Middleware::Instrumentor)
|
12
12
|
|
@@ -23,4 +23,4 @@ module Skylight::Core
|
|
23
23
|
|
24
24
|
register(:excon, "Excon", "excon", Excon::Probe.new)
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
@@ -4,7 +4,7 @@ module Skylight::Core
|
|
4
4
|
class Probe
|
5
5
|
def install
|
6
6
|
::Faraday::Connection.class_eval do
|
7
|
-
|
7
|
+
alias_method :initialize_without_sk, :initialize
|
8
8
|
|
9
9
|
def initialize(*args, &block)
|
10
10
|
initialize_without_sk(*args, &block)
|
@@ -13,7 +13,6 @@ module Skylight::Core
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "skylight/core/formatters/http"
|
2
2
|
|
3
3
|
module Skylight::Core
|
4
4
|
module Probes
|
@@ -24,7 +24,7 @@ module Skylight::Core
|
|
24
24
|
# on that, so this instance method override will cover both
|
25
25
|
# `HTTPClient.get(...)` and `HTTPClient.new.get(...)`
|
26
26
|
|
27
|
-
|
27
|
+
alias_method :do_request_without_sk, :do_request
|
28
28
|
def do_request(method, uri, query, body, header, &block)
|
29
29
|
if Probes::HTTPClient::Probe.disabled?
|
30
30
|
return do_request_without_sk(method, uri, query, body, header, &block)
|
@@ -38,8 +38,8 @@ module Skylight::Core
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
42
|
-
end
|
41
|
+
end
|
42
|
+
end
|
43
43
|
|
44
44
|
register(:httpclient, "HTTPClient", "httpclient", HTTPClient::Probe.new)
|
45
45
|
end
|
@@ -12,10 +12,10 @@ module Skylight::Core
|
|
12
12
|
class Subscriber
|
13
13
|
include Util::Logging
|
14
14
|
|
15
|
-
COMMANDS = [
|
15
|
+
COMMANDS = %i[insert find count distinct update findandmodify delete aggregate].freeze
|
16
16
|
|
17
17
|
COMMAND_NAMES = {
|
18
|
-
findandmodify:
|
18
|
+
findandmodify: "findAndModify".freeze
|
19
19
|
}.freeze
|
20
20
|
|
21
21
|
def initialize
|
@@ -58,7 +58,7 @@ module Skylight::Core
|
|
58
58
|
|
59
59
|
# Not sure if this will always exist
|
60
60
|
# Delete so the description will be less redundant
|
61
|
-
if target = command[event.command_name]
|
61
|
+
if (target = command[event.command_name])
|
62
62
|
title << " #{target}"
|
63
63
|
end
|
64
64
|
|
@@ -66,50 +66,50 @@ module Skylight::Core
|
|
66
66
|
|
67
67
|
# Ruby Hashes are ordered based on insertion so do the most important ones first
|
68
68
|
|
69
|
-
add_value(
|
70
|
-
add_bound(
|
71
|
-
add_bound(
|
72
|
-
add_value(
|
69
|
+
add_value("key".freeze, command, payload)
|
70
|
+
add_bound("query".freeze, command, payload)
|
71
|
+
add_bound("filter".freeze, command, payload)
|
72
|
+
add_value("sort".freeze, command, payload)
|
73
73
|
|
74
74
|
if event.command_name == :findandmodify
|
75
|
-
add_bound(
|
75
|
+
add_bound("update".freeze, command, payload)
|
76
76
|
end
|
77
77
|
|
78
|
-
add_value(
|
79
|
-
add_value(
|
78
|
+
add_value("remove".freeze, command, payload)
|
79
|
+
add_value("new".freeze, command, payload)
|
80
80
|
|
81
|
-
if updates = command[
|
81
|
+
if (updates = command["updates".freeze])
|
82
82
|
# AFAICT the gem generally just sends one item in the updates array
|
83
83
|
update = updates[0]
|
84
84
|
update_payload = {}
|
85
|
-
add_bound(
|
86
|
-
add_bound(
|
87
|
-
add_value(
|
88
|
-
add_value(
|
85
|
+
add_bound("q".freeze, update, update_payload)
|
86
|
+
add_bound("u".freeze, update, update_payload)
|
87
|
+
add_value("multi".freeze, update, update_payload)
|
88
|
+
add_value("upsert".freeze, update, update_payload)
|
89
89
|
|
90
|
-
payload[
|
90
|
+
payload["updates".freeze] = [update_payload]
|
91
91
|
|
92
92
|
if updates.length > 1
|
93
|
-
payload[
|
93
|
+
payload["updates".freeze] << "..."
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
if deletes = command[
|
97
|
+
if (deletes = command["deletes".freeze])
|
98
98
|
# AFAICT the gem generally just sends one item in the updates array
|
99
99
|
delete = deletes[0]
|
100
100
|
delete_payload = {}
|
101
|
-
add_bound(
|
102
|
-
add_value(
|
101
|
+
add_bound("q".freeze, delete, delete_payload)
|
102
|
+
add_value("limit".freeze, delete, delete_payload)
|
103
103
|
|
104
|
-
payload[
|
104
|
+
payload["deletes".freeze] = [delete_payload]
|
105
105
|
|
106
106
|
if deletes.length > 1
|
107
|
-
payload[
|
107
|
+
payload["deletes".freeze] << "..."
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
if (pipeline = command[
|
112
|
-
payload[
|
111
|
+
if (pipeline = command["pipeline".freeze])
|
112
|
+
payload["pipeline".freeze] = pipeline.map { |segment| extract_binds(segment) }
|
113
113
|
end
|
114
114
|
|
115
115
|
# We're ignoring documents from insert because they could have completely inconsistent
|
@@ -128,7 +128,7 @@ module Skylight::Core
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def end_instrumentation(event)
|
131
|
-
if original_event = @events.delete(event.operation_id)
|
131
|
+
if (original_event = @events.delete(event.operation_id))
|
132
132
|
meta = {}
|
133
133
|
if event.is_a?(::Mongo::Monitoring::Event::CommandFailed)
|
134
134
|
meta[:exception] = ["CommandFailed", event.message]
|
@@ -140,14 +140,14 @@ module Skylight::Core
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def add_value(key, command, payload)
|
143
|
-
if command.
|
143
|
+
if command.key?(key)
|
144
144
|
value = command[key]
|
145
145
|
payload[key] = value
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
def add_bound(key, command, payload)
|
150
|
-
if value = command[key]
|
150
|
+
if (value = command[key])
|
151
151
|
payload[key] = extract_binds(value)
|
152
152
|
end
|
153
153
|
end
|
@@ -155,17 +155,12 @@ module Skylight::Core
|
|
155
155
|
def extract_binds(hash)
|
156
156
|
ret = {}
|
157
157
|
|
158
|
-
hash.each do |k,v|
|
159
|
-
|
160
|
-
ret[k] = extract_binds(v)
|
161
|
-
else
|
162
|
-
ret[k] = '?'.freeze
|
163
|
-
end
|
158
|
+
hash.each do |k, v|
|
159
|
+
ret[k] = v.is_a?(Hash) ? extract_binds(v) : "?".freeze
|
164
160
|
end
|
165
161
|
|
166
162
|
ret
|
167
163
|
end
|
168
|
-
|
169
164
|
end
|
170
165
|
end
|
171
166
|
|
@@ -2,9 +2,8 @@ module Skylight::Core
|
|
2
2
|
module Probes
|
3
3
|
module Mongoid
|
4
4
|
class Probe
|
5
|
-
|
6
5
|
def install
|
7
|
-
require
|
6
|
+
require "mongoid/version"
|
8
7
|
version = Gem::Version.new(::Mongoid::VERSION)
|
9
8
|
|
10
9
|
if version < Gem::Version.new("5.0")
|
@@ -18,4 +17,4 @@ module Skylight::Core
|
|
18
17
|
|
19
18
|
register(:mongoid, "Mongoid", "mongoid", Mongoid::Probe.new)
|
20
19
|
end
|
21
|
-
end
|
20
|
+
end
|
@@ -2,7 +2,6 @@ module Skylight::Core
|
|
2
2
|
module Probes
|
3
3
|
module Moped
|
4
4
|
class Probe
|
5
|
-
|
6
5
|
def install
|
7
6
|
unless defined?(::Moped::Instrumentable)
|
8
7
|
# Using $stderr here isn't great, but we don't have a logger accessible
|
@@ -13,27 +12,27 @@ module Skylight::Core
|
|
13
12
|
end
|
14
13
|
|
15
14
|
::Moped::Instrumentable.module_eval do
|
16
|
-
|
15
|
+
alias_method :instrument_without_sk, :instrument
|
17
16
|
|
18
17
|
def instrument(*args, &block)
|
19
18
|
# Mongoid sets the instrumenter to AS::N
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
asn_block =
|
20
|
+
if instrumenter == ActiveSupport::Notifications
|
21
|
+
block
|
22
|
+
else
|
23
|
+
# If the instrumenter hasn't been changed to AS::N use both
|
24
|
+
proc do
|
25
|
+
ActiveSupport::Notifications.instrument(*args, &block)
|
26
|
+
end
|
26
27
|
end
|
27
|
-
end
|
28
28
|
|
29
29
|
instrument_without_sk(*args, &asn_block)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
36
|
register(:moped, "Moped", "moped", Moped::Probe.new)
|
38
37
|
end
|
39
|
-
end
|
38
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "skylight/core/formatters/http"
|
2
2
|
|
3
3
|
module Skylight::Core
|
4
4
|
module Probes
|
@@ -20,7 +20,7 @@ module Skylight::Core
|
|
20
20
|
|
21
21
|
def install
|
22
22
|
Net::HTTP.class_eval do
|
23
|
-
|
23
|
+
alias_method :request_without_sk, :request
|
24
24
|
|
25
25
|
def request(req, body = nil, &block)
|
26
26
|
if !started? || Probes::NetHTTP::Probe.disabled?
|
@@ -30,11 +30,11 @@ module Skylight::Core
|
|
30
30
|
method = req.method
|
31
31
|
|
32
32
|
# req['host'] also includes special handling for default ports
|
33
|
-
host, port = req[
|
33
|
+
host, port = req["host"] ? req["host"].split(":") : nil
|
34
34
|
|
35
35
|
# If we're connected with a persistent socket
|
36
|
-
host ||=
|
37
|
-
port ||=
|
36
|
+
host ||= address
|
37
|
+
port ||= port
|
38
38
|
|
39
39
|
path = req.path
|
40
40
|
scheme = use_ssl? ? "https" : "http"
|
@@ -13,7 +13,7 @@ module Skylight::Core
|
|
13
13
|
end
|
14
14
|
|
15
15
|
::Redis::Client.class_eval do
|
16
|
-
|
16
|
+
alias_method :call_without_sk, :call
|
17
17
|
|
18
18
|
def call(command, &block)
|
19
19
|
command_name = command[0]
|
@@ -46,7 +46,7 @@ module Skylight::Core
|
|
46
46
|
}.freeze
|
47
47
|
|
48
48
|
::Redis.class_eval do
|
49
|
-
|
49
|
+
alias_method :pipelined_without_sk, :pipelined
|
50
50
|
|
51
51
|
def pipelined(&block)
|
52
52
|
Skylight::Core::Fanout.instrument(PIPELINED_OPTS) do
|
@@ -54,8 +54,7 @@ module Skylight::Core
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
alias multi_without_sk multi
|
57
|
+
alias_method :multi_without_sk, :multi
|
59
58
|
|
60
59
|
def multi(&block)
|
61
60
|
Skylight::Core::Fanout.instrument(MULTI_OPTS) do
|
@@ -4,11 +4,11 @@ module Skylight::Core
|
|
4
4
|
module Sequel
|
5
5
|
class Probe
|
6
6
|
def install
|
7
|
-
require
|
7
|
+
require "sequel/database/logging"
|
8
8
|
|
9
|
-
method_name = ::Sequel::Database.method_defined?(:log_connection_yield) ?
|
9
|
+
method_name = ::Sequel::Database.method_defined?(:log_connection_yield) ? "log_connection_yield" : "log_yield"
|
10
10
|
|
11
|
-
::Sequel::Database.class_eval <<-
|
11
|
+
::Sequel::Database.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
12
12
|
alias #{method_name}_without_sk #{method_name}
|
13
13
|
|
14
14
|
def #{method_name}(sql, *args, &block)
|
@@ -23,7 +23,7 @@ module Skylight::Core
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
RUBY
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -3,14 +3,14 @@ module Skylight::Core
|
|
3
3
|
module Sinatra
|
4
4
|
class Probe
|
5
5
|
def install
|
6
|
-
if ::Sinatra::VERSION <
|
6
|
+
if ::Sinatra::VERSION < "1.4.0"
|
7
7
|
# Using $stderr here isn't great, but we don't have a logger accessible
|
8
8
|
$stderr.puts "[SKYLIGHT::CORE] [#{Skylight::VERSION}] Sinatra must be version 1.4.0 or greater."
|
9
9
|
return
|
10
10
|
end
|
11
11
|
|
12
12
|
class << ::Sinatra::Base
|
13
|
-
|
13
|
+
alias_method :compile_without_sk!, :compile!
|
14
14
|
|
15
15
|
def compile!(verb, path, *args, &block)
|
16
16
|
compile_without_sk!(verb, path, *args, &block).tap do |_, _, keys_or_wrapper, wrapper|
|
@@ -29,14 +29,14 @@ module Skylight::Core
|
|
29
29
|
end
|
30
30
|
|
31
31
|
::Sinatra::Base.class_eval do
|
32
|
-
|
33
|
-
|
32
|
+
alias_method :dispatch_without_sk!, :dispatch!
|
33
|
+
alias_method :compile_template_without_sk, :compile_template
|
34
34
|
|
35
35
|
def dispatch!(*args, &block)
|
36
36
|
dispatch_without_sk!(*args, &block).tap do
|
37
37
|
Skylight::Core::Fanout.each_trace do |trace|
|
38
38
|
# Set the endpoint name to the route name
|
39
|
-
route = env[
|
39
|
+
route = env["sinatra.route"]
|
40
40
|
trace.endpoint = route if route
|
41
41
|
end
|
42
42
|
end
|
@@ -45,12 +45,7 @@ module Skylight::Core
|
|
45
45
|
def compile_template(engine, data, options, *args, &block)
|
46
46
|
# Pass along a useful "virtual path" to Tilt. The Tilt probe will handle
|
47
47
|
# instrumenting correctly.
|
48
|
-
|
49
|
-
when Symbol
|
50
|
-
options[:sky_virtual_path] = data.to_s
|
51
|
-
else
|
52
|
-
options[:sky_virtual_path] = "Inline template (#{engine})"
|
53
|
-
end
|
48
|
+
options[:sky_virtual_path] = data.is_a?(Symbol) ? data.to_s : "Inline template (#{engine})"
|
54
49
|
|
55
50
|
compile_template_without_sk(engine, data, options, *args, &block)
|
56
51
|
end
|