class LibraryDetection::Dependent

Attributes

dependencies[R]
executed[R]
name[RW]

Public Class Methods

new() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 58
def initialize
  @dependencies = []
  @executes = []
  @name = nil
end

Public Instance Methods

allowed_by_config?() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 98
def allowed_by_config?
  # If we don't have a name, can't check config so allow it
  return true if self.name.nil?

  key = "disable_#{self.name}".to_sym
  if (OneApm::Manager.config[key] == true)
    OneApm::Manager.logger.debug("Not installing #{self.name} instrumentation because of configuration #{key}")
    false
  else
    true
  end
end
check_dependencies() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 81
def check_dependencies
  return false unless allowed_by_config? && dependencies

  dependencies.all? do |dep|
    begin
      dep.call
    rescue => err
      OneApm::Manager.logger.error( "Error while detecting #{self.name}:", err )
      false
    end
  end
end
dependencies_satisfied?() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 64
def dependencies_satisfied?
  !executed and check_dependencies
end
depends_on() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 94
def depends_on
  @dependencies << Proc.new
end
execute() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 68
def execute
  @executes.each do |x|
    begin
      x.call
    rescue => err
      OneApm::Manager.logger.error( "Error while installing #{self.name} instrumentation:", err )
      break
    end
  end
ensure
  executed!
end
executed!() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 52
def executed!
  @executed = true
end
executes() click to toggle source
# File lib/one_apm/support/library_detection.rb, line 115
def executes
  @executes << Proc.new
end
named(new_name) click to toggle source
# File lib/one_apm/support/library_detection.rb, line 111
def named(new_name)
  self.name = new_name
end