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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/skylight/core/config.rb +103 -108
  3. data/lib/skylight/core/deprecation.rb +3 -3
  4. data/lib/skylight/core/fanout.rb +3 -3
  5. data/lib/skylight/core/formatters/http.rb +1 -2
  6. data/lib/skylight/core/gc.rb +31 -36
  7. data/lib/skylight/core/instrumentable.rb +17 -16
  8. data/lib/skylight/core/instrumenter.rb +25 -23
  9. data/lib/skylight/core/middleware.rb +11 -10
  10. data/lib/skylight/core/normalizers/action_controller/process_action.rb +9 -9
  11. data/lib/skylight/core/normalizers/action_controller/send_file.rb +16 -16
  12. data/lib/skylight/core/normalizers/action_view/render_collection.rb +2 -2
  13. data/lib/skylight/core/normalizers/action_view/render_partial.rb +2 -2
  14. data/lib/skylight/core/normalizers/action_view/render_template.rb +2 -2
  15. data/lib/skylight/core/normalizers/active_job/perform.rb +11 -23
  16. data/lib/skylight/core/normalizers/active_model_serializers/render.rb +6 -6
  17. data/lib/skylight/core/normalizers/active_record/instantiation.rb +2 -3
  18. data/lib/skylight/core/normalizers/active_record/sql.rb +1 -2
  19. data/lib/skylight/core/normalizers/active_support/cache.rb +12 -10
  20. data/lib/skylight/core/normalizers/active_support/cache_clear.rb +2 -2
  21. data/lib/skylight/core/normalizers/active_support/cache_decrement.rb +3 -3
  22. data/lib/skylight/core/normalizers/active_support/cache_delete.rb +3 -3
  23. data/lib/skylight/core/normalizers/active_support/cache_exist.rb +3 -3
  24. data/lib/skylight/core/normalizers/active_support/cache_fetch_hit.rb +3 -3
  25. data/lib/skylight/core/normalizers/active_support/cache_generate.rb +3 -3
  26. data/lib/skylight/core/normalizers/active_support/cache_increment.rb +3 -3
  27. data/lib/skylight/core/normalizers/active_support/cache_read.rb +3 -3
  28. data/lib/skylight/core/normalizers/active_support/cache_read_multi.rb +3 -3
  29. data/lib/skylight/core/normalizers/active_support/cache_write.rb +3 -3
  30. data/lib/skylight/core/normalizers/coach/handler_finish.rb +6 -6
  31. data/lib/skylight/core/normalizers/coach/middleware_finish.rb +2 -2
  32. data/lib/skylight/core/normalizers/couch_potato/query.rb +20 -0
  33. data/lib/skylight/core/normalizers/data_mapper/sql.rb +1 -1
  34. data/lib/skylight/core/normalizers/default.rb +1 -4
  35. data/lib/skylight/core/normalizers/elasticsearch/request.rb +5 -5
  36. data/lib/skylight/core/normalizers/grape/endpoint.rb +6 -5
  37. data/lib/skylight/core/normalizers/grape/endpoint_render.rb +3 -4
  38. data/lib/skylight/core/normalizers/grape/endpoint_run.rb +2 -3
  39. data/lib/skylight/core/normalizers/grape/endpoint_run_filters.rb +1 -2
  40. data/lib/skylight/core/normalizers/grape/format_response.rb +1 -2
  41. data/lib/skylight/core/normalizers/moped/query.rb +38 -43
  42. data/lib/skylight/core/normalizers/render.rb +26 -25
  43. data/lib/skylight/core/normalizers/sequel/sql.rb +1 -1
  44. data/lib/skylight/core/normalizers/sql.rb +5 -5
  45. data/lib/skylight/core/normalizers.rb +11 -12
  46. data/lib/skylight/core/probes/action_controller.rb +15 -14
  47. data/lib/skylight/core/probes/action_dispatch/request_id.rb +2 -3
  48. data/lib/skylight/core/probes/action_dispatch/routing/route_set.rb +2 -3
  49. data/lib/skylight/core/probes/action_dispatch.rb +2 -2
  50. data/lib/skylight/core/probes/action_view.rb +11 -17
  51. data/lib/skylight/core/probes/active_job.rb +8 -4
  52. data/lib/skylight/core/probes/active_job_enqueue.rb +2 -2
  53. data/lib/skylight/core/probes/active_model_serializers.rb +7 -6
  54. data/lib/skylight/core/probes/delayed_job.rb +46 -0
  55. data/lib/skylight/core/probes/elasticsearch.rb +3 -4
  56. data/lib/skylight/core/probes/excon/middleware.rb +4 -7
  57. data/lib/skylight/core/probes/excon.rb +2 -2
  58. data/lib/skylight/core/probes/faraday.rb +1 -2
  59. data/lib/skylight/core/probes/httpclient.rb +4 -4
  60. data/lib/skylight/core/probes/middleware.rb +1 -1
  61. data/lib/skylight/core/probes/mongo.rb +29 -34
  62. data/lib/skylight/core/probes/mongoid.rb +2 -3
  63. data/lib/skylight/core/probes/moped.rb +10 -11
  64. data/lib/skylight/core/probes/net_http.rb +5 -5
  65. data/lib/skylight/core/probes/redis.rb +3 -4
  66. data/lib/skylight/core/probes/sequel.rb +4 -4
  67. data/lib/skylight/core/probes/sinatra.rb +6 -11
  68. data/lib/skylight/core/probes/tilt.rb +1 -1
  69. data/lib/skylight/core/probes.rb +16 -17
  70. data/lib/skylight/core/railtie.rb +120 -119
  71. data/lib/skylight/core/sidekiq.rb +8 -4
  72. data/lib/skylight/core/subscriber.rb +25 -29
  73. data/lib/skylight/core/test.rb +13 -17
  74. data/lib/skylight/core/trace.rb +76 -76
  75. data/lib/skylight/core/user_config.rb +9 -11
  76. data/lib/skylight/core/util/allocation_free.rb +0 -1
  77. data/lib/skylight/core/util/clock.rb +16 -16
  78. data/lib/skylight/core/util/gzip.rb +1 -2
  79. data/lib/skylight/core/util/inflector.rb +5 -4
  80. data/lib/skylight/core/util/logging.rb +11 -14
  81. data/lib/skylight/core/util/platform.rb +52 -49
  82. data/lib/skylight/core/util/proxy.rb +3 -3
  83. data/lib/skylight/core/util.rb +5 -5
  84. data/lib/skylight/core/version.rb +1 -2
  85. data/lib/skylight/core/vm/gc.rb +1 -3
  86. data/lib/skylight/core.rb +21 -21
  87. metadata +47 -44
