skylight 4.3.2 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -3
  3. data/CONTRIBUTING.md +2 -8
  4. data/ext/extconf.rb +6 -5
  5. data/ext/libskylight.yml +7 -6
  6. data/ext/skylight_native.c +22 -99
  7. data/lib/skylight.rb +211 -14
  8. data/lib/skylight/api.rb +10 -3
  9. data/lib/skylight/cli.rb +4 -3
  10. data/lib/skylight/cli/doctor.rb +13 -14
  11. data/lib/skylight/cli/merger.rb +6 -4
  12. data/lib/skylight/config.rb +597 -127
  13. data/lib/skylight/deprecation.rb +17 -0
  14. data/lib/skylight/errors.rb +21 -6
  15. data/lib/skylight/extensions.rb +107 -0
  16. data/lib/skylight/extensions/source_location.rb +291 -0
  17. data/lib/skylight/formatters/http.rb +20 -0
  18. data/lib/skylight/gc.rb +109 -0
  19. data/lib/skylight/helpers.rb +69 -26
  20. data/lib/skylight/instrumenter.rb +326 -15
  21. data/lib/skylight/middleware.rb +138 -1
  22. data/lib/skylight/native.rb +52 -2
  23. data/lib/skylight/native_ext_fetcher.rb +4 -3
  24. data/lib/skylight/normalizers.rb +153 -0
  25. data/lib/skylight/normalizers/action_controller/process_action.rb +69 -0
  26. data/lib/skylight/normalizers/action_controller/send_file.rb +50 -0
  27. data/lib/skylight/normalizers/action_dispatch/process_middleware.rb +22 -0
  28. data/lib/skylight/normalizers/action_dispatch/route_set.rb +27 -0
  29. data/lib/skylight/normalizers/action_view/render_collection.rb +24 -0
  30. data/lib/skylight/normalizers/action_view/render_layout.rb +25 -0
  31. data/lib/skylight/normalizers/action_view/render_partial.rb +23 -0
  32. data/lib/skylight/normalizers/action_view/render_template.rb +23 -0
  33. data/lib/skylight/normalizers/active_job/perform.rb +86 -0
  34. data/lib/skylight/normalizers/active_model_serializers/render.rb +28 -0
  35. data/lib/skylight/normalizers/active_record/instantiation.rb +16 -0
  36. data/lib/skylight/normalizers/active_record/sql.rb +12 -0
  37. data/lib/skylight/normalizers/active_storage.rb +30 -0
  38. data/lib/skylight/normalizers/active_support/cache.rb +22 -0
  39. data/lib/skylight/normalizers/active_support/cache_clear.rb +16 -0
  40. data/lib/skylight/normalizers/active_support/cache_decrement.rb +16 -0
  41. data/lib/skylight/normalizers/active_support/cache_delete.rb +16 -0
  42. data/lib/skylight/normalizers/active_support/cache_exist.rb +16 -0
  43. data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +16 -0
  44. data/lib/skylight/normalizers/active_support/cache_generate.rb +16 -0
  45. data/lib/skylight/normalizers/active_support/cache_increment.rb +16 -0
  46. data/lib/skylight/normalizers/active_support/cache_read.rb +16 -0
  47. data/lib/skylight/normalizers/active_support/cache_read_multi.rb +16 -0
  48. data/lib/skylight/normalizers/active_support/cache_write.rb +16 -0
  49. data/lib/skylight/normalizers/coach/handler_finish.rb +46 -0
  50. data/lib/skylight/normalizers/coach/middleware_finish.rb +33 -0
  51. data/lib/skylight/normalizers/couch_potato/query.rb +20 -0
  52. data/lib/skylight/normalizers/data_mapper/sql.rb +12 -0
  53. data/lib/skylight/normalizers/default.rb +32 -0
  54. data/lib/skylight/normalizers/elasticsearch/request.rb +20 -0
  55. data/lib/skylight/normalizers/faraday/request.rb +40 -0
  56. data/lib/skylight/normalizers/grape/endpoint.rb +34 -0
  57. data/lib/skylight/normalizers/grape/endpoint_render.rb +25 -0
  58. data/lib/skylight/normalizers/grape/endpoint_run.rb +41 -0
  59. data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +22 -0
  60. data/lib/skylight/normalizers/grape/format_response.rb +20 -0
  61. data/lib/skylight/normalizers/graphiti/render.rb +22 -0
  62. data/lib/skylight/normalizers/graphiti/resolve.rb +31 -0
  63. data/lib/skylight/normalizers/graphql/base.rb +132 -0
  64. data/lib/skylight/normalizers/render.rb +81 -0
  65. data/lib/skylight/normalizers/sequel/sql.rb +12 -0
  66. data/lib/skylight/normalizers/shrine.rb +34 -0
  67. data/lib/skylight/normalizers/sql.rb +45 -0
  68. data/lib/skylight/probes.rb +181 -0
  69. data/lib/skylight/probes/action_controller.rb +48 -0
  70. data/lib/skylight/probes/action_dispatch.rb +2 -0
  71. data/lib/skylight/probes/action_dispatch/request_id.rb +29 -0
  72. data/lib/skylight/probes/action_dispatch/routing/route_set.rb +28 -0
  73. data/lib/skylight/probes/action_view.rb +43 -0
  74. data/lib/skylight/probes/active_job.rb +27 -0
  75. data/lib/skylight/probes/active_job_enqueue.rb +41 -0
  76. data/lib/skylight/probes/active_model_serializers.rb +50 -0
  77. data/lib/skylight/probes/delayed_job.rb +149 -0
  78. data/lib/skylight/probes/elasticsearch.rb +38 -0
  79. data/lib/skylight/probes/excon.rb +25 -0
  80. data/lib/skylight/probes/excon/middleware.rb +66 -0
  81. data/lib/skylight/probes/faraday.rb +23 -0
  82. data/lib/skylight/probes/graphql.rb +43 -0
  83. data/lib/skylight/probes/httpclient.rb +44 -0
  84. data/lib/skylight/probes/middleware.rb +126 -0
  85. data/lib/skylight/probes/mongo.rb +164 -0
  86. data/lib/skylight/probes/mongoid.rb +13 -0
  87. data/lib/skylight/probes/net_http.rb +54 -0
  88. data/lib/skylight/probes/redis.rb +63 -0
  89. data/lib/skylight/probes/sequel.rb +33 -0
  90. data/lib/skylight/probes/sinatra.rb +63 -0
  91. data/lib/skylight/probes/sinatra_add_middleware.rb +10 -10
  92. data/lib/skylight/probes/tilt.rb +27 -0
  93. data/lib/skylight/railtie.rb +162 -18
  94. data/lib/skylight/sidekiq.rb +48 -0
  95. data/lib/skylight/subscriber.rb +110 -0
  96. data/lib/skylight/test.rb +146 -0
  97. data/lib/skylight/trace.rb +307 -10
  98. data/lib/skylight/user_config.rb +61 -0
  99. data/lib/skylight/util.rb +12 -0
  100. data/lib/skylight/util/allocation_free.rb +26 -0
  101. data/lib/skylight/util/clock.rb +56 -0
  102. data/lib/skylight/util/component.rb +5 -2
  103. data/lib/skylight/util/deploy.rb +7 -10
  104. data/lib/skylight/util/gzip.rb +20 -0
  105. data/lib/skylight/util/http.rb +4 -10
  106. data/lib/skylight/util/instrumenter_method.rb +26 -0
  107. data/lib/skylight/util/logging.rb +138 -0
  108. data/lib/skylight/util/lru_cache.rb +40 -0
  109. data/lib/skylight/util/platform.rb +1 -1
  110. data/lib/skylight/vendor/cli/thor/rake_compat.rb +1 -1
  111. data/lib/skylight/version.rb +5 -1
  112. data/lib/skylight/vm/gc.rb +68 -0
  113. metadata +126 -13
