skylight 1.7.2 → 2.0.0.beta1

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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -33
  3. data/ext/extconf.rb +32 -6
  4. data/ext/libskylight.yml +6 -9
  5. data/ext/skylight_native.c +49 -18
  6. data/lib/skylight.rb +35 -1
  7. data/lib/skylight/api.rb +4 -2
  8. data/lib/skylight/cli.rb +1 -1
  9. data/lib/skylight/cli/doctor.rb +6 -4
  10. data/lib/skylight/config.rb +149 -518
  11. data/lib/skylight/data/cacert.pem +236 -812
  12. data/lib/skylight/helpers.rb +5 -1
  13. data/lib/skylight/instrumenter.rb +10 -241
  14. data/lib/skylight/middleware.rb +1 -89
  15. data/lib/skylight/native.rb +8 -6
  16. data/lib/skylight/native_ext_fetcher.rb +251 -0
  17. data/lib/skylight/normalizers/active_job/enqueue_at.rb +2 -20
  18. data/lib/skylight/probes/sinatra_add_middleware.rb +22 -0
  19. data/lib/skylight/railtie.rb +11 -131
  20. data/lib/skylight/sinatra.rb +1 -5
  21. data/lib/skylight/trace.rb +1 -229
  22. data/lib/skylight/util/http.rb +3 -3
  23. data/lib/skylight/vendor/cli/thor/actions/directory.rb +5 -15
  24. data/lib/skylight/version.rb +1 -1
  25. metadata +114 -91
  26. data/lib/skylight/compat.rb +0 -76
  27. data/lib/skylight/core.rb +0 -149
  28. data/lib/skylight/deprecation.rb +0 -55
  29. data/lib/skylight/formatters/http.rb +0 -20
  30. data/lib/skylight/gc.rb +0 -107
  31. data/lib/skylight/normalizers.rb +0 -192
  32. data/lib/skylight/normalizers/action_controller/process_action.rb +0 -50
  33. data/lib/skylight/normalizers/action_controller/send_file.rb +0 -50
  34. data/lib/skylight/normalizers/action_view/render_collection.rb +0 -22
  35. data/lib/skylight/normalizers/action_view/render_partial.rb +0 -21
  36. data/lib/skylight/normalizers/action_view/render_template.rb +0 -21
  37. data/lib/skylight/normalizers/active_model_serializers/render.rb +0 -26
  38. data/lib/skylight/normalizers/active_record/instantiation.rb +0 -17
  39. data/lib/skylight/normalizers/active_record/sql.rb +0 -55
  40. data/lib/skylight/normalizers/active_support/cache.rb +0 -51
  41. data/lib/skylight/normalizers/active_support/cache_clear.rb +0 -16
  42. data/lib/skylight/normalizers/active_support/cache_decrement.rb +0 -16
  43. data/lib/skylight/normalizers/active_support/cache_delete.rb +0 -16
  44. data/lib/skylight/normalizers/active_support/cache_exist.rb +0 -16
  45. data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +0 -16
  46. data/lib/skylight/normalizers/active_support/cache_generate.rb +0 -16
  47. data/lib/skylight/normalizers/active_support/cache_increment.rb +0 -16
  48. data/lib/skylight/normalizers/active_support/cache_read.rb +0 -16
  49. data/lib/skylight/normalizers/active_support/cache_read_multi.rb +0 -16
  50. data/lib/skylight/normalizers/active_support/cache_write.rb +0 -16
  51. data/lib/skylight/normalizers/coach/handler_finish.rb +0 -36
  52. data/lib/skylight/normalizers/coach/middleware_finish.rb +0 -23
  53. data/lib/skylight/normalizers/couch_potato/query.rb +0 -20
  54. data/lib/skylight/normalizers/default.rb +0 -27
  55. data/lib/skylight/normalizers/elasticsearch/request.rb +0 -20
  56. data/lib/skylight/normalizers/faraday/request.rb +0 -38
  57. data/lib/skylight/normalizers/grape/endpoint.rb +0 -30
  58. data/lib/skylight/normalizers/grape/endpoint_render.rb +0 -26
  59. data/lib/skylight/normalizers/grape/endpoint_run.rb +0 -33
  60. data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +0 -23
  61. data/lib/skylight/normalizers/moped/query.rb +0 -100
  62. data/lib/skylight/probes.rb +0 -129
  63. data/lib/skylight/probes/action_controller.rb +0 -64
  64. data/lib/skylight/probes/action_dispatch.rb +0 -30
  65. data/lib/skylight/probes/action_view.rb +0 -43
  66. data/lib/skylight/probes/active_model_serializers.rb +0 -55
  67. data/lib/skylight/probes/elasticsearch.rb +0 -37
  68. data/lib/skylight/probes/excon.rb +0 -26
  69. data/lib/skylight/probes/excon/middleware.rb +0 -68
  70. data/lib/skylight/probes/faraday.rb +0 -22
  71. data/lib/skylight/probes/grape.rb +0 -88
  72. data/lib/skylight/probes/httpclient.rb +0 -46
  73. data/lib/skylight/probes/middleware.rb +0 -68
  74. data/lib/skylight/probes/mongo.rb +0 -161
  75. data/lib/skylight/probes/mongoid.rb +0 -21
  76. data/lib/skylight/probes/moped.rb +0 -39
  77. data/lib/skylight/probes/net_http.rb +0 -58
  78. data/lib/skylight/probes/redis.rb +0 -71
  79. data/lib/skylight/probes/sequel.rb +0 -37
  80. data/lib/skylight/probes/sinatra.rb +0 -76
  81. data/lib/skylight/probes/tilt.rb +0 -31
  82. data/lib/skylight/subscriber.rb +0 -122
  83. data/lib/skylight/user_config.rb +0 -60
  84. data/lib/skylight/util.rb +0 -17
  85. data/lib/skylight/util/allocation_free.rb +0 -26
  86. data/lib/skylight/util/clock.rb +0 -54
  87. data/lib/skylight/util/deploy.rb +0 -132
  88. data/lib/skylight/util/gzip.rb +0 -21
  89. data/lib/skylight/util/inflector.rb +0 -112
  90. data/lib/skylight/util/logging.rb +0 -127
  91. data/lib/skylight/util/multi_io.rb +0 -21
  92. data/lib/skylight/util/native_ext_fetcher.rb +0 -253
  93. data/lib/skylight/util/platform.rb +0 -75
  94. data/lib/skylight/util/proxy.rb +0 -13
  95. data/lib/skylight/vendor/active_support/notifications.rb +0 -207
  96. data/lib/skylight/vendor/active_support/notifications/fanout.rb +0 -159
  97. data/lib/skylight/vendor/active_support/notifications/instrumenter.rb +0 -72
  98. data/lib/skylight/vendor/active_support/per_thread_registry.rb +0 -52
  99. data/lib/skylight/vendor/thread_safe.rb +0 -126
  100. data/lib/skylight/vendor/thread_safe/non_concurrent_cache_backend.rb +0 -133
  101. data/lib/skylight/vendor/thread_safe/synchronized_cache_backend.rb +0 -76
  102. data/lib/skylight/vm/gc.rb +0 -70