@@ -1,20 +1,21 @@
1
- require 'securerandom'
1
+ require "securerandom"
2
2
 
3
3
  module Skylight::Core
4
4
  class Trace
5
- GC_CAT = 'noise.gc'.freeze
5
+ GC_CAT = "noise.gc".freeze
6
6
 
7
7
  include Util::Logging
8
8
 
9
9
  attr_reader :instrumenter, :endpoint, :notifications, :meta
10
- attr_accessor :uuid
10
+ attr_accessor :uuid, :segment
11
11
 
12
- def self.new(instrumenter, endpoint, start, cat, title=nil, desc=nil, meta=nil)
12
+ def self.new(instrumenter, endpoint, start, cat, title = nil, desc = nil, meta = nil, segment: nil)
13
13
  uuid = SecureRandom.uuid
14
14
  inst = native_new(normalize_time(start), uuid, endpoint, meta)
15
15
  inst.uuid = uuid
16
16
  inst.send(:initialize, instrumenter, cat, title, desc, meta)
17
17
  inst.endpoint = endpoint
18
+ inst.segment = segment
18
19
  inst
19
20
  end
20
21
 
@@ -26,7 +27,7 @@ module Skylight::Core
26
27
  end
27
28
 
28
29
  def initialize(instrumenter, cat, title, desc, meta)