@@ -0,0 +1,40 @@
1
+ # Based on code by Sam Saffron: https://stackoverflow.com/a/16161783/181916
2
+ module Skylight
3
+ module Util
4
+ class LruCache
5
+ def initialize(max_size)
6
+ @max_size = max_size
7
+ @data = {}
8
+ end
9
+
10
+ def max_size=(size)
11
+ raise ArgumentError, :max_size if @max_size < 1
12
+
13
+ @max_size = size
14
+ @data.shift while @data.size > @max_size
15
+ end
16
+
17
+ # Individual hash operations here are atomic in MRI.
18
+ def fetch(key)
19
+ found = true
20
+ value = @data.delete(key) { found = false }
21
+
22
+ if !found && block_given?
23
+ value = yield
24
+ end
25
+
26
+ @data[key] = value if value
27
+
28
+ if !found && value && @data.length > @max_size
29
+ @data.shift
30
+ end
31
+
32
+ value
33
+ end
34
+
35
+ def clear
36
+ @data.clear
37
+ end
38
+ end
39
+ end
40
+ end
@@ -56,7 +56,7 @@ module Skylight
56
56
  "so"
57
57
  when /windows|cygwin/
58
58
  "dll"
59
- else
59
+ else # rubocop:disable Lint/DuplicateBranch
60
60
  "so"
