Module: Skylight::Probes Private
- Defined in:
- lib/skylight/probes.rb,
lib/skylight/probes/tilt.rb,
lib/skylight/probes/excon.rb,
lib/skylight/probes/mongo.rb,
lib/skylight/probes/redis.rb,
lib/skylight/probes/lambda.rb,
lib/skylight/probes/sequel.rb,
lib/skylight/probes/faraday.rb,
lib/skylight/probes/graphql.rb,
lib/skylight/probes/sinatra.rb,
lib/skylight/probes/net_http.rb,
lib/skylight/probes/active_job.rb,
lib/skylight/probes/httpclient.rb,
lib/skylight/probes/middleware.rb,
lib/skylight/probes/action_view.rb,
lib/skylight/probes/delayed_job.rb,
lib/skylight/probes/rack_builder.rb,
lib/skylight/probes/elasticsearch.rb,
lib/skylight/probes/excon/middleware.rb,
lib/skylight/probes/action_controller.rb,
lib/skylight/probes/active_job_enqueue.rb,
lib/skylight/probes/active_record_async.rb,
lib/skylight/probes/sinatra_add_middleware.rb,
lib/skylight/probes/active_model_serializers.rb,
lib/skylight/probes/action_dispatch/request_id.rb,
lib/skylight/probes/action_dispatch/show_exceptions.rb,
lib/skylight/probes/action_dispatch/routing/route_set.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: ActionController, ActionDispatch, ActionView, ActiveJob, ActiveModelSerializers, ActiveRecord, DelayedJob, Elasticsearch, Excon, Faraday, GraphQL, HTTPClient, Lambda, Middleware, Mongo, NetHTTP, Rack, Redis, Sequel, Sinatra, Tilt Classes: ProbeRegistration
Class Method Summary collapse
- .add_path(path) ⇒ Object private
- .available ⇒ Object private
- .constant_available?(const_name) ⇒ Boolean private
- .each_by_require_path(require_path) ⇒ Object private
- .install! ⇒ Object private
- .install_probe(registration) ⇒ Object private
- .installed ⇒ Object private
- .probe(*probes) ⇒ Object private
- .register(name, *args) ⇒ Object private
- .register_require_hook(registration) ⇒ Object private
- .registered ⇒ Object private
- .require_hook(require_path) ⇒ Object private
- .require_hooks ⇒ Object private
- .unregister_require_hook(registration) ⇒ Object private
Class Method Details
.add_path(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/skylight/probes.rb', line 80 def add_path(path) Dir.glob("**/*.rb", base: path) do |f| name = Pathname.new(f).sub_ext("").to_s full_path = File.(f, path) raise "duplicate probe name: #{name}; original=#{available[name]}; new=#{full_path}" if available.key?(name) available[name] = full_path end end |
.available ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 |
# File 'lib/skylight/probes.rb', line 91 def available @available ||= {} end |
.constant_available?(const_name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/skylight/probes.rb', line 61 def constant_available?(const_name) !::ActiveSupport::Inflector.safe_constantize(const_name).nil? end |
.each_by_require_path(require_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
148 149 150 151 152 153 |
# File 'lib/skylight/probes.rb', line 148 def each_by_require_path(require_path) return unless require_hooks.key?(require_path) # dup because we may be mutating the array require_hooks[require_path].dup.each { |registration| yield registration } end |
.install! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 70 71 |
# File 'lib/skylight/probes.rb', line 65 def install! pending = registered.values - installed.values pending.each do |registration| registration.constant_available? ? install_probe(registration) : register_require_hook(registration) end end |
.install_probe(registration) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 76 77 78 |
# File 'lib/skylight/probes.rb', line 73 def install_probe(registration) return if installed.key?(registration.name) installed[registration.name] = registration registration.install end |
.installed ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
110 111 112 |
# File 'lib/skylight/probes.rb', line 110 def installed @installed ||= {} end |
.probe(*probes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 98 99 100 |
# File 'lib/skylight/probes.rb', line 95 def probe(*probes) unknown = probes.map(&:to_s) - available.keys raise ArgumentError, "unknown probes: #{unknown.join(", ")}" unless unknown.empty? probes.each { |p| require available[p.to_s] } end |
.register(name, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
114 115 116 117 118 119 120 |
# File 'lib/skylight/probes.rb', line 114 def register(name, *args) raise "already registered: #{name}" if registered.key?(name) registered[name] = ProbeRegistration.new(name, *args) true end |
.register_require_hook(registration) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
134 135 136 137 138 139 |
# File 'lib/skylight/probes.rb', line 134 def register_require_hook(registration) registration.require_paths.each do |p| require_hooks[p] ||= [] require_hooks[p] << registration end end |
.registered ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
102 103 104 |
# File 'lib/skylight/probes.rb', line 102 def registered @registered ||= {} end |
.require_hook(require_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/skylight/probes.rb', line 122 def require_hook(require_path) each_by_require_path(require_path) do |registration| # Double check constant is available next unless registration.constant_available? install_probe(registration) # Don't need this to be called again unregister_require_hook(registration) end end |
.require_hooks ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
106 107 108 |
# File 'lib/skylight/probes.rb', line 106 def require_hooks @require_hooks ||= {} end |
.unregister_require_hook(registration) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
141 142 143 144 145 146 |
# File 'lib/skylight/probes.rb', line 141 def unregister_require_hook(registration) registration.require_paths.each do |p| require_hooks[p].delete(registration) require_hooks.delete(p) if require_hooks[p].empty? end end |