Module: ElasticAPM::Spies Private

Defined in:
lib/elastic_apm/spies.rb,
lib/elastic_apm/spies/s3.rb,
lib/elastic_apm/spies/sns.rb,
lib/elastic_apm/spies/sqs.rb,
lib/elastic_apm/spies/http.rb,
lib/elastic_apm/spies/json.rb,
lib/elastic_apm/spies/rake.rb,
lib/elastic_apm/spies/tilt.rb,
lib/elastic_apm/spies/mongo.rb,
lib/elastic_apm/spies/redis.rb,
lib/elastic_apm/spies/resque.rb,
lib/elastic_apm/spies/sequel.rb,
lib/elastic_apm/spies/faraday.rb,
lib/elastic_apm/spies/sidekiq.rb,
lib/elastic_apm/spies/sinatra.rb,
lib/elastic_apm/spies/net_http.rb,
lib/elastic_apm/spies/sneakers.rb,
lib/elastic_apm/spies/dynamo_db.rb,
lib/elastic_apm/spies/shoryuken.rb,
lib/elastic_apm/spies/delayed_job.rb,
lib/elastic_apm/spies/sucker_punch.rb,
lib/elastic_apm/spies/elasticsearch.rb,
lib/elastic_apm/spies/action_dispatch.rb,
lib/elastic_apm/spies/azure_storage_table.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

Classes: ActionDispatchSpy, AzureStorageTableSpy, DelayedJobSpy, DynamoDBSpy, ElasticsearchSpy, FaradaySpy, HTTPSpy, JSONSpy, MongoSpy, NetHTTPSpy, RakeSpy, RedisSpy, Registration, ResqueSpy, S3Spy, SNSSpy, SQSSpy, SequelSpy, ShoryukenSpy, SidekiqSpy, SinatraSpy, SneakersSpy, SuckerPunchSpy, TiltSpy

Class Method Summary collapse

Class Method Details

.hook_into(name) ⇒ 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.



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/elastic_apm/spies.rb', line 85

def self.hook_into(name)
  return unless (registration = require_hooks[name])
  return unless safe_defined?(registration.const_name)

  installed[registration.const_name] = registration
  registration.install

  registration.require_paths.each do |path|
    require_hooks.delete path
  end
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.



44
45
46
# File 'lib/elastic_apm/spies.rb', line 44

def self.installed
  @installed ||= {}
end

.register(*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.



48
49
50
51
52
53
54
55
56
57
# File 'lib/elastic_apm/spies.rb', line 48

def self.register(*args)
  registration = Registration.new(*args)

  if safe_defined?(registration.const_name)
    registration.install
    installed[registration.const_name] = registration
  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.



79
80
81
82
83
# File 'lib/elastic_apm/spies.rb', line 79

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



40
41
42
# File 'lib/elastic_apm/spies.rb', line 40

def self.require_hooks
  @require_hooks ||= {}
end

.safe_defined?(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.

Returns:

  • (Boolean)


97
98
99
# File 'lib/elastic_apm/spies.rb', line 97

def self.safe_defined?(const_name)
  Util::Inflector.safe_constantize(const_name)
end

.without_faradayObject

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.



59
60
61
62
63
64
65
66
67
# File 'lib/elastic_apm/spies.rb', line 59

def self.without_faraday
  return yield unless defined?(FaradaySpy)

  # rubocop:disable Style/ExplicitBlockArgument
  ElasticAPM::Spies::FaradaySpy.disable_in do
    yield
  end
  # rubocop:enable Style/ExplicitBlockArgument
end

.without_net_httpObject

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.



69
70
71
72
73
74
75
76
77
# File 'lib/elastic_apm/spies.rb', line 69

def self.without_net_http
  return yield unless defined?(NetHTTPSpy)

  # rubocop:disable Style/ExplicitBlockArgument
  ElasticAPM::Spies::NetHTTPSpy.disable_in do
    yield
  end
  # rubocop:enable Style/ExplicitBlockArgument
end