Class: D13n::Metric::Instrumentation::Conductor::Performance
- Inherits:
-
Object
- Object
- D13n::Metric::Instrumentation::Conductor::Performance
- Defined in:
- lib/d13n/metric/conductor.rb
Instance Attribute Summary collapse
-
#dependences ⇒ Object
readonly
Returns the value of attribute dependences.
-
#name ⇒ Object
Returns the value of attribute name.
-
#performed ⇒ Object
readonly
Returns the value of attribute performed.
Instance Method Summary collapse
- #allowed_by_config? ⇒ Boolean
- #check_dependences ⇒ Object
- #depend_on ⇒ Object
-
#initialize ⇒ Performance
constructor
A new instance of Performance.
- #named(new_name) ⇒ Object
- #perform ⇒ Object
- #perform! ⇒ Object
- #performances ⇒ Object
- #ready? ⇒ Boolean
Constructor Details
#initialize ⇒ Performance
Returns a new instance of Performance.
61 62 63 64 65 |
# File 'lib/d13n/metric/conductor.rb', line 61 def initialize @dependences = [] @performances = [] @name = nil end |
Instance Attribute Details
#dependences ⇒ Object (readonly)
Returns the value of attribute dependences.
59 60 61 |
# File 'lib/d13n/metric/conductor.rb', line 59 def dependences @dependences end |
#name ⇒ Object
Returns the value of attribute name.
53 54 55 |
# File 'lib/d13n/metric/conductor.rb', line 53 def name @name end |
#performed ⇒ Object (readonly)
Returns the value of attribute performed.
52 53 54 |
# File 'lib/d13n/metric/conductor.rb', line 52 def performed @performed end |
Instance Method Details
#allowed_by_config? ⇒ Boolean
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/d13n/metric/conductor.rb', line 101 def allowed_by_config? return true if self.name.nil? key = "instrumentation.#{self.name}.disable".to_sym if (D13n.config[key] == true) D13n.logger.debug("Not setting up #{self.name} instrumentation for configuration #{key}") false else true end end |
#check_dependences ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/d13n/metric/conductor.rb', line 88 def check_dependences return false unless allowed_by_config? && dependences dependences.all? do |score| begin score.call rescue => e D13n.logger.error("Error while checking #{self.name}:", e) false end end end |
#depend_on ⇒ Object
84 85 86 |
# File 'lib/d13n/metric/conductor.rb', line 84 def depend_on @dependences << Proc.new end |
#named(new_name) ⇒ Object
114 115 116 |
# File 'lib/d13n/metric/conductor.rb', line 114 def named(new_name) self.name = new_name end |
#perform ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/d13n/metric/conductor.rb', line 71 def perform @performances.each do |p| begin p.call rescue => e D13n.logger.error("Error while setting up #{self.name} instrumentation:", e) break end end ensure perform! end |
#perform! ⇒ Object
55 56 57 |
# File 'lib/d13n/metric/conductor.rb', line 55 def perform! @performed = true end |
#performances ⇒ Object
118 119 120 |
# File 'lib/d13n/metric/conductor.rb', line 118 def performances @performances << Proc.new end |
#ready? ⇒ Boolean
67 68 69 |
# File 'lib/d13n/metric/conductor.rb', line 67 def ready? !performed and check_dependences end |