61
61
  end
62
62
 
@@ -11,7 +11,7 @@ class Thor
11
11
  # class Default < Thor
12
12
  # include Thor::RakeCompat
13
13
  #
14
- # RSpec::Core::RakeTask.new(:spec) do |t|
14
+ # RSpec::RakeTask.new(:spec) do |t|
15
15
  # t.spec_opts = ['--options', "./.rspec"]
16
16
  # t.spec_files = FileList['spec/**/*_spec.rb']
17
17
  # end
@@ -1,3 +1,7 @@
1
1
  module Skylight
2
- VERSION = "4.3.2".freeze
2
+ # pre-release versions should be given here as "5.0.0-alpha"
3
+ # for compatibility with semver when it is parsed by the rust agent.
4
+ # This string will be transformed in the gemspec to "5.0.0.alpha"
5
+ # to conform with rubygems.
6
+ VERSION = "5.0.1".freeze
3
7
  end
@@ -0,0 +1,68 @@
1
+ module Skylight
2
+ # @api private
3
+ module VM
4
+ if defined?(JRUBY_VERSION)
5
+
6
+ # This doesn't quite work as we would like it. I believe that the GC
7
+ # statistics includes time that is not stop-the-world, this does not
8
+ # necessarily take time away from the application.
9
+ #
10
+ # require 'java'
11
+ # class GC
12
+ # def initialize
13
+ # @factory = Java::JavaLangManagement::ManagementFactory
14
+ # end
15
+ #
16
+ # def enable
17
+ # end
18
+ #
19
+ # def total_time
20
+ # res = 0.0
21
+ #
22
+ # @factory.garbage_collector_mx_beans.each do |mx|
23
+ # res += (mx.collection_time.to_f / 1_000.0)
24
+ # end
25
+ #
26
+ # res
27
+ # end
28
+ # end
29
+
30
+ elsif defined?(::GC::Profiler)
31
+
32
+ class GC
33
+ def initialize
34
+ @total = 0
35
+ end
36
+
37
+ def enable
38
+ ::GC::Profiler.enable
39
+ end
40
+
41
+ def total_time
42
+ # Reported in seconds
43
+ run = (::GC::Profiler.total_time * 1_000_000).to_i
44
+
45
+ if run > 0
46
+ ::GC::Profiler.clear
47
+ end
48
+
49
+ @total += run
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ # Fallback
56
+ unless defined?(VM::GC)
57
+
58
+ class GC
59
+ def enable; end
60
+
61
+ def total_time
62
+ 0
63
+ end
64
+ end
65
+
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.2
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-15 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: skylight-core
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.3.2
19
+ version: 5.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.3.2
26
+ version: 5.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: beefcake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 12.3.3
89
+ version: 13.0.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 12.3.3
96
+ version: 13.0.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake-compiler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.4
103
+ version: 1.1.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.4
110
+ version: 1.1.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 1.11.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 1.11.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.21.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.21.2
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: timecop
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -193,20 +221,104 @@ files:
193
221
  - lib/skylight/cli/merger.rb
