Class: TingYun::Support::LibraryDetection::Dependent

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/support/library_detection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDependent

Returns a new instance of Dependent.



71
72
73
74
75
# File 'lib/ting_yun/support/library_detection.rb', line 71

def initialize
  @dependencies = []
  @executes = []
  @name = nil
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



59
60
61
# File 'lib/ting_yun/support/library_detection.rb', line 59

def dependencies
  @dependencies
end

#executedObject (readonly)

Returns the value of attribute executed.



60
61
62
# File 'lib/ting_yun/support/library_detection.rb', line 60

def executed
  @executed
end

#nameObject

Returns the value of attribute name.



61
62
63
# File 'lib/ting_yun/support/library_detection.rb', line 61

def name
  @name
end

Instance Method Details

#allowed_by_config?Boolean

Returns:

  • (Boolean)


107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ting_yun/support/library_detection.rb', line 107

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 TingYun::Agent.config[key]
    TingYun::Agent.logger.debug("Not installing #{self.name} instrumentation because of configuration #{key}")
  else
    true
  end
end

#check_dependenciesObject



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ting_yun/support/library_detection.rb', line 90

def check_dependencies
  return false unless allowed_by_config? && dependencies

  dependencies.all? do |depend|
    begin
      depend.call
    rescue => err
      TingYun::Agent.logger.error( "Error while detecting #{self.name}:", err )
      false
    end
  end
end

#dependencies_satisfied?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/ting_yun/support/library_detection.rb', line 67

def dependencies_satisfied?
  !executed and check_dependencies
end

#depends_onObject



103
104
105
# File 'lib/ting_yun/support/library_detection.rb', line 103

def depends_on
  @dependencies << Proc.new
end

#executeObject



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ting_yun/support/library_detection.rb', line 77

def execute
  @executes.each do |e|
    begin
      e.call
    rescue => err
      TingYun::Agent.logger.error( "Error while installing #{self.name} instrumentation:", err )
      break
    end
  end
ensure
  executed!
end

#executed!Object



63
64
65
# File 'lib/ting_yun/support/library_detection.rb', line 63

def executed!
  @executed = true
end

#executesObject



123
124
125
# File 'lib/ting_yun/support/library_detection.rb', line 123

def executes
  @executes << Proc.new
end

#named(new_name) ⇒ Object



119
120
121
# File 'lib/ting_yun/support/library_detection.rb', line 119

def named(new_name)
  self.name = new_name
end