skylight-core 2.0.0.beta3 → 2.0.0
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/core.rb +1 -0
- data/lib/skylight/core/config.rb +2 -0
- data/lib/skylight/core/deprecation.rb +15 -0
- data/lib/skylight/core/instrumentable.rb +8 -0
- data/lib/skylight/core/instrumenter.rb +20 -12
- data/lib/skylight/core/middleware.rb +46 -14
- data/lib/skylight/core/normalizers.rb +34 -86
- data/lib/skylight/core/normalizers/action_view/render_collection.rb +2 -0
- data/lib/skylight/core/normalizers/action_view/render_partial.rb +2 -0
- data/lib/skylight/core/normalizers/action_view/render_template.rb +2 -0
- data/lib/skylight/core/normalizers/render.rb +77 -0
- data/lib/skylight/core/probes.rb +73 -73
- data/lib/skylight/core/probes/action_controller.rb +1 -1
- data/lib/skylight/core/probes/action_dispatch.rb +1 -0
- data/lib/skylight/core/probes/action_dispatch/request_id.rb +31 -0
- data/lib/skylight/core/probes/action_view.rb +1 -1
- data/lib/skylight/core/probes/active_model_serializers.rb +1 -1
- data/lib/skylight/core/probes/elasticsearch.rb +1 -1
- data/lib/skylight/core/probes/excon.rb +1 -1
- data/lib/skylight/core/probes/faraday.rb +1 -1
- data/lib/skylight/core/probes/httpclient.rb +1 -1
- data/lib/skylight/core/probes/middleware.rb +19 -3
- data/lib/skylight/core/probes/mongo.rb +1 -1
- data/lib/skylight/core/probes/mongoid.rb +3 -3
- data/lib/skylight/core/probes/moped.rb +1 -1
- data/lib/skylight/core/probes/net_http.rb +1 -1
- data/lib/skylight/core/probes/redis.rb +1 -1
- data/lib/skylight/core/probes/sequel.rb +1 -1
- data/lib/skylight/core/probes/sinatra.rb +1 -1
- data/lib/skylight/core/probes/tilt.rb +1 -1
- data/lib/skylight/core/test.rb +95 -82
- data/lib/skylight/core/trace.rb +48 -19
- data/lib/skylight/core/user_config.rb +1 -0
- data/lib/skylight/core/util.rb +0 -1
- data/lib/skylight/core/util/logging.rb +12 -4
- data/lib/skylight/core/version.rb +1 -1
- metadata +9 -8
- data/lib/skylight/core/normalizers/couch_potato/query.rb +0 -20
- data/lib/skylight/core/probes/grape.rb +0 -80
- data/lib/skylight/core/util/deploy.rb +0 -132
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skylight-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.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-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -145,6 +145,7 @@ extra_rdoc_files: []
|
|
145
145
|
files:
|
146
146
|
- lib/skylight/core.rb
|
147
147
|
- lib/skylight/core/config.rb
|
148
|
+
- lib/skylight/core/deprecation.rb
|
148
149
|
- lib/skylight/core/errors.rb
|
149
150
|
- lib/skylight/core/fanout.rb
|
150
151
|
- lib/skylight/core/formatters/http.rb
|
@@ -175,7 +176,6 @@ files:
|
|
175
176
|
- lib/skylight/core/normalizers/active_support/cache_write.rb
|
176
177
|
- lib/skylight/core/normalizers/coach/handler_finish.rb
|
177
178
|
- lib/skylight/core/normalizers/coach/middleware_finish.rb
|
178
|
-
- lib/skylight/core/normalizers/couch_potato/query.rb
|
179
179
|
- lib/skylight/core/normalizers/data_mapper/sql.rb
|
180
180
|
- lib/skylight/core/normalizers/default.rb
|
181
181
|
- lib/skylight/core/normalizers/elasticsearch/request.rb
|
@@ -185,17 +185,19 @@ files:
|
|
185
185
|
- lib/skylight/core/normalizers/grape/endpoint_run.rb
|
186
186
|
- lib/skylight/core/normalizers/grape/endpoint_run_filters.rb
|
187
187
|
- lib/skylight/core/normalizers/moped/query.rb
|
188
|
+
- lib/skylight/core/normalizers/render.rb
|
188
189
|
- lib/skylight/core/normalizers/sequel/sql.rb
|
189
190
|
- lib/skylight/core/normalizers/sql.rb
|
190
191
|
- lib/skylight/core/probes.rb
|
191
192
|
- lib/skylight/core/probes/action_controller.rb
|
193
|
+
- lib/skylight/core/probes/action_dispatch.rb
|
194
|
+
- lib/skylight/core/probes/action_dispatch/request_id.rb
|
192
195
|
- lib/skylight/core/probes/action_view.rb
|
193
196
|
- lib/skylight/core/probes/active_model_serializers.rb
|
194
197
|
- lib/skylight/core/probes/elasticsearch.rb
|
195
198
|
- lib/skylight/core/probes/excon.rb
|
196
199
|
- lib/skylight/core/probes/excon/middleware.rb
|
197
200
|
- lib/skylight/core/probes/faraday.rb
|
198
|
-
- lib/skylight/core/probes/grape.rb
|
199
201
|
- lib/skylight/core/probes/httpclient.rb
|
200
202
|
- lib/skylight/core/probes/middleware.rb
|
201
203
|
- lib/skylight/core/probes/mongo.rb
|
@@ -214,7 +216,6 @@ files:
|
|
214
216
|
- lib/skylight/core/util.rb
|
215
217
|
- lib/skylight/core/util/allocation_free.rb
|
216
218
|
- lib/skylight/core/util/clock.rb
|
217
|
-
- lib/skylight/core/util/deploy.rb
|
218
219
|
- lib/skylight/core/util/gzip.rb
|
219
220
|
- lib/skylight/core/util/inflector.rb
|
220
221
|
- lib/skylight/core/util/logging.rb
|
@@ -242,12 +243,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
243
|
version: 2.2.7
|
243
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
245
|
requirements:
|
245
|
-
- - "
|
246
|
+
- - ">="
|
246
247
|
- !ruby/object:Gem::Version
|
247
|
-
version:
|
248
|
+
version: '0'
|
248
249
|
requirements: []
|
249
250
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.7.
|
251
|
+
rubygems_version: 2.7.6
|
251
252
|
signing_key:
|
252
253
|
specification_version: 4
|
253
254
|
summary: The core methods of the Skylight profiler.
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
module Skylight::Core
|
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,80 +0,0 @@
|
|
1
|
-
module Skylight::Core
|
2
|
-
module Probes
|
3
|
-
module Grape
|
4
|
-
class Probe
|
5
|
-
def install
|
6
|
-
version = Gem::Version.new(::Grape::VERSION)
|
7
|
-
|
8
|
-
if version > Gem::Version.new("0.12.1")
|
9
|
-
# AS::N is built in to newer versions
|
10
|
-
return
|
11
|
-
end
|
12
|
-
|
13
|
-
if version < Gem::Version.new("0.10.0")
|
14
|
-
# Using $stderr here isn't great, but we don't have a logger accessible
|
15
|
-
$stderr.puts "[SKYLIGHT::CORE] [#{Skylight::Core::VERSION}] The Grape probe only works with version 0.10.0+ " \
|
16
|
-
"and will be disabled."
|
17
|
-
|
18
|
-
return
|
19
|
-
end
|
20
|
-
|
21
|
-
::Grape::Endpoint.class_eval do
|
22
|
-
alias initialize_without_sk initialize
|
23
|
-
def initialize(*args, &block)
|
24
|
-
initialize_without_sk(*args, &block)
|
25
|
-
|
26
|
-
# This solution of wrapping the block is effective, but potentially fragile.
|
27
|
-
# A cleaner solution would be to call the original initialize with the already
|
28
|
-
# modified block. However, Grape does some odd stuff with the block binding
|
29
|
-
# that makes this difficult to reason about.
|
30
|
-
if original_block = @block
|
31
|
-
@block = lambda do |endpoint_instance|
|
32
|
-
ActiveSupport::Notifications.instrument('endpoint_render.grape', endpoint: endpoint_instance) do
|
33
|
-
original_block.call(endpoint_instance)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
alias run_without_sk run
|
40
|
-
def run(*args)
|
41
|
-
ActiveSupport::Notifications.instrument('endpoint_run.grape', endpoint: self) do
|
42
|
-
run_without_sk(*args)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
alias run_filters_without_sk run_filters
|
47
|
-
def run_filters(filters)
|
48
|
-
# Unfortunately, the type isn't provided to the method so we have
|
49
|
-
# to try to guess it by looking at the contents. This is only reliable
|
50
|
-
# if the filters aren't empty.
|
51
|
-
if filters && !filters.empty?
|
52
|
-
type = case filters
|
53
|
-
when befores then :before
|
54
|
-
when before_validations then :before_validation
|
55
|
-
when after_validations then :after_validation
|
56
|
-
when afters then :after
|
57
|
-
else :other
|
58
|
-
end
|
59
|
-
else
|
60
|
-
type = :unknown
|
61
|
-
end
|
62
|
-
|
63
|
-
payload = {
|
64
|
-
endpoint: self,
|
65
|
-
filters: filters,
|
66
|
-
type: type
|
67
|
-
}
|
68
|
-
|
69
|
-
ActiveSupport::Notifications.instrument('endpoint_run_filters.grape', payload) do
|
70
|
-
run_filters_without_sk(filters)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
register("Grape::Endpoint", "grape/endpoint", Grape::Probe.new)
|
79
|
-
end
|
80
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'uri'
|
3
|
-
require 'skylight/core/util/logging'
|
4
|
-
|
5
|
-
module Skylight::Core
|
6
|
-
module Util
|
7
|
-
|
8
|
-
module Deploy
|
9
|
-
|
10
|
-
def self.build(config)
|
11
|
-
DEPLOY_TYPES.each do |type|
|
12
|
-
deploy = type.new(config)
|
13
|
-
return deploy if deploy.id
|
14
|
-
end
|
15
|
-
nil
|
16
|
-
end
|
17
|
-
|
18
|
-
class EmptyDeploy
|
19
|
-
|
20
|
-
attr_reader :config
|
21
|
-
attr_reader :timestamp
|
22
|
-
|
23
|
-
def initialize(config)
|
24
|
-
@config = config
|
25
|
-
@timestamp = Time.now.to_i
|
26
|
-
end
|
27
|
-
|
28
|
-
def id
|
29
|
-
git_sha
|
30
|
-
end
|
31
|
-
|
32
|
-
def git_sha
|
33
|
-
nil
|
34
|
-
end
|
35
|
-
|
36
|
-
def description
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
|
40
|
-
def to_query_string
|
41
|
-
URI.encode_www_form(
|
42
|
-
timestamp: timestamp,
|
43
|
-
deploy_id: id.to_s[0..100], # Keep this sane
|
44
|
-
git_sha: git_sha ? git_sha[0..40] : nil, # A valid SHA will never exceed 40
|
45
|
-
description: description ? description[0..255] : nil) # Avoid massive descriptions
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
class DefaultDeploy < EmptyDeploy
|
51
|
-
include Logging
|
52
|
-
|
53
|
-
def initialize(*)
|
54
|
-
super
|
55
|
-
if description && !id
|
56
|
-
warn "The configured deploy will be ignored as an id or git_sha must be provided."
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def id
|
61
|
-
config.get(:'deploy.id') || git_sha
|
62
|
-
end
|
63
|
-
|
64
|
-
def git_sha
|
65
|
-
config.get(:'deploy.git_sha')
|
66
|
-
end
|
67
|
-
|
68
|
-
def description
|
69
|
-
config.get(:'deploy.description')
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
class HerokuDeploy < EmptyDeploy
|
75
|
-
|
76
|
-
def initialize(*)
|
77
|
-
super
|
78
|
-
@info = get_info
|
79
|
-
end
|
80
|
-
|
81
|
-
def id
|
82
|
-
@info ? @info['id'] : nil
|
83
|
-
end
|
84
|
-
|
85
|
-
def git_sha
|
86
|
-
@info ? @info['commit'] : nil
|
87
|
-
end
|
88
|
-
|
89
|
-
def description
|
90
|
-
@info ? @info['description'] : nil
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def get_info
|
96
|
-
info_path = config[:'heroku.dyno_info_path']
|
97
|
-
|
98
|
-
if File.exist?(info_path)
|
99
|
-
if info = JSON.parse(File.read(info_path))
|
100
|
-
info['release']
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
class GitDeploy < EmptyDeploy
|
108
|
-
|
109
|
-
attr_reader :git_sha, :description
|
110
|
-
|
111
|
-
def initialize(*)
|
112
|
-
super
|
113
|
-
@git_sha, @description = get_info
|
114
|
-
end
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
def get_info
|
119
|
-
Dir.chdir(config.root) do
|
120
|
-
info = `git log -1 --pretty="%H %s" 2>&1`
|
121
|
-
info.split(" ", 2).map(&:strip) if $?.success?
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
DEPLOY_TYPES = [DefaultDeploy, HerokuDeploy, GitDeploy]
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|