29
- raise ArgumentError, 'instrumenter is required' unless instrumenter
30
+ raise ArgumentError, "instrumenter is required" unless instrumenter
30
31
 
31
32
  @instrumenter = instrumenter
32
33
  @submitted = false
@@ -52,7 +53,6 @@ module Skylight::Core
52
53
  def endpoint=(value)
53
54
  @endpoint = value
54
55
  native_set_endpoint(value)
55
- value
56
56
  end
57
57
 
58
58
  def config
@@ -63,12 +63,12 @@ module Skylight::Core
63
63
  !!@broken
64
64
  end
65
65
 
66
- def maybe_broken(e)
67
- error "failed to instrument span; msg=%s; endpoint=%s", e.message, endpoint
66
+ def maybe_broken(err)
67
+ error "failed to instrument span; msg=%s; endpoint=%s", err.message, endpoint
68
68
  broken!
69
69
  end
70
70
 
71
- def record(cat, title=nil, desc=nil)
71
+ def record(cat, title = nil, desc = nil)
72
72
  return if broken?
73
73
 
74
74
  title.freeze if title.is_a?(String)
@@ -86,7 +86,7 @@ module Skylight::Core
86
86
  nil
87
87
  end
88
88
 
89
- def instrument(cat, title=nil, desc=nil, meta=nil)
89
+ def instrument(cat, title = nil, desc = nil, meta = nil)
90
90
  return if broken?
91
91
  t { "instrument: #{cat}, #{title}" }
92
92
 
@@ -115,7 +115,7 @@ module Skylight::Core
115
115
  native_span_get_correlation_header(span)
116
116
  end
117
117
 
118
- def done(span, meta=nil)
118
+ def done(span, meta = nil)
119
119
  # `span` will be `nil` if we failed to start instrumenting, such as in
120
120
  # the case of too many spans in a request.
121
121
  return unless span
@@ -187,89 +187,89 @@ module Skylight::Core
187
187
  t { e.backtrace.join("\n") }
188
188
  end
189
189
 
190
- private
190
+ private
191
191
 
192
- def track_gc(time, now)
193
- if time > 0
194
- t { fmt "tracking GC time; duration=%d", time }
195
- stop(start(now - time, GC_CAT, nil, nil, nil), now)
192
+ def track_gc(time, now)
193
+ if time > 0
194
+ t { fmt "tracking GC time; duration=%d", time }
195
+ stop(start(now - time, GC_CAT, nil, nil, nil), now)
196
+ end
196
197
  end
197
- end
198
198
 
199
- def start(time, cat, title, desc, meta, opts={})
200
- time = self.class.normalize_time(time) unless opts[:normalize] == false
199
+ def start(time, cat, title, desc, meta, opts = {})
200
+ time = self.class.normalize_time(time) unless opts[:normalize] == false
201
201
 
202
- sp = native_start_span(time, cat.to_s)
203
- native_span_set_title(sp, title.to_s) if title
204
- native_span_set_description(sp, desc.to_s) if desc
205
- native_span_set_meta(sp, meta) if meta
206
- native_span_started(sp)
202
+ sp = native_start_span(time, cat.to_s)
203
+ native_span_set_title(sp, title.to_s) if title
204
+ native_span_set_description(sp, desc.to_s) if desc
205
+ native_span_set_meta(sp, meta) if meta
206
+ native_span_started(sp)
207
207
 
208
- @spans << sp
209
- t { "started span: #{sp} - #{cat}, #{title}" }
208
+ @spans << sp
209
+ t { "started span: #{sp} - #{cat}, #{title}" }
210
210
 
211
- sp
212
- end
211
+ sp
212
+ end
213
213
 