194
222
  - lib/skylight/config.rb
195
223
  - lib/skylight/data/cacert.pem
224
+ - lib/skylight/deprecation.rb
196
225
  - lib/skylight/errors.rb
226
+ - lib/skylight/extensions.rb
227
+ - lib/skylight/extensions/source_location.rb
228
+ - lib/skylight/formatters/http.rb
229
+ - lib/skylight/gc.rb
197
230
  - lib/skylight/helpers.rb
198
231
  - lib/skylight/instrumenter.rb
199
232
  - lib/skylight/middleware.rb
200
233
  - lib/skylight/native.rb
201
234
  - lib/skylight/native_ext_fetcher.rb
235
+ - lib/skylight/normalizers.rb
236
+ - lib/skylight/normalizers/action_controller/process_action.rb
237
+ - lib/skylight/normalizers/action_controller/send_file.rb
238
+ - lib/skylight/normalizers/action_dispatch/process_middleware.rb
239
+ - lib/skylight/normalizers/action_dispatch/route_set.rb
240
+ - lib/skylight/normalizers/action_view/render_collection.rb
241
+ - lib/skylight/normalizers/action_view/render_layout.rb
242
+ - lib/skylight/normalizers/action_view/render_partial.rb
243
+ - lib/skylight/normalizers/action_view/render_template.rb
244
+ - lib/skylight/normalizers/active_job/perform.rb
245
+ - lib/skylight/normalizers/active_model_serializers/render.rb
246
+ - lib/skylight/normalizers/active_record/instantiation.rb
247
+ - lib/skylight/normalizers/active_record/sql.rb
248
+ - lib/skylight/normalizers/active_storage.rb
249
+ - lib/skylight/normalizers/active_support/cache.rb
250
+ - lib/skylight/normalizers/active_support/cache_clear.rb
251
+ - lib/skylight/normalizers/active_support/cache_decrement.rb
252
+ - lib/skylight/normalizers/active_support/cache_delete.rb
253
+ - lib/skylight/normalizers/active_support/cache_exist.rb
254
+ - lib/skylight/normalizers/active_support/cache_fetch_hit.rb
255
+ - lib/skylight/normalizers/active_support/cache_generate.rb
256
+ - lib/skylight/normalizers/active_support/cache_increment.rb
257
+ - lib/skylight/normalizers/active_support/cache_read.rb
258
+ - lib/skylight/normalizers/active_support/cache_read_multi.rb
259
+ - lib/skylight/normalizers/active_support/cache_write.rb
260
+ - lib/skylight/normalizers/coach/handler_finish.rb
261
+ - lib/skylight/normalizers/coach/middleware_finish.rb
262
+ - lib/skylight/normalizers/couch_potato/query.rb
263
+ - lib/skylight/normalizers/data_mapper/sql.rb
264
+ - lib/skylight/normalizers/default.rb
265
+ - lib/skylight/normalizers/elasticsearch/request.rb
266
+ - lib/skylight/normalizers/faraday/request.rb
267
+ - lib/skylight/normalizers/grape/endpoint.rb
268
+ - lib/skylight/normalizers/grape/endpoint_render.rb
269
+ - lib/skylight/normalizers/grape/endpoint_run.rb
270
+ - lib/skylight/normalizers/grape/endpoint_run_filters.rb
271
+ - lib/skylight/normalizers/grape/format_response.rb
272
+ - lib/skylight/normalizers/graphiti/render.rb
273
+ - lib/skylight/normalizers/graphiti/resolve.rb
274
+ - lib/skylight/normalizers/graphql/base.rb
275
+ - lib/skylight/normalizers/render.rb
276
+ - lib/skylight/normalizers/sequel/sql.rb
277
+ - lib/skylight/normalizers/shrine.rb
278
+ - lib/skylight/normalizers/sql.rb
279
+ - lib/skylight/probes.rb
280
+ - lib/skylight/probes/action_controller.rb
281
+ - lib/skylight/probes/action_dispatch.rb
282
+ - lib/skylight/probes/action_dispatch/request_id.rb
283
+ - lib/skylight/probes/action_dispatch/routing/route_set.rb
284
+ - lib/skylight/probes/action_view.rb
285
+ - lib/skylight/probes/active_job.rb
286
+ - lib/skylight/probes/active_job_enqueue.rb
287
+ - lib/skylight/probes/active_model_serializers.rb
288
+ - lib/skylight/probes/delayed_job.rb
289
+ - lib/skylight/probes/elasticsearch.rb
290
+ - lib/skylight/probes/excon.rb
291
+ - lib/skylight/probes/excon/middleware.rb
292
+ - lib/skylight/probes/faraday.rb
293
+ - lib/skylight/probes/graphql.rb
294
+ - lib/skylight/probes/httpclient.rb
295
+ - lib/skylight/probes/middleware.rb
296
+ - lib/skylight/probes/mongo.rb
297
+ - lib/skylight/probes/mongoid.rb
298
+ - lib/skylight/probes/net_http.rb
299
+ - lib/skylight/probes/redis.rb
300
+ - lib/skylight/probes/sequel.rb
301
+ - lib/skylight/probes/sinatra.rb
202
302
  - lib/skylight/probes/sinatra_add_middleware.rb
