Class: LibraryDetection::Dependent
- Inherits:
-
Object
- Object
- LibraryDetection::Dependent
- Defined in:
- lib/one_apm/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.
58 59 60 61 62 |
# File 'lib/one_apm/support/library_detection.rb', line 58 def initialize @dependencies = [] @executes = [] @name = nil end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
56 57 58 |
# File 'lib/one_apm/support/library_detection.rb', line 56 def dependencies @dependencies end |
#executed ⇒ Object (readonly)
Returns the value of attribute executed.
50 51 52 |
# File 'lib/one_apm/support/library_detection.rb', line 50 def executed @executed end |
#name ⇒ Object
Returns the value of attribute name.
51 52 53 |
# File 'lib/one_apm/support/library_detection.rb', line 51 def name @name end |
Instance Method Details
#allowed_by_config? ⇒ Boolean
98 99 100 101 102 103 104 105 106 107 108 109 |
# 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 ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# 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? ⇒ Boolean
64 65 66 |
# File 'lib/one_apm/support/library_detection.rb', line 64 def dependencies_satisfied? !executed and check_dependencies end |
#depends_on ⇒ Object
94 95 96 |
# File 'lib/one_apm/support/library_detection.rb', line 94 def depends_on @dependencies << Proc.new end |
#execute ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# 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! ⇒ Object
52 53 54 |
# File 'lib/one_apm/support/library_detection.rb', line 52 def executed! @executed = true end |
#executes ⇒ Object
115 116 117 |
# File 'lib/one_apm/support/library_detection.rb', line 115 def executes @executes << Proc.new end |
#named(new_name) ⇒ Object
111 112 113 |
# File 'lib/one_apm/support/library_detection.rb', line 111 def named(new_name) self.name = new_name end |