214
- # Middleware spans that were interrupted by a throw/catch should be cached here.
215
- # keys: span ids
216
- # values: nsec timestamp at which the span was cached here.
217
- def deferred_spans
218
- @deferred_spans ||= {}
219
- end
214
+ # Middleware spans that were interrupted by a throw/catch should be cached here.
215
+ # keys: span ids
216
+ # values: nsec timestamp at which the span was cached here.
217
+ def deferred_spans
218
+ @deferred_spans ||= {}
219
+ end
220
220
 
221
- def stop(span, time)
222
- t { "stopping span: #{span}" }
221
+ def stop(span, time)
222
+ t { "stopping span: #{span}" }
223
223
 
224
- # If `stop` is called for a span that is not the last item in the stack,
225
- # check to see if the last item has been marked as deferred. If so, close
226
- # that span first, then try to close the original.
227
- while deferred_spans[expected = @spans.pop]
228
- normalized_stop(expected, deferred_spans.delete(expected))
229
- end
224
+ # If `stop` is called for a span that is not the last item in the stack,
225
+ # check to see if the last item has been marked as deferred. If so, close
226
+ # that span first, then try to close the original.
227
+ while deferred_spans[expected = @spans.pop]
228
+ normalized_stop(expected, deferred_spans.delete(expected))
229
+ end
230
230
 
231
- handle_unexpected_stop(expected, span) unless span == expected
231
+ handle_unexpected_stop(expected, span) unless span == expected
232
232
 
233
- normalized_stop(span, time)
234
- nil
235
- end
233
+ normalized_stop(span, time)
234
+ nil
235
+ end
236
236
 
237
- def normalized_stop(span, time)
238
- time = self.class.normalize_time(time)
239
- native_stop_span(span, time)
240
- end
237
+ def normalized_stop(span, time)
238
+ time = self.class.normalize_time(time)
239
+ native_stop_span(span, time)
240
+ end
241
241
 
242
- # Originally extracted from `stop`.
243
- # If we attempt to close spans out of order, and it appears to be a middleware issue,
244
- # disable the middleware probe and mark trace as broken.
245
- def handle_unexpected_stop(expected, span)
246
- message = "[E0001] Spans were closed out of order. Expected to see '#{native_span_get_title(expected)}', " \
247
- "but got '#{native_span_get_title(span)}' instead."
248
-
249
- if native_span_get_category(span) == "rack.middleware" &&
250
- Probes.installed.keys.include?("ActionDispatch::MiddlewareStack::Middleware")
251
- if Probes::Middleware::Probe.disabled?
252
- message << "\nWe disabled the Middleware probe but unfortunately, this didn't solve the issue."
253
- else
254
- Probes::Middleware::Probe.disable!
255
- message << "\n#{native_span_get_title(span)} may be a Middleware that doesn't fully conform " \
256
- "to the Rack SPEC. We've disabled the Middleware probe to see if that resolves the issue."
242
+ # Originally extracted from `stop`.
243
+ # If we attempt to close spans out of order, and it appears to be a middleware issue,
244
+ # disable the middleware probe and mark trace as broken.
245
+ def handle_unexpected_stop(expected, span)
246
+ message = "[E0001] Spans were closed out of order. Expected to see '#{native_span_get_title(expected)}', " \
247
+ "but got '#{native_span_get_title(span)}' instead."
248
+
249
+ if native_span_get_category(span) == "rack.middleware" &&
250
+ Probes.installed.key?("ActionDispatch::MiddlewareStack::Middleware")
251
+ if Probes::Middleware::Probe.disabled?
252
+ message << "\nWe disabled the Middleware probe but unfortunately, this didn't solve the issue."
253
+ else
254
+ Probes::Middleware::Probe.disable!
255
+ message << "\n#{native_span_get_title(span)} may be a Middleware that doesn't fully conform " \
256
+ "to the Rack SPEC. We've disabled the Middleware probe to see if that resolves the issue."
257
+ end
257
258
  end
258
- end
259
259
 