303
+ - lib/skylight/probes/tilt.rb
203
304
  - lib/skylight/railtie.rb
305
+ - lib/skylight/sidekiq.rb
204
306
  - lib/skylight/sinatra.rb
307
+ - lib/skylight/subscriber.rb
308
+ - lib/skylight/test.rb
205
309
  - lib/skylight/trace.rb
310
+ - lib/skylight/user_config.rb
311
+ - lib/skylight/util.rb
312
+ - lib/skylight/util/allocation_free.rb
313
+ - lib/skylight/util/clock.rb
206
314
  - lib/skylight/util/component.rb
207
315
  - lib/skylight/util/deploy.rb
316
+ - lib/skylight/util/gzip.rb
208
317
  - lib/skylight/util/hostname.rb
209
318
  - lib/skylight/util/http.rb
319
+ - lib/skylight/util/instrumenter_method.rb
320
+ - lib/skylight/util/logging.rb
321
+ - lib/skylight/util/lru_cache.rb
210
322
  - lib/skylight/util/platform.rb
211
323
  - lib/skylight/util/proxy.rb
212
324
  - lib/skylight/util/ssl.rb
@@ -250,6 +362,7 @@ files:
250
362
  - lib/skylight/vendor/cli/thor/util.rb
251
363
  - lib/skylight/vendor/cli/thor/version.rb
252
364
  - lib/skylight/version.rb
365
+ - lib/skylight/vm/gc.rb
253
366
  homepage: https://www.skylight.io
254
367
  licenses:
255
368
  - Nonstandard
@@ -262,14 +375,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
375
  requirements:
263
376
  - - ">="
264
377
  - !ruby/object:Gem::Version
265
- version: '2.3'
378
+ version: '2.5'
266
379
  required_rubygems_version: !ruby/object:Gem::Requirement
267
380
  requirements:
268
381
  - - ">="
269
382
  - !ruby/object:Gem::Version
270
383
  version: '0'
271
384
  requirements: []
272
- rubygems_version: 3.1.4
385
+ rubygems_version: 3.2.3
273
386
  signing_key:
274
387
  specification_version: 4
275
388
  summary: Skylight is a smart profiler for Rails, Sinatra, and other Ruby apps.