Class: TingYun::Support::LibraryDetection::Dependent
- Inherits:
-
Object
- Object
- TingYun::Support::LibraryDetection::Dependent
- Defined in:
- lib/ting_yun/support/library_detection.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#executed ⇒ Object
readonly
Returns the value of attribute executed.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #allowed_by_config? ⇒ Boolean
- #check_dependencies ⇒ Object
- #dependencies_satisfied? ⇒ Boolean
- #depends_on ⇒ Object
- #execute ⇒ Object
- #executed! ⇒ Object
- #executes ⇒ Object
-
#initialize ⇒ Dependent
constructor
A new instance of Dependent.
- #named(new_name) ⇒ Object
Constructor Details
#initialize ⇒ Dependent
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
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
59 60 61 |
# File 'lib/ting_yun/support/library_detection.rb', line 59 def dependencies @dependencies end |
#executed ⇒ Object (readonly)
Returns the value of attribute executed.
60 61 62 |
# File 'lib/ting_yun/support/library_detection.rb', line 60 def executed @executed end |
#name ⇒ Object
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
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_dependencies ⇒ Object
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
67 68 69 |
# File 'lib/ting_yun/support/library_detection.rb', line 67 def dependencies_satisfied? !executed and check_dependencies end |
#depends_on ⇒ Object
103 104 105 |
# File 'lib/ting_yun/support/library_detection.rb', line 103 def depends_on @dependencies << Proc.new end |
#execute ⇒ Object
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 |
#executes ⇒ Object
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 |