260
- message << "\nThis request will not be tracked. Please contact #{config.class.support_email} for more information."
260
+ message << "\nThis request will not be tracked. Please contact #{config.class.support_email} for more information."
261
261
 
262
- error message
262
+ error message
263
263
 
264
- t { "expected=#{expected}, actual=#{span}" }
264
+ t { "expected=#{expected}, actual=#{span}" }
265
265
 
266
- broken!
267
- end
266
+ broken!
267
+ end
268
268
 
269
- def gc_time
270
- return 0 unless @gc
271
- @gc.update
272
- @gc.time
273
- end
269
+ def gc_time
270
+ return 0 unless @gc
271
+ @gc.update
272
+ @gc.time
273
+ end
274
274
  end
275
275
  end
@@ -1,9 +1,8 @@
1
- require 'yaml'
2
- require 'skylight/core/errors'
1
+ require "yaml"
2
+ require "skylight/core/errors"
3
3
 
4
4
  module Skylight::Core
5
5
  class UserConfig
6
-
7
6
  attr_accessor :disable_dev_warning, :disable_env_warning
8
7
 
9
8
  def initialize(config)
@@ -17,7 +16,7 @@ module Skylight::Core
17
16
 
18
17
  config_path = @config[:user_config_path] || begin
19
18
  require "etc"
20
- home_dir = ENV['HOME'] || Etc.getpwuid.dir || (ENV["USER"] && File.expand_path("~#{ENV['USER']}"))
19
+ home_dir = ENV["HOME"] || Etc.getpwuid.dir || (ENV["USER"] && File.expand_path("~#{ENV['USER']}"))
21
20
  if home_dir
22
21
  File.join(home_dir, ".skylight")
23
22
  else
@@ -29,7 +28,7 @@ module Skylight::Core
29
28
  end
30
29
 
31
30
  def disable_dev_warning?
32
- disable_dev_warning || ENV['SKYLIGHT_DISABLE_DEV_WARNING'] =~ /^true$/i
31
+ disable_dev_warning || ENV["SKYLIGHT_DISABLE_DEV_WARNING"] =~ /^true$/i
33
32
  end
34
33
 
35
34
  def disable_env_warning?
@@ -40,23 +39,22 @@ module Skylight::Core
40
39
  config = File.exist?(file_path) ? YAML.load_file(file_path) : false
41
40
  return unless config
42
41
 
43
- self.disable_dev_warning = !!config['disable_dev_warning']
44
- self.disable_env_warning = !!config['disable_env_warning']
42
+ self.disable_dev_warning = !!config["disable_dev_warning"]
43
+ self.disable_env_warning = !!config["disable_env_warning"]
45
44
  end
46
45
 
47
46
  def save
48
47
  FileUtils.mkdir_p(File.dirname(file_path))
49
- File.open(file_path, 'w') do |f|
48
+ File.open(file_path, "w") do |f|
50
49
  f.puts YAML.dump(to_hash)
51
50
  end
52
51
  end
53
52
 
54
53
  def to_hash
55
54
  {
56
- 'disable_dev_warning' => disable_dev_warning,
57
- 'disable_env_warning' => disable_env_warning
55
+ "disable_dev_warning" => disable_dev_warning,
56
+ "disable_env_warning" => disable_env_warning
58
57
  }
59
58
  end
60
-
61
59
  end
62
60
  end
@@ -2,7 +2,6 @@ module Skylight::Core
2
2
  module Util
3
3
  # Helpers to reduce memory allocation
4
4
  module AllocationFree
5
-
6
5
  # Find an item in an array without allocation.
7
6
  #
8
7
  # @param array [Array] the array to search
@@ -2,7 +2,6 @@ module Skylight::Core
2
2
  module Util
3
3
  # A more precise clock
4
4
  class Clock
5
-
6
5
  def self.use_native!
7
6
  class_eval do
8
7
  def tick
@@ -11,10 +10,12 @@ module Skylight::Core
11
10
  end
12
11
  end
