Class: Harness::Measurement
- Inherits:
-
Struct
- Object
- Struct
- Harness::Measurement
- Defined in:
- lib/harness.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
10 11 12 |
# File 'lib/harness.rb', line 10 def name @name end |
#rate ⇒ Object
Returns the value of attribute rate
10 11 12 |
# File 'lib/harness.rb', line 10 def rate @rate end |
#value ⇒ Object
Returns the value of attribute value
10 11 12 |
# File 'lib/harness.rb', line 10 def value @value end |
Class Method Details
.from_event(event) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/harness.rb', line 11 def self.from_event(event) payload = event.payload value = payload.fetch name.split('::').last.downcase.to_sym case value when true new event.name when Fixnum new event.name, value when String new value when Hash new(value[:name] || event.name, value[:value], value[:rate]) end end |
Instance Method Details
#sample_rate ⇒ Object
27 28 29 |
# File 'lib/harness.rb', line 27 def sample_rate rate.nil? ? 1 : rate end |