skylight 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/skylight/core.rb +14 -0
- data/lib/skylight/deprecation.rb +55 -0
- data/lib/skylight/normalizers.rb +26 -7
- data/lib/skylight/normalizers/active_job/enqueue_at.rb +1 -1
- data/lib/skylight/probes.rb +40 -4
- data/lib/skylight/probes/action_controller.rb +1 -1
- data/lib/skylight/probes/action_view.rb +1 -1
- data/lib/skylight/probes/active_model_serializers.rb +1 -1
- data/lib/skylight/probes/elasticsearch.rb +1 -1
- data/lib/skylight/probes/excon.rb +1 -1
- data/lib/skylight/probes/faraday.rb +1 -1
- data/lib/skylight/probes/grape.rb +4 -2
- data/lib/skylight/probes/httpclient.rb +1 -1
- data/lib/skylight/probes/middleware.rb +1 -1
- data/lib/skylight/probes/mongo.rb +1 -1
- data/lib/skylight/probes/mongoid.rb +3 -3
- data/lib/skylight/probes/moped.rb +1 -1
- data/lib/skylight/probes/net_http.rb +1 -1
- data/lib/skylight/probes/redis.rb +1 -1
- data/lib/skylight/probes/sequel.rb +5 -1
- data/lib/skylight/probes/sinatra.rb +1 -1
- data/lib/skylight/probes/tilt.rb +5 -1
- data/lib/skylight/railtie.rb +2 -3
- data/lib/skylight/sinatra.rb +6 -3
- data/lib/skylight/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55eaebadf3fb220c9b3dbccdfc9a7a24daff7eda6775b89e58ea5fe0e2a1ba56
|
4
|
+
data.tar.gz: 894eb4d03f6b66ca6301884c98f754f0d03dbdb416e40a662b34733e2c5c19f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e18ee5d48433c0bdb42090e975ccffbd28b34e179a77f252048bccc27669f41b08a6648aabc55b79eac2158ee57ac74b3308f22bc8ff25e2da1d50efe552073
|
7
|
+
data.tar.gz: d346a3b7a24e4453324273320c8400d998302a4c658957aef9274fd40f8735c2f33f8245e6ef33ed1dbc39ac081b0fb7bee7addce81f02c4c1457257bf3cddb7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.7.0 (April 24, 2018)
|
2
|
+
|
3
|
+
* [FEATURE] New API for loading Probes. Example: `Skylight.probe(:excon')`
|
4
|
+
* [FEATURE] New API for enabling non-default Normalizers. Example: `Skylight.enable_normalizer('active_job')`
|
5
|
+
* [DEPRECATION] Support for Rails versions prior to 4.2
|
6
|
+
* [DEPRECATION] Support for Tilt versions prior to 1.4.1
|
7
|
+
* [DEPRECATION] Support for Sinatra versions prior to 1.4
|
8
|
+
* [DEPRECATION] Support for Grape versions prior to 0.13.0
|
9
|
+
|
1
10
|
## 1.6.1 (April 12, 2018)
|
2
11
|
|
3
12
|
* [IMPROVEMENT] Include endpoint name in error logging
|
data/lib/skylight/core.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'skylight/version'
|
2
|
+
require 'skylight/deprecation'
|
2
3
|
|
3
4
|
# Root Skylight namespace
|
4
5
|
module Skylight
|
6
|
+
|
5
7
|
# @api private
|
6
8
|
TRACE_ENV_KEY = 'SKYLIGHT_ENABLE_TRACE_LOGS'.freeze
|
7
9
|
|
@@ -11,6 +13,10 @@ module Skylight
|
|
11
13
|
# Specifically check for Railtie since we've had at least one case of a
|
12
14
|
# customer having Rails defined without having all of Rails loaded.
|
13
15
|
if defined?(Rails::Railtie)
|
16
|
+
if Gem::Version.new(Rails.version) < Gem::Version.new('4.2.0')
|
17
|
+
DEPRECATOR.deprecation_warning("Support for Rails versions before 4.2")
|
18
|
+
end
|
19
|
+
|
14
20
|
require 'skylight/railtie'
|
15
21
|
end
|
16
22
|
|
@@ -59,6 +65,14 @@ module Skylight
|
|
59
65
|
# @api private
|
60
66
|
DEFAULT_OPTIONS = { category: DEFAULT_CATEGORY }
|
61
67
|
|
68
|
+
def self.probe(*args)
|
69
|
+
Probes.probe(*args)
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.enable_normalizer(*names)
|
73
|
+
Normalizers.enable(*names)
|
74
|
+
end
|
75
|
+
|
62
76
|
# Start instrumenting
|
63
77
|
def self.start!(*args)
|
64
78
|
Instrumenter.start!(*args)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'active_support/deprecation'
|
2
|
+
|
3
|
+
module Skylight
|
4
|
+
SKYLIGHT_GEM_ROOT = File.expand_path("../../..", __FILE__) + "/"
|
5
|
+
|
6
|
+
if ActiveSupport::Deprecation.respond_to?(:new)
|
7
|
+
class Deprecation < ActiveSupport::Deprecation
|
8
|
+
private
|
9
|
+
|
10
|
+
def ignored_callstack(path)
|
11
|
+
path.start_with?(SKYLIGHT_GEM_ROOT)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
else
|
15
|
+
# Rails 3.x
|
16
|
+
class Deprecation
|
17
|
+
attr_accessor :silenced
|
18
|
+
attr_reader :deprecation_horizon, :gem_name
|
19
|
+
|
20
|
+
def initialize(deprecation_horizon, gem_name)
|
21
|
+
@deprecation_horizon = deprecation_horizon
|
22
|
+
@gem_name = gem_name
|
23
|
+
end
|
24
|
+
|
25
|
+
# Silence deprecation warnings within the block.
|
26
|
+
def silence
|
27
|
+
old_silenced, @silenced = @silenced, true
|
28
|
+
yield
|
29
|
+
ensure
|
30
|
+
@silenced = old_silenced
|
31
|
+
end
|
32
|
+
|
33
|
+
def deprecation_warning(deprecated_method_name, message = nil)
|
34
|
+
return if silenced
|
35
|
+
|
36
|
+
msg = "#{deprecated_method_name} is deprecated and will be removed from #{gem_name} #{deprecation_horizon}"
|
37
|
+
case message
|
38
|
+
when Symbol then msg << " (use #{message} instead)"
|
39
|
+
when String then msg << " (#{message})"
|
40
|
+
end
|
41
|
+
|
42
|
+
ActiveSupport::Deprecation.warn(msg, extract_callstack(caller))
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def extract_callstack(callstack)
|
48
|
+
filtered = callstack.reject { |line| line.start_with?(SKYLIGHT_GEM_ROOT) }
|
49
|
+
filtered.empty? ? callstack : filtered
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
DEPRECATOR = Deprecation.new('2.0', 'skylight')
|
55
|
+
end
|
data/lib/skylight/normalizers.rb
CHANGED
@@ -7,29 +7,47 @@ module Skylight
|
|
7
7
|
|
8
8
|
DEFAULT = Default.new
|
9
9
|
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
10
|
+
def self.registry
|
11
|
+
@registry ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.register(name, klass, opts)
|
15
|
+
enabled = opts[:enabled] != false
|
16
|
+
registry[name] = [klass, enabled]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.enable(*names)
|
20
|
+
names.each do |name|
|
21
|
+
matches = registry.select{|n,_| n =~ /(^|\.)#{name}$/ }
|
22
|
+
raise ArgumentError, "no normalizers match #{name}" if matches.empty?
|
23
|
+
matches.each{|k,v| v[1] = true }
|
24
|
+
end
|
13
25
|
end
|
14
26
|
|
15
27
|
def self.build(config)
|
16
28
|
normalizers = {}
|
17
29
|
|
18
|
-
|
30
|
+
registry.each do |key, (klass, enabled)|
|
31
|
+
if !enabled
|
32
|
+
# For now we use anyway, but in 2.0 we'll stop using disabled normalizers
|
33
|
+
DEPRECATOR.deprecation_warning("Enabling non-default normalizers via `require`",
|
34
|
+
"use `Skylight.enable_normalizer('#{key}')` instead")
|
35
|
+
end
|
36
|
+
|
19
37
|
unless klass.method_defined?(:normalize)
|
20
38
|
# TODO: Warn
|
21
39
|
next
|
22
40
|
end
|
23
41
|
|
24
|
-
normalizers[
|
42
|
+
normalizers[key] = klass.new(config)
|
25
43
|
end
|
26
44
|
|
27
45
|
Container.new(normalizers)
|
28
46
|
end
|
29
47
|
|
30
48
|
class Normalizer
|
31
|
-
def self.register(name)
|
32
|
-
Normalizers.register(name, self)
|
49
|
+
def self.register(name, opts={})
|
50
|
+
Normalizers.register(name, self, opts)
|
33
51
|
end
|
34
52
|
|
35
53
|
attr_reader :config
|
@@ -47,6 +65,7 @@ module Skylight
|
|
47
65
|
end
|
48
66
|
end
|
49
67
|
|
68
|
+
# FIXME: Move this elsewhere
|
50
69
|
# Base Normalizer for Rails rendering
|
51
70
|
class RenderNormalizer < Normalizer
|
52
71
|
include Util::AllocationFree
|
data/lib/skylight/probes.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Skylight
|
2
4
|
# @api private
|
3
5
|
module Probes
|
4
6
|
class ProbeRegistration
|
5
|
-
attr_reader :klass_name, :require_paths, :probe
|
7
|
+
attr_reader :name, :klass_name, :require_paths, :probe
|
6
8
|
|
7
|
-
def initialize(klass_name, require_paths, probe)
|
9
|
+
def initialize(name, klass_name, require_paths, probe)
|
10
|
+
@name = name
|
8
11
|
@klass_name = klass_name
|
9
12
|
@require_paths = Array(require_paths)
|
10
13
|
@probe = probe
|
@@ -15,6 +18,34 @@ module Skylight
|
|
15
18
|
end
|
16
19
|
end
|
17
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
|
+
|
18
49
|
def self.require_hooks
|
19
50
|
@require_hooks ||= {}
|
20
51
|
end
|
@@ -27,8 +58,13 @@ module Skylight
|
|
27
58
|
!!Skylight::Util::Inflector.safe_constantize(klass_name)
|
28
59
|
end
|
29
60
|
|
30
|
-
def self.register(*args)
|
31
|
-
|
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)
|
32
68
|
|
33
69
|
if is_available?(registration.klass_name)
|
34
70
|
installed[registration.klass_name] = registration
|
@@ -59,6 +59,6 @@ module Skylight
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
register("ActionController::Instrumentation", "action_controller/metal/instrumentation", ActionController::Probe.new)
|
62
|
+
register(:action_controller, "ActionController::Instrumentation", "action_controller/metal/instrumentation", ActionController::Probe.new)
|
63
63
|
end
|
64
64
|
end
|
@@ -50,6 +50,6 @@ module Skylight
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
register("ActiveModel::Serializer", "active_model/serializer", ActiveModelSerializers::Probe.new)
|
53
|
+
register(:active_model_serializers, "ActiveModel::Serializer", "active_model/serializer", ActiveModelSerializers::Probe.new)
|
54
54
|
end
|
55
55
|
end
|
@@ -5,11 +5,13 @@ module Skylight
|
|
5
5
|
def install
|
6
6
|
version = Gem::Version.new(::Grape::VERSION)
|
7
7
|
|
8
|
-
if version
|
8
|
+
if version >= Gem::Version.new("0.13.0")
|
9
9
|
# AS::N is built in to newer versions
|
10
10
|
return
|
11
11
|
end
|
12
12
|
|
13
|
+
Skylight::DEPRECATOR.deprecation_warning("Support for Grape versions before 0.13.0")
|
14
|
+
|
13
15
|
if version < Gem::Version.new("0.10.0")
|
14
16
|
# Using $stderr here isn't great, but we don't have a logger accessible
|
15
17
|
$stderr.puts "[SKYLIGHT] [#{Skylight::VERSION}] The Grape probe only works with version 0.10.0+ " \
|
@@ -81,6 +83,6 @@ module Skylight
|
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
|
-
register("Grape::Endpoint", "grape/endpoint", Grape::Probe.new)
|
86
|
+
register(:grape, "Grape::Endpoint", "grape/endpoint", Grape::Probe.new)
|
85
87
|
end
|
86
88
|
end
|
@@ -74,6 +74,6 @@ module Skylight
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
register("ActionDispatch::MiddlewareStack::Middleware", "actionpack/action_dispatch", Middleware::Probe.new)
|
77
|
+
register(:middleware, "ActionDispatch::MiddlewareStack::Middleware", "actionpack/action_dispatch", Middleware::Probe.new)
|
78
78
|
end
|
79
79
|
end
|
@@ -8,14 +8,14 @@ module Skylight
|
|
8
8
|
version = Gem::Version.new(::Mongoid::VERSION)
|
9
9
|
|
10
10
|
if version < Gem::Version.new("5.0")
|
11
|
-
|
11
|
+
Skylight.probe(:moped)
|
12
12
|
else
|
13
|
-
|
13
|
+
Skylight.probe(:mongo)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
register("Mongoid", "mongoid", Mongoid::Probe.new)
|
19
|
+
register(:mongoid, "Mongoid", "mongoid", Mongoid::Probe.new)
|
20
20
|
end
|
21
21
|
end
|
@@ -4,6 +4,10 @@ module Skylight
|
|
4
4
|
module Sequel
|
5
5
|
class Probe
|
6
6
|
def install
|
7
|
+
if Gem::Version.new(::Sequel.version) < Gem::Version.new('4.0')
|
8
|
+
Skylight::DEPRECATOR.deprecation_warning("Support for Sequel versions before 4.0")
|
9
|
+
end
|
10
|
+
|
7
11
|
require 'sequel/database/logging'
|
8
12
|
|
9
13
|
method_name = ::Sequel::Database.method_defined?(:log_connection_yield) ? 'log_connection_yield' : 'log_yield'
|
@@ -28,6 +32,6 @@ module Skylight
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
|
-
register("Sequel", "sequel", Sequel::Probe.new)
|
35
|
+
register(:sequel, "Sequel", "sequel", Sequel::Probe.new)
|
32
36
|
end
|
33
37
|
end
|
data/lib/skylight/probes/tilt.rb
CHANGED
@@ -4,6 +4,10 @@ module Skylight
|
|
4
4
|
module Tilt
|
5
5
|
class Probe
|
6
6
|
def install
|
7
|
+
if Gem::Version.new(::Tilt::VERSION) < Gem::Version.new('1.4.1')
|
8
|
+
Skylight::DEPRECATOR.deprecation_warning("Support for Tilt versions before 1.4.1")
|
9
|
+
end
|
10
|
+
|
7
11
|
::Tilt::Template.class_eval do
|
8
12
|
alias render_without_sk render
|
9
13
|
|
@@ -22,6 +26,6 @@ module Skylight
|
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
|
-
register("Tilt::Template", "tilt/template", Tilt::Probe.new)
|
29
|
+
register(:tilt, "Tilt::Template", "tilt/template", Tilt::Probe.new)
|
26
30
|
end
|
27
31
|
end
|
data/lib/skylight/railtie.rb
CHANGED
data/lib/skylight/sinatra.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'skylight'
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
if Gem::Version(Sinatra::VERSION) < Gem::Version('1.4')
|
4
|
+
Skylight::DEPRECATOR.deprecation_warning("Support for Sinatra versions before 1.4")
|
5
|
+
end
|
6
|
+
|
7
|
+
Skylight.probe(:sinatra, :tilt, :sequel)
|
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: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/skylight/config.rb
|
68
68
|
- lib/skylight/core.rb
|
69
69
|
- lib/skylight/data/cacert.pem
|
70
|
+
- lib/skylight/deprecation.rb
|
70
71
|
- lib/skylight/formatters/http.rb
|
71
72
|
- lib/skylight/gc.rb
|
72
73
|
- lib/skylight/helpers.rb
|