13
12
 
13
+ # rubocop:disable Lint/DuplicateMethods
14
14
  def tick
15
15
  now = Time.now
16
16
  now.to_i * 1_000_000_000 + now.usec * 1_000
17
17
  end
18
+ # rubocop:enable Lint/DuplicateMethods
18
19
 
19
20
  # TODO: rename to secs
20
21
  def absolute_secs
@@ -31,26 +32,25 @@ module Skylight::Core
31
32
  nanos / 1_000_000_000
32
33
  end
33
34
 
34
- def self.absolute_secs
35
- default.absolute_secs
36
- end
35
+ class << self
36
+ def absolute_secs
37
+ default.absolute_secs
38
+ end
37
39
 
38
- def self.nanos
39
- default.nanos
40
- end
40
+ def nanos
41
+ default.nanos
42
+ end
41
43
 
42
- def self.secs
43
- default.secs
44
- end
44
+ def secs
45
+ default.secs
46
+ end
45
47
 
46
- def self.default
47
- @clock ||= Clock.new
48
- end
48
+ def default
49
+ @default ||= Clock.new
50
+ end
49
51
 
50
- def self.default=(clock)
51
- @clock = clock
52
+ attr_writer :default
52
53
  end
53
-
54
54
  end
55
55
  end
56
56
  end
@@ -1,10 +1,9 @@
1
- require 'zlib'
1
+ require "zlib"
2
2
 
3
3
  module Skylight::Core
4
4
  module Util
5
5
  # Provides Gzip compressing support
6
6
  module Gzip
7
-
8
7
  # Compress a string with Gzip
9
8
  #
10
9
  # @param str [String] uncompressed string
@@ -1,6 +1,7 @@
1
+ # rubocop:disable all
2
+
1
3
  module Skylight::Core
2
4
  module Util
3
-
4
5
  # String Inflector methods
5
6
  #
6
7
  # From https://github.com/rails/rails/blob/f8e5022c73679f41db9bb6743179bab4571fb28e/activesupport/lib/active_support/inflector/methods.rb
@@ -26,7 +27,7 @@ module Skylight::Core
26
27
  # NameError is raised when the name is not in CamelCase or the constant is
27
28
  # unknown.
28
29
  def constantize(camel_cased_word)
29
- names = camel_cased_word.split('::')
30
+ names = camel_cased_word.split("::")
30
31
 
31
32
  # Trigger a builtin NameError exception including the ill-formed constant in the message.
32
33
  Object.const_get(camel_cased_word) if names.empty?
@@ -105,8 +106,8 @@ module Skylight::Core
105
106
  part.empty? ? acc : "#{part}(::#{acc})?"
106
107
  end
107
108
 
108
- "(" + ([regexp] + parts[1..-1]).join('|') + ")"
109
+ "(" + ([regexp] + parts[1..-1]).join("|") + ")"
109
110
  end
110
111
  end
111
112
  end
112
- end
113
+ end
@@ -1,4 +1,4 @@
1
- require 'logger'
1
+ require "logger"
2
2
 
3
3
  module Skylight::Core
4
4
  module Util
@@ -19,18 +19,16 @@ module Skylight::Core
19
19
  end
20
20
  end
21
21
 
22
- def close
23
- end
22
+ def close; end
24
23
  end
25
24
 
26
25
  module Logging
27
-
28
26
  def log_context
29
27
  {}
30
28
  end
31
29
 
32
30
  def log_env_prefix
33
- if c = config_for_logging
31
+ if (c = config_for_logging)
34
32
  c.class.env_prefix
35
33
  else
36
34
  "SKYLIGHT_"
@@ -88,7 +86,7 @@ module Skylight::Core
88
86
  # @param args (see #log)
89
87
  def error(msg, *args)
90
88
  log :error, msg, *args
91
- raise sprintf(msg, *args) if raise_on_error?
89
+ raise format(msg, *args) if raise_on_error?
92
90
  end
