Module: Skylight::Core::Probes Private

Defined in:
lib/skylight/core/probes.rb,
lib/skylight/core/probes/tilt.rb,
lib/skylight/core/probes/excon.rb,
lib/skylight/core/probes/mongo.rb,
lib/skylight/core/probes/moped.rb,
lib/skylight/core/probes/redis.rb,
lib/skylight/core/probes/sequel.rb,
lib/skylight/core/probes/faraday.rb,
lib/skylight/core/probes/graphql.rb,
lib/skylight/core/probes/mongoid.rb,
lib/skylight/core/probes/sinatra.rb,
lib/skylight/core/probes/net_http.rb,
lib/skylight/core/probes/active_job.rb,
lib/skylight/core/probes/httpclient.rb,
lib/skylight/core/probes/middleware.rb,
lib/skylight/core/probes/action_view.rb,
lib/skylight/core/probes/delayed_job.rb,
lib/skylight/core/probes/elasticsearch.rb,
lib/skylight/core/probes/excon/middleware.rb,
lib/skylight/core/probes/action_controller.rb,
lib/skylight/core/probes/active_job_enqueue.rb,
lib/skylight/core/probes/active_model_serializers.rb,
lib/skylight/core/probes/action_dispatch/request_id.rb,
lib/skylight/core/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, DelayedJob, Elasticsearch, Excon, Faraday, GraphQL, HTTPClient, Middleware, Mongo, Mongoid, Moped, NetHTTP, Redis, Sequel, Sinatra, Tilt Classes: ProbeRegistration

Class Method Summary collapse

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.


26
27
28
29
30
31
32
33
34
35
# File 'lib/skylight/core/probes.rb', line 26

def add_path(path)
  root = Pathname.new(path)
  Pathname.glob(root.join("./**/*.rb")).each do |f|
    name = f.relative_path_from(root).sub_ext("").to_s
    if available.key?(name)
      raise "duplicate probe name: #{name}; original=#{available[name]}; new=#{f}"
    end
    available[name] = f
  end
end

.availableObject

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.


37
38
39
# File 'lib/skylight/core/probes.rb', line 37

def available
  @available ||= {}
end

.available?(klass_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.

Returns:

  • (Boolean)

60
61
62
# File 'lib/skylight/core/probes.rb', line 60

def available?(klass_name)
  !!Skylight::Core::Util::Inflector.safe_constantize(klass_name)
end

.installedObject

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.


56
57
58
# File 'lib/skylight/core/probes.rb', line 56

def installed
  @installed ||= {}
end

.lookup_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.


101
102
103
# File 'lib/skylight/core/probes.rb', line 101

def lookup_by_require_path(require_path)
  require_hooks[require_path]
end

.pathsObject

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.


22
23
24
# File 'lib/skylight/core/probes.rb', line 22

def paths
  @paths ||= []
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.


41
42
43
44
45
46
47
48
49
50
# File 'lib/skylight/core/probes.rb', line 41

def probe(*probes)
  unknown = probes.map(&:to_s) - available.keys
  unless unknown.empty?
    raise ArgumentError, "unknown probes: #{unknown.join(', ')}"
  end

  probes.each do |p|
    require available[p.to_s]
  end
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.


64
65
66
67
68
69
70
71
72
73
# File 'lib/skylight/core/probes.rb', line 64

def register(name, *args)
  registration = ProbeRegistration.new(name, *args)

  if available?(registration.klass_name)
    installed[registration.klass_name] = registration
    registration.install
  else
    register_require_hook(registration)
  end
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.


89
90
91
92
93
# File 'lib/skylight/core/probes.rb', line 89

def register_require_hook(registration)
  registration.require_paths.each do |p|
    require_hooks[p] = registration
  end
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.


75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/skylight/core/probes.rb', line 75

def require_hook(require_path)
  registration = lookup_by_require_path(require_path)
  return unless registration

  # Double check constant is available
  if available?(registration.klass_name)
    installed[registration.klass_name] = registration
    registration.install

    # Don't need this to be called again
    unregister_require_hook(registration)
  end
end

.require_hooksObject

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.


52
53
54
# File 'lib/skylight/core/probes.rb', line 52

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.


95
96
97
98
99
# File 'lib/skylight/core/probes.rb', line 95

def unregister_require_hook(registration)
  registration.require_paths.each do |p|
    require_hooks.delete(p)
  end
end