@@ -1,75 +0,0 @@
1
- require 'rbconfig'
2
-
3
- # Used from extconf and to load libskylight
4
- module Skylight
5
- module Util
6
- module Platform
7
- # Normalize the platform OS
8
- OS = case os = RbConfig::CONFIG['host_os'].downcase
9
- when /linux/
10
- # The official ruby-alpine Docker containers pre-build Ruby. As a result,
11
- # Ruby doesn't know that it's on a musl-based platform. `ldd` is the
12
- # only reliable way to detect musl that we've found.
13
- # See https://github.com/skylightio/skylight-ruby/issues/92
14
- if ENV['SKYLIGHT_MUSL'] || `ldd --version 2>&1` =~ /musl/
15
- "linux-musl"
16
- else
17
- "linux"
18
- end
19
- when /darwin/
20
- "darwin"
21
- when /freebsd/
22
- "freebsd"
23
- when /netbsd/
24
- "netbsd"
25
- when /openbsd/
26
- "openbsd"
27
- when /sunos|solaris/
28
- "solaris"
29
- when /mingw|mswin/
30
- "windows"
31
- else
32
- os
33
- end
34
-
35
- # Normalize the platform CPU
36
- ARCH = case cpu = RbConfig::CONFIG['host_cpu'].downcase
37
- when /amd64|x86_64/
38
- "x86_64"
39
- when /i?86|x86|i86pc/
40
- "x86"
41
- when /ppc|powerpc/
42
- "powerpc"
43
- when /^arm/
44
- "arm"
45
- else
46
- cpu
47
- end
48
-
49
- LIBEXT = case OS
50
- when /darwin/
51
- 'dylib'
52
- when /linux|bsd|solaris/
53
- 'so'
54
- when /windows|cygwin/
55
- 'dll'
56
- else
57
- 'so'
58
- end
59
-
60
- TUPLE = "#{ARCH}-#{OS}"
61
-
62
- def self.tuple
63
- TUPLE
64
- end
65
-
66
- def self.libext
67
- LIBEXT
68
- end
69
-
70
- def self.dlext
71
- RbConfig::CONFIG['DLEXT']
72
- end
73
- end
74
- end
75
- end
@@ -1,13 +0,0 @@
1
- module Skylight
2
- module Util
3
- module Proxy
4
- def self.detect_url(env)
5
- u = env['HTTP_PROXY'] || env['http_proxy']
6
- if u && !u.empty?
7
- u = "http://#{u}" unless u =~ %r[://]
8
- u
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,207 +0,0 @@
1
- require 'skylight/vendor/active_support/notifications/instrumenter'
2
- require 'skylight/vendor/active_support/notifications/fanout'
3
- require 'skylight/vendor/active_support/per_thread_registry'
4
-
5
- module ActiveSupport
6
- # = Notifications
7
- #
8
- # <tt>ActiveSupport::Notifications</tt> provides an instrumentation API for
9
- # Ruby.
10
- #
11
- # == Instrumenters
12
- #
13
- # To instrument an event you just need to do:
14
- #
15
- # ActiveSupport::Notifications.instrument('render', extra: :information) do
16
- # render text: 'Foo'
17
- # end
18
- #
19
- # That executes the block first and notifies all subscribers once done.
20
- #
21
- # In the example above +render+ is the name of the event, and the rest is called
22
- # the _payload_. The payload is a mechanism that allows instrumenters to pass
23
- # extra information to subscribers. Payloads consist of a hash whose contents
24
- # are arbitrary and generally depend on the event.
25
- #
26
- # == Subscribers
27
- #
28
- # You can consume those events and the information they provide by registering
29
- # a subscriber.
30
- #
31
- # ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload|
32
- # name # => String, name of the event (such as 'render' from above)
33
- # start # => Time, when the instrumented block started execution
34
- # finish # => Time, when the instrumented block ended execution
35
- # id # => String, unique ID for this notification
36
- # payload # => Hash, the payload
37
- # end
38
- #
39
- # For instance, let's store all "render" events in an array:
40
- #
41
- # events = []
42
- #
43
- # ActiveSupport::Notifications.subscribe('render') do |*args|
44
- # events << ActiveSupport::Notifications::Event.new(*args)
45
- # end
46
- #
47
- # That code returns right away, you are just subscribing to "render" events.
48
- # The block is saved and will be called whenever someone instruments "render":
49
- #
50
- # ActiveSupport::Notifications.instrument('render', extra: :information) do
51
- # render text: 'Foo'
52
- # end
53
- #
54
- # event = events.first
55
- # event.name # => "render"
56
- # event.duration # => 10 (in milliseconds)
57
- # event.payload # => { extra: :information }
58
- #
59
- # The block in the <tt>subscribe</tt> call gets the name of the event, start
60
- # timestamp, end timestamp, a string with a unique identifier for that event
61
- # (something like "535801666f04d0298cd6"), and a hash with the payload, in
62
- # that order.
63
- #
64
- # If an exception happens during that particular instrumentation the payload will
65
- # have a key <tt>:exception</tt> with an array of two elements as value: a string with
66
- # the name of the exception class, and the exception message.
67
- #
68
- # As the previous example depicts, the class <tt>ActiveSupport::Notifications::Event</tt>
69
- # is able to take the arguments as they come and provide an object-oriented
70
- # interface to that data.
71
- #
72
- # It is also possible to pass an object as the second parameter passed to the
73
- # <tt>subscribe</tt> method instead of a block:
74
- #
75
- # module ActionController
76
- # class PageRequest
77
- # def call(name, started, finished, unique_id, payload)
78
- # Rails.logger.debug ['notification:', name, started, finished, unique_id, payload].join(' ')
79
- # end
80
- # end
81
- # end
82
- #
83
- # ActiveSupport::Notifications.subscribe('process_action.action_controller', ActionController::PageRequest.new)
84
- #
85
- # resulting in the following output within the logs including a hash with the payload:
86
- #
87
- # notification: process_action.action_controller 2012-04-13 01:08:35 +0300 2012-04-13 01:08:35 +0300 af358ed7fab884532ec7 {
88
- # controller: "Devise::SessionsController",
89
- # action: "new",
90
- # params: {"action"=>"new", "controller"=>"devise/sessions"},
91
- # format: :html,
92
- # method: "GET",
93
- # path: "/login/sign_in",
94
- # status: 200,
95
- # view_runtime: 279.3080806732178,
96
- # db_runtime: 40.053
97
- # }
98
- #
99
- # You can also subscribe to all events whose name matches a certain regexp:
100
- #
101
- # ActiveSupport::Notifications.subscribe(/render/) do |*args|
102
- # ...
103
- # end
104
- #
105
- # and even pass no argument to <tt>subscribe</tt>, in which case you are subscribing
106
- # to all events.
107
- #
108
- # == Temporary Subscriptions
109
- #
110
- # Sometimes you do not want to subscribe to an event for the entire life of
111
- # the application. There are two ways to unsubscribe.
112
- #
113
- # WARNING: The instrumentation framework is designed for long-running subscribers,
114
- # use this feature sparingly because it wipes some internal caches and that has
115
- # a negative impact on performance.
116
- #
117
- # === Subscribe While a Block Runs
118
- #
119
- # You can subscribe to some event temporarily while some block runs. For
120
- # example, in
121
- #
122
- # callback = lambda {|*args| ... }
123
- # ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
124
- # ...
125
- # end
126
- #
127
- # the callback will be called for all "sql.active_record" events instrumented
128
- # during the execution of the block. The callback is unsubscribed automatically
129
- # after that.
130
- #
131
- # === Manual Unsubscription
132
- #
133
- # The +subscribe+ method returns a subscriber object:
134
- #
135
- # subscriber = ActiveSupport::Notifications.subscribe("render") do |*args|
136
- # ...
137
- # end
138
- #
139
- # To prevent that block from being called anymore, just unsubscribe passing
140
- # that reference:
141
- #
142
- # ActiveSupport::Notifications.unsubscribe(subscriber)
143
- #
144
- # == Default Queue
145
- #
146
- # Notifications ships with a queue implementation that consumes and publish events
147
- # to log subscribers in a thread. You can use any queue implementation you want.
148
- #
149
- module Notifications
150
- class << self
151
- attr_accessor :notifier
152
-
153
- def publish(name, *args)
154
- notifier.publish(name, *args)
155
- end
156
-
157
- def instrument(name, payload = {})
158
- if notifier.listening?(name)
159
- instrumenter.instrument(name, payload) { yield payload if block_given? }
160
- else
161
- yield payload if block_given?
162
- end
163
- end
164
-
165
- def subscribe(*args, &block)
166
- notifier.subscribe(*args, &block)
167
- end
168
-
169
- def subscribed(callback, *args, &block)
170
- subscriber = subscribe(*args, &callback)
171
- yield
172
- ensure
173
- unsubscribe(subscriber)
174
- end
175
-
176
- def unsubscribe(args)
177
- notifier.unsubscribe(args)
178
- end
179
-
180
- def instrumenter
181
- InstrumentationRegistry.instrumenter_for(notifier)
182
- end
183
- end
184
-
185
- # This class is a registry which holds all of the +Instrumenter+ objects
186
- # in a particular thread local. To access the +Instrumenter+ object for a
187
- # particular +notifier+, you can call the following method:
188
- #
189
- # InstrumentationRegistry.instrumenter_for(notifier)
190
- #
191
- # The instrumenters for multiple notifiers are held in a single instance of
192
- # this class.
193
- class InstrumentationRegistry # :nodoc:
194
- extend ActiveSupport::PerThreadRegistry
195
-
196
- def initialize
197
- @registry = {}
198
- end
199
-
200
- def instrumenter_for(notifier)
201
- @registry[notifier] ||= Instrumenter.new(notifier)
202
- end
203
- end
204
-
205
- self.notifier = Fanout.new
206
- end
207
- end
@@ -1,159 +0,0 @@
1
- require 'mutex_m'
2
- begin
3
- require 'thread_safe'
4
- rescue LoadError
5
- require 'skylight/vendor/thread_safe'
6
- end
7
-
8
- module ActiveSupport
9
- module Notifications
10
- # This is a default queue implementation that ships with Notifications.
11
- # It just pushes events to all registered log subscribers.
12
- #
13
- # This class is thread safe. All methods are reentrant.
14
- class Fanout
15
- include Mutex_m
16
-
17
- def initialize
18
- @subscribers = []
19
- @listeners_for = ThreadSafe::Cache.new
20
- super
21
- end
22
-
23
- def subscribe(pattern = nil, block = Proc.new)
24
- subscriber = Subscribers.new pattern, block
25
- synchronize do
26
- @subscribers << subscriber
27
- @listeners_for.clear
28
- end
29
- subscriber
30
- end
31
-
32
- def unsubscribe(subscriber)
33
- synchronize do
34
- @subscribers.reject! { |s| s.matches?(subscriber) }
35
- @listeners_for.clear
36
- end
37
- end
38
-
39
- def start(name, id, payload)
40
- listeners_for(name).each { |s| s.start(name, id, payload) }
41
- end
42
-
43
- def finish(name, id, payload)
44
- listeners_for(name).each { |s| s.finish(name, id, payload) }
45
- end
46
-
47
- def publish(name, *args)
48
- listeners_for(name).each { |s| s.publish(name, *args) }
49
- end
50
-
51
- def listeners_for(name)
52
- # this is correctly done double-checked locking (ThreadSafe::Cache's lookups have volatile semantics)
53
- @listeners_for[name] || synchronize do
54
- # use synchronisation when accessing @subscribers
55
- @listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
56
- end
57
- end
58
-
59
- def listening?(name)
60
- listeners_for(name).any?
61
- end
62
-
63
- # This is a sync queue, so there is no waiting.
64
- def wait
65
- end
66
-
67
- module Subscribers # :nodoc:
68
- def self.new(pattern, listener)
69
- if listener.respond_to?(:start) and listener.respond_to?(:finish)
70
- subscriber = Evented.new pattern, listener
71
- else
72
- subscriber = Timed.new pattern, listener
73
- end
74
-
75
- unless pattern
76
- AllMessages.new(subscriber)
77
- else
78
- subscriber
79
- end
80
- end
81
-
82
- class Evented #:nodoc:
83
- def initialize(pattern, delegate)
84
- @pattern = pattern
85
- @delegate = delegate
86
- @can_publish = delegate.respond_to?(:publish)
87
- end
88
-
89
- def publish(name, *args)
90
- if @can_publish
91
- @delegate.publish name, *args
92
- end
93
- end
94
-
95
- def start(name, id, payload)
96
- @delegate.start name, id, payload
97
- end
98
-
99
- def finish(name, id, payload)
100
- @delegate.finish name, id, payload
101
- end
102
-
103
- def subscribed_to?(name)
104
- @pattern === name.to_s
105
- end
106
-
107
- def matches?(subscriber_or_name)
108
- self === subscriber_or_name ||
109
- @pattern && @pattern === subscriber_or_name
110
- end
111
- end
112
-
113
- class Timed < Evented
114
- def initialize(pattern, delegate)
115
- @timestack = []
116
- super
117
- end
118
-
119
- def publish(name, *args)
120
- @delegate.call name, *args
121
- end
122
-
123
- def start(name, id, payload)
124
- @timestack.push Time.now
125
- end
126
-
127
- def finish(name, id, payload)
128
- started = @timestack.pop
129
- @delegate.call(name, started, Time.now, id, payload)
130
- end
131
- end
132
-
133
- class AllMessages # :nodoc:
134
- def initialize(delegate)
135
- @delegate = delegate
136
- end
137
-
138
- def start(name, id, payload)
139
- @delegate.start name, id, payload
140
- end
141
-
142
- def finish(name, id, payload)
143
- @delegate.finish name, id, payload
144
- end
145
-
146
- def publish(name, *args)
147
- @delegate.publish name, *args
148
- end
149
-
150
- def subscribed_to?(name)
151
- true
152
- end
153
-
154
- alias :matches? :===
155
- end
156
- end
157
- end
158
- end
159
- end