93
91
 
94
92
  alias log_trace trace
@@ -106,7 +104,7 @@ module Skylight::Core
106
104
  def config_for_logging
107
105
  if respond_to?(:config)
108
106
  config
109
- elsif self.is_a?(Config)
107
+ elsif is_a?(Config)
110
108
  self
111
109
  end
112
110
  end
@@ -118,12 +116,12 @@ module Skylight::Core
118
116
  c = config_for_logging
119
117
  logger = c ? c.logger : nil
120
118
 
121
- msg = log_context.map{|(k,v)| "#{k}=#{v}; " }.join << msg
119
+ msg = log_context.map { |(k, v)| "#{k}=#{v}; " }.join << msg
122
120
 
123
121
  if logger
124
122
  if logger.respond_to?(level)
125
- if args.length > 0
126
- logger.send level, sprintf(msg, *args)
123
+ if !args.empty?
124
+ logger.send level, format(msg, *args)
127
125
  else
128
126
  logger.send level, msg
129
127
  end
@@ -134,18 +132,17 @@ module Skylight::Core
134
132
  end
135
133
 
136
134
  # Fallback
137
- if module_name = self.is_a?(Module) ? name : self.class.name
138
- root_name = module_name.split('::').first.upcase
135
+ if (module_name = is_a?(Module) ? name : self.class.name)
136
+ root_name = module_name.split("::").first.upcase
139
137
  msg.prepend("[#{root_name}] ")
140
138
  end
141
- puts sprintf(msg, *args)
139
+ puts format(msg, *args)
142
140
  rescue Exception => e
143
141
  if trace?
144
142
  puts "[ERROR] #{e.message}"
145
143
  puts e.backtrace
146
144
  end
147
145
  end
148
-
149
146
  end
150
147
  end
151
148
  end
@@ -1,4 +1,4 @@
1
- require 'rbconfig'
1
+ require "rbconfig"
2
2
 
3
3
  # Used from extconf and to load libskylight
4
4
  module Skylight
@@ -6,59 +6,62 @@ module Skylight
6
6
  module Util
7
7
  module Platform
8
8
  # Normalize the platform OS
9
- OS = case os = RbConfig::CONFIG['host_os'].downcase
10
- when /linux/
11
- # The official ruby-alpine Docker containers pre-build Ruby. As a result,
12
- # Ruby doesn't know that it's on a musl-based platform. `ldd` is the
13
- # only reliable way to detect musl that we've found.
14
- # See https://github.com/skylightio/skylight-ruby/issues/92
15
- if ENV['SKYLIGHT_MUSL'] || `ldd --version 2>&1` =~ /musl/
16
- "linux-musl"
9
+ OS =
10
+ case os = RbConfig::CONFIG["host_os"].downcase
11
+ when /linux/
12
+ # The official ruby-alpine Docker containers pre-build Ruby. As a result,
13
+ # Ruby doesn't know that it's on a musl-based platform. `ldd` is the
14
+ # only reliable way to detect musl that we've found.
15
+ # See https://github.com/skylightio/skylight-ruby/issues/92
16
+ if ENV["SKYLIGHT_MUSL"] || `ldd --version 2>&1` =~ /musl/
17
+ "linux-musl"
18
+ else
19
+ "linux"
20
+ end
21
+ when /darwin/
22
+ "darwin"
23
+ when /freebsd/
24
+ "freebsd"
25
+ when /netbsd/
26
+ "netbsd"
27
+ when /openbsd/
28
+ "openbsd"
29
+ when /sunos|solaris/
30
+ "solaris"
31
+ when /mingw|mswin/
32
+ "windows"
17
33
  else
18
- "linux"
34
+ os
19
35
  end
20
- when /darwin/
21
- "darwin"
22
- when /freebsd/
23
- "freebsd"
24
- when /netbsd/
25
- "netbsd"
26
- when /openbsd/
27
- "openbsd"
28
- when /sunos|solaris/
29
- "solaris"
30
- when /mingw|mswin/
31
- "windows"
32
- else
33
- os
34
- end
35
36
 
