skylight 5.0.0.beta4 → 5.1.0.beta2
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 +399 -362
- data/CLA.md +1 -1
- data/CONTRIBUTING.md +1 -1
- data/LICENSE.md +7 -17
- data/README.md +1 -1
- data/ext/extconf.rb +42 -54
- data/ext/libskylight.yml +10 -5
- data/lib/skylight.rb +20 -30
- data/lib/skylight/api.rb +22 -18
- data/lib/skylight/cli.rb +47 -46
- data/lib/skylight/cli/doctor.rb +50 -50
- data/lib/skylight/cli/helpers.rb +19 -19
- data/lib/skylight/cli/merger.rb +141 -139
- data/lib/skylight/config.rb +267 -310
- data/lib/skylight/deprecation.rb +4 -4
- data/lib/skylight/errors.rb +3 -4
- data/lib/skylight/extensions.rb +17 -29
- data/lib/skylight/extensions/source_location.rb +128 -128
- data/lib/skylight/formatters/http.rb +1 -3
- data/lib/skylight/gc.rb +30 -40
- data/lib/skylight/helpers.rb +57 -30
- data/lib/skylight/instrumenter.rb +25 -18
- data/lib/skylight/middleware.rb +31 -35
- data/lib/skylight/native.rb +8 -10
- data/lib/skylight/native_ext_fetcher.rb +10 -12
- data/lib/skylight/normalizers.rb +43 -38
- data/lib/skylight/normalizers/action_controller/process_action.rb +24 -25
- data/lib/skylight/normalizers/action_controller/send_file.rb +7 -6
- data/lib/skylight/normalizers/action_dispatch/route_set.rb +7 -7
- data/lib/skylight/normalizers/active_job/perform.rb +48 -44
- data/lib/skylight/normalizers/active_model_serializers/render.rb +7 -3
- data/lib/skylight/normalizers/active_storage.rb +11 -13
- data/lib/skylight/normalizers/active_support/cache.rb +1 -12
- data/lib/skylight/normalizers/coach/handler_finish.rb +1 -3
- data/lib/skylight/normalizers/default.rb +1 -9
- data/lib/skylight/normalizers/faraday/request.rb +1 -3
- data/lib/skylight/normalizers/grape/endpoint.rb +13 -19
- data/lib/skylight/normalizers/grape/endpoint_run.rb +16 -18
- data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +1 -3
- data/lib/skylight/normalizers/graphql/base.rb +23 -28
- data/lib/skylight/normalizers/render.rb +19 -21
- data/lib/skylight/normalizers/shrine.rb +32 -0
- data/lib/skylight/normalizers/sql.rb +4 -4
- data/lib/skylight/probes.rb +38 -46
- data/lib/skylight/probes/action_controller.rb +32 -28
- data/lib/skylight/probes/action_dispatch/request_id.rb +9 -5
- data/lib/skylight/probes/action_dispatch/routing/route_set.rb +7 -5
- data/lib/skylight/probes/action_view.rb +9 -10
- data/lib/skylight/probes/active_job_enqueue.rb +3 -9
- data/lib/skylight/probes/active_model_serializers.rb +8 -8
- data/lib/skylight/probes/delayed_job.rb +37 -42
- data/lib/skylight/probes/elasticsearch.rb +4 -6
- data/lib/skylight/probes/excon.rb +1 -1
- data/lib/skylight/probes/excon/middleware.rb +22 -23
- data/lib/skylight/probes/graphql.rb +2 -7
- data/lib/skylight/probes/middleware.rb +14 -5
- data/lib/skylight/probes/mongo.rb +83 -91
- data/lib/skylight/probes/net_http.rb +1 -1
- data/lib/skylight/probes/redis.rb +5 -17
- data/lib/skylight/probes/sequel.rb +7 -11
- data/lib/skylight/probes/sinatra.rb +8 -5
- data/lib/skylight/probes/tilt.rb +2 -4
- data/lib/skylight/railtie.rb +121 -135
- data/lib/skylight/sidekiq.rb +4 -5
- data/lib/skylight/subscriber.rb +31 -33
- data/lib/skylight/test.rb +89 -84
- data/lib/skylight/trace.rb +121 -115
- data/lib/skylight/user_config.rb +14 -17
- data/lib/skylight/util/clock.rb +1 -0
- data/lib/skylight/util/component.rb +18 -21
- data/lib/skylight/util/deploy.rb +11 -13
- data/lib/skylight/util/http.rb +104 -105
- data/lib/skylight/util/logging.rb +4 -6
- data/lib/skylight/util/lru_cache.rb +2 -6
- data/lib/skylight/util/platform.rb +2 -6
- data/lib/skylight/util/ssl.rb +1 -25
- data/lib/skylight/version.rb +1 -1
- data/lib/skylight/vm/gc.rb +1 -9
- metadata +20 -5
@@ -17,7 +17,8 @@ module Skylight
|
|
17
17
|
|
18
18
|
include FileUtils
|
19
19
|
|
20
|
-
class FetchError < StandardError
|
20
|
+
class FetchError < StandardError
|
21
|
+
end
|
21
22
|
|
22
23
|
# Creates a new fetcher and fetches
|
23
24
|
# @param opts [Hash]
|
@@ -56,7 +57,7 @@ module Skylight
|
|
56
57
|
# @return [String] the inflated archive
|
57
58
|
def fetch
|
58
59
|
log "fetching native ext; curr-platform=#{@platform}; " \
|
59
|
-
|
60
|
+
"requested-arch=#{@arch}; version=#{@version}"
|
60
61
|
|
61
62
|
tar_gz = "#{@target}/#{basename}"
|
62
63
|
|
@@ -109,11 +110,12 @@ module Skylight
|
|
109
110
|
next
|
110
111
|
end
|
111
112
|
end
|
112
|
-
rescue => e
|
113
|
+
rescue StandardError => e
|
113
114
|
remaining_attempts -= 1
|
114
115
|
|
115
116
|
error "failed to fetch native extension; uri=#{uri}; msg=#{e.message}; " \
|
116
|
-
|
117
|
+
"remaining-attempts=#{remaining_attempts}",
|
118
|
+
e
|
117
119
|
|
118
120
|
if remaining_attempts > 0
|
119
121
|
sleep 2
|
@@ -149,9 +151,7 @@ module Skylight
|
|
149
151
|
opts = {}
|
150
152
|
opts[:use_ssl] = use_ssl
|
151
153
|
|
152
|
-
if use_ssl
|
153
|
-
opts[:ca_file] = Util::SSL.ca_cert_file_or_default
|
154
|
-
end
|
154
|
+
opts[:ca_file] = Util::SSL.ca_cert_file_or_default if use_ssl
|
155
155
|
|
156
156
|
Net::HTTP.start(host, port, p_host, p_port, p_user, p_pass, use_ssl: use_ssl) do |http|
|
157
157
|
http.request_get path do |resp|
|
@@ -164,13 +164,13 @@ module Skylight
|
|
164
164
|
out.write chunk
|
165
165
|
end
|
166
166
|
|
167
|
-
return
|
167
|
+
return :success, digest.hexdigest
|
168
168
|
when Net::HTTPRedirection
|
169
169
|
unless (location = resp["location"])
|
170
170
|
raise "received redirect but no location"
|
171
171
|
end
|
172
172
|
|
173
|
-
return
|
173
|
+
return :redirect, location
|
174
174
|
else
|
175
175
|
raise "received HTTP status code #{resp.code}"
|
176
176
|
end
|
@@ -221,9 +221,7 @@ module Skylight
|
|
221
221
|
def maybe_raise(err)
|
222
222
|
error err
|
223
223
|
|
224
|
-
if @required
|
225
|
-
raise err
|
226
|
-
end
|
224
|
+
raise err if @required
|
227
225
|
end
|
228
226
|
|
229
227
|
# Log an `info` to the `logger`
|
data/lib/skylight/normalizers.rb
CHANGED
@@ -79,18 +79,18 @@ module Skylight
|
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
def process_meta(trace, _name, payload, meta, cache_key: nil)
|
83
|
+
trace.instrumenter.extensions.process_normalizer_meta(
|
84
|
+
payload,
|
85
|
+
meta,
|
86
|
+
cache_key: cache_key,
|
87
|
+
**process_meta_options(payload)
|
88
|
+
)
|
89
|
+
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
def process_meta_options(_payload)
|
92
|
+
{}
|
93
|
+
end
|
94
94
|
end
|
95
95
|
|
96
96
|
require "skylight/normalizers/default"
|
@@ -105,6 +105,10 @@ module Skylight
|
|
105
105
|
@normalizers.keys
|
106
106
|
end
|
107
107
|
|
108
|
+
def each_key(&block)
|
109
|
+
@normalizers.each_key(&block)
|
110
|
+
end
|
111
|
+
|
108
112
|
def normalize(trace, name, payload)
|
109
113
|
normalizer_for(name).normalize_with_meta(trace, name, payload)
|
110
114
|
end
|
@@ -121,32 +125,33 @@ module Skylight
|
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
124
|
-
%w[
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
128
|
+
%w[
|
129
|
+
action_controller/process_action
|
130
|
+
action_controller/send_file
|
131
|
+
action_dispatch/process_middleware
|
132
|
+
action_dispatch/route_set
|
133
|
+
action_view/render_collection
|
134
|
+
action_view/render_partial
|
135
|
+
action_view/render_template
|
136
|
+
action_view/render_layout
|
137
|
+
active_job/perform
|
138
|
+
active_model_serializers/render
|
139
|
+
active_record/instantiation
|
140
|
+
active_record/sql
|
141
|
+
active_storage
|
142
|
+
active_support/cache
|
143
|
+
coach/handler_finish
|
144
|
+
coach/middleware_finish
|
145
|
+
couch_potato/query
|
146
|
+
data_mapper/sql
|
147
|
+
elasticsearch/request
|
148
|
+
faraday/request
|
149
|
+
grape/endpoint
|
150
|
+
graphiti/resolve
|
151
|
+
graphiti/render
|
152
|
+
graphql/base
|
153
|
+
sequel/sql
|
154
|
+
shrine
|
155
|
+
].each { |file| require "skylight/normalizers/#{file}" }
|
151
156
|
end
|
152
157
|
end
|
@@ -32,37 +32,36 @@ module Skylight
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def controller_action(payload)
|
36
|
+
"#{payload[:controller]}##{payload[:action]}"
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
def process_meta_options(payload)
|
40
|
+
# provide hints to override default source_location behavior
|
41
|
+
super.merge(source_location_hint: [:instance_method, payload[:controller], payload[:action]])
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def segment_from_payload(payload)
|
45
|
+
# Show 'error' if there's an unhandled exception or if the status is 4xx or 5xx
|
46
|
+
return "error" if payload[:exception] || payload[:exception_object]
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
[payload[:sk_rendered_format], payload[:sk_variant]].compact.flatten.join("+")
|
53
|
-
end
|
48
|
+
segment_from_status(payload[:status]) || if payload[:sk_rendered_format]
|
49
|
+
# We only show the variant if we actually have a format
|
50
|
+
# We won't have a sk_rendered_format if it's a `head` outside of a `respond_to` block.
|
51
|
+
[payload[:sk_rendered_format], payload[:sk_variant]].compact.flatten.join("+")
|
54
52
|
end
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
55
|
+
def segment_from_status(status)
|
56
|
+
case status
|
57
|
+
when 304
|
58
|
+
"not modified"
|
59
|
+
when (300..399)
|
60
|
+
"redirect"
|
61
|
+
when (400..599)
|
62
|
+
"error"
|
65
63
|
end
|
64
|
+
end
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
@@ -32,17 +32,18 @@ module Skylight
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
OCTET_STREAM = "application/octet-stream".freeze
|
36
|
+
ATTACHMENT = "attachment".freeze
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
def initialize(*)
|
39
|
+
super
|
40
40
|
|
41
|
-
|
41
|
+
@mimes =
|
42
|
+
Mime::SET.each_with_object({}) do |mime, hash|
|
42
43
|
hash[mime.symbol] = mime.to_s.dup.freeze
|
43
44
|
hash
|
44
45
|
end
|
45
|
-
|
46
|
+
end
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -13,14 +13,14 @@ module Skylight
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def router_class_name
|
17
|
+
"ActionDispatch::Routing::RouteSet"
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def process_meta_options(_payload)
|
21
|
+
# provide hints to override default source_location behavior
|
22
|
+
super.merge(source_location_hint: [:own_instance_method, router_class_name, "call"])
|
23
|
+
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -8,12 +8,16 @@ module Skylight
|
|
8
8
|
DELAYED_JOB_WRAPPER = "ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper".freeze
|
9
9
|
|
10
10
|
def self.normalize_title(job_instance)
|
11
|
-
job_instance
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
job_instance
|
12
|
+
.class
|
13
|
+
.name
|
14
|
+
.to_s
|
15
|
+
.tap do |str|
|
16
|
+
if str.match(DELIVERY_JOB)
|
17
|
+
mailer_class, mailer_method, * = job_instance.arguments
|
18
|
+
return "#{mailer_class}##{mailer_method}", str
|
19
|
+
end
|
15
20
|
end
|
16
|
-
end
|
17
21
|
end
|
18
22
|
|
19
23
|
CAT = "app.job.perform".freeze
|
@@ -36,50 +40,50 @@ module Skylight
|
|
36
40
|
|
37
41
|
private
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def normalize_adapter_name(adapter)
|
45
|
-
adapter_string = adapter.is_a?(Class) ? adapter.to_s : adapter.class.to_s
|
46
|
-
adapter_string[/ActiveJob::QueueAdapters::(\w+)Adapter/, 1].underscore
|
47
|
-
rescue
|
48
|
-
"active_job"
|
49
|
-
end
|
43
|
+
def process_meta_options(payload)
|
44
|
+
# provide hints to override default source_location behavior
|
45
|
+
super.merge(source_location_hint: [:instance_method, payload[:job].class.to_s, "perform"])
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
def normalize_adapter_name(adapter)
|
49
|
+
adapter_string = adapter.is_a?(Class) ? adapter.to_s : adapter.class.to_s
|
50
|
+
adapter_string[/ActiveJob::QueueAdapters::(\w+)Adapter/, 1].underscore
|
51
|
+
rescue StandardError
|
52
|
+
"active_job"
|
53
|
+
end
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
return true if defined?(Skylight::Probes::ActiveJob::TITLE) &&
|
61
|
-
trace.endpoint == Skylight::Probes::ActiveJob::TITLE
|
62
|
-
return true if defined?(SKylight::Probes::DelayedJob::Probe::UNKNOWN) &&
|
63
|
-
trace.endpoint == Skylight::Probes::DelayedJob::Probe::UNKNOWN
|
55
|
+
def maybe_set_endpoint(trace, payload)
|
56
|
+
trace.endpoint = normalize_title(payload[:job]) if assign_endpoint?(trace, payload)
|
57
|
+
end
|
64
58
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
# segment to be assigned by normalize_after.
|
71
|
-
trace.endpoint == DELIVERY_JOB ||
|
72
|
-
trace.endpoint == normalize_title(payload[:job]) ||
|
73
|
-
# This adapter wrapper needs to be handled specifically due to interactions with the
|
74
|
-
# standalone Delayed::Job probe, as there is no consistent way to get the wrapped
|
75
|
-
# job name among all Delayed::Job backends.
|
76
|
-
trace.endpoint == DELAYED_JOB_WRAPPER
|
59
|
+
def assign_endpoint?(trace, payload)
|
60
|
+
# Always assign the endpoint if it has not yet been assigned by the ActiveJob probe.
|
61
|
+
return true unless trace.endpoint
|
62
|
+
if defined?(Skylight::Probes::ActiveJob::TITLE) && trace.endpoint == Skylight::Probes::ActiveJob::TITLE
|
63
|
+
return true
|
77
64
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
title
|
65
|
+
if defined?(SKylight::Probes::DelayedJob::Probe::UNKNOWN) &&
|
66
|
+
trace.endpoint == Skylight::Probes::DelayedJob::Probe::UNKNOWN
|
67
|
+
return true
|
82
68
|
end
|
69
|
+
|
70
|
+
# If a job is called using #perform_now inside a controller action
|
71
|
+
# or within another job's #perform method, we do not want this to
|
72
|
+
# overwrite the existing endpoint name (unless it is the default from ActiveJob).
|
73
|
+
#
|
74
|
+
# If the current endpoint name matches this payload, return true to allow the
|
75
|
+
# segment to be assigned by normalize_after.
|
76
|
+
trace.endpoint == DELIVERY_JOB || trace.endpoint == normalize_title(payload[:job]) ||
|
77
|
+
# This adapter wrapper needs to be handled specifically due to interactions with the
|
78
|
+
# standalone Delayed::Job probe, as there is no consistent way to get the wrapped
|
79
|
+
# job name among all Delayed::Job backends.
|
80
|
+
trace.endpoint == DELAYED_JOB_WRAPPER
|
81
|
+
end
|
82
|
+
|
83
|
+
def normalize_title(job_instance)
|
84
|
+
title, * = self.class.normalize_title(job_instance)
|
85
|
+
title
|
86
|
+
end
|
83
87
|
end
|
84
88
|
end
|
85
89
|
end
|
@@ -14,9 +14,13 @@ module Skylight
|
|
14
14
|
title = title.sub(/^ActiveModel::(Serializer::)?/, "")
|
15
15
|
|
16
16
|
if (adapter_instance = payload[:adapter])
|
17
|
-
adapter_name =
|
18
|
-
|
19
|
-
|
17
|
+
adapter_name =
|
18
|
+
adapter_instance
|
19
|
+
.class
|
20
|
+
.name
|
21
|
+
.to_s
|
22
|
+
.sub(/^ActiveModel::Serializer::Adapter::/, "")
|
23
|
+
.sub(/^ActiveModelSerializers::Adapter::/, "")
|
20
24
|
desc = "Adapter: #{adapter_name}"
|
21
25
|
end
|
22
26
|
|
@@ -2,26 +2,24 @@ module Skylight
|
|
2
2
|
module Normalizers
|
3
3
|
class ActiveStorage < Normalizer
|
4
4
|
TITLES = {
|
5
|
-
"preview.active_storage"
|
6
|
-
"transform.active_storage"
|
7
|
-
"service_download.active_storage"
|
8
|
-
"service_upload.active_storage"
|
5
|
+
"preview.active_storage" => "Preview",
|
6
|
+
"transform.active_storage" => "Transform",
|
7
|
+
"service_download.active_storage" => "Download",
|
8
|
+
"service_upload.active_storage" => "Upload",
|
9
9
|
"service_streaming_download.active_storage" => "Streaming Download",
|
10
|
-
"service_download_chunk.active_storage"
|
11
|
-
"service_delete.active_storage"
|
12
|
-
"service_delete_prefixed.active_storage"
|
13
|
-
"service_exist.active_storage"
|
14
|
-
"service_url.active_storage"
|
10
|
+
"service_download_chunk.active_storage" => "Download Chunk",
|
11
|
+
"service_delete.active_storage" => "Delete",
|
12
|
+
"service_delete_prefixed.active_storage" => "Delete Prefixed",
|
13
|
+
"service_exist.active_storage" => "Exist",
|
14
|
+
"service_url.active_storage" => "Url"
|
15
15
|
}.freeze
|
16
16
|
|
17
|
-
TITLES.each_key
|
18
|
-
register key
|
19
|
-
end
|
17
|
+
TITLES.each_key { |key| register key }
|
20
18
|
|
21
19
|
def normalize(_trace, name, _payload)
|
22
20
|
title = ["ActiveStorage", TITLES[name]].join(" ")
|
23
21
|
|
24
|
-
cat = "app.#{name.split(
|
22
|
+
cat = "app.#{name.split(".").reverse.join(".")}"
|
25
23
|
|
26
24
|
[cat, title, nil]
|
27
25
|
end
|