36
37
  # Normalize the platform CPU
37
- ARCH = case cpu = RbConfig::CONFIG['host_cpu'].downcase
38
- when /amd64|x86_64/
39
- "x86_64"
40
- when /i?86|x86|i86pc/
41
- "x86"
42
- when /ppc|powerpc/
43
- "powerpc"
44
- when /^arm/
45
- "arm"
46
- else
47
- cpu
48
- end
38
+ ARCH =
39
+ case cpu = RbConfig::CONFIG["host_cpu"].downcase
40
+ when /amd64|x86_64/
41
+ "x86_64"
42
+ when /i?86|x86|i86pc/
43
+ "x86"
44
+ when /ppc|powerpc/
45
+ "powerpc"
46
+ when /^arm/
47
+ "arm"
48
+ else
49
+ cpu
50
+ end
49
51
 
50
- LIBEXT = case OS
51
- when /darwin/
52
- 'dylib'
53
- when /linux|bsd|solaris/
54
- 'so'
55
- when /windows|cygwin/
56
- 'dll'
57
- else
58
- 'so'
59
- end
52
+ LIBEXT =
53
+ case OS
54
+ when /darwin/
55
+ "dylib"
56
+ when /linux|bsd|solaris/
57
+ "so"
58
+ when /windows|cygwin/
59
+ "dll"
60
+ else
61
+ "so"
62
+ end
60
63
 
61
- TUPLE = "#{ARCH}-#{OS}"
64
+ TUPLE = "#{ARCH}-#{OS}".freeze
62
65
 
63
66
  def self.tuple
64
67
  TUPLE
@@ -69,7 +72,7 @@ module Skylight
69
72
  end
70
73
 
71
74
  def self.dlext
72
- RbConfig::CONFIG['DLEXT']
75
+ RbConfig::CONFIG["DLEXT"]
73
76
  end
74
77
  end
75
78
  end
@@ -2,12 +2,12 @@ module Skylight::Core
2
2
  module Util
3
3
  module Proxy
4
4
  def self.detect_url(env)
5
- u = env['HTTP_PROXY'] || env['http_proxy']
5
+ u = env["HTTP_PROXY"] || env["http_proxy"]
6
6
  if u && !u.empty?
7
- u = "http://#{u}" unless u =~ %r[://]
7
+ u = "http://#{u}" unless u =~ %r{://}
8
8
  u
9
9
  end
10
10
  end
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -2,12 +2,12 @@ module Skylight::Core
2
2
  # @api private
3
3
  module Util
4
4
  # Used from the main lib
5
- require 'skylight/core/util/allocation_free'
6
- require 'skylight/core/util/clock'
7
- require 'skylight/core/util/logging'
5
+ require "skylight/core/util/allocation_free"
6
+ require "skylight/core/util/clock"
7
+ require "skylight/core/util/logging"
8
8
 
9
9
  # Used from the CLI
10
- autoload :Gzip, 'skylight/core/util/gzip'
11
- autoload :Inflector, 'skylight/core/util/inflector'
10
+ autoload :Gzip, "skylight/core/util/gzip"
11
+ autoload :Inflector, "skylight/core/util/inflector"
12
12
  end
13
13
  end
@@ -1,6 +1,5 @@
1
1
  module Skylight
2
2
  module Core
3
- VERSION = '3.1.5'
3
+ VERSION = "4.0.0-alpha".freeze
4
4
  end
5
5
  end
6
-
@@ -1,4 +1,3 @@
1
-
2
1
  module Skylight::Core
3
2
  # @api private
4
3
  module VM
@@ -57,8 +56,7 @@ module Skylight::Core
57
56
  unless defined?(VM::GC)
58
57
 
59
58
  class GC
60
- def enable
61
- end
59
+ def enable; end
62
60
 
63
61
  def total_time
64
62
  0