Module: LeelaClient::Metric
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
20 21 22 |
# File 'lib/leela_client/metrics.rb', line 20 def key @key end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
22 23 24 |
# File 'lib/leela_client/metrics.rb', line 22 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
19 20 21 |
# File 'lib/leela_client/metrics.rb', line 19 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
21 22 23 |
# File 'lib/leela_client/metrics.rb', line 21 def value @value end |
Instance Method Details
#serialize ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/leela_client/metrics.rb', line 24 def serialize size = @key.size time = .to_f.to_s if (@value.integer?) value = @value.to_f.to_s elsif (@value.nan?) value = "nan" elsif (@value.infinite? == 1) value = "inf" elsif (@value.infinite? == -1) value = "-inf" else value = @value.to_s end "#{@type} #{size}|#{@key} #{value} #{time};" end |
#serialize_json ⇒ Object
42 43 44 45 |
# File 'lib/leela_client/metrics.rb', line 42 def serialize_json time = .to_f.to_s {:name => @key, :type => @type, :value => @value, :timestamp => time} end |
#size ⇒ Object
47 48 49 |
# File 'lib/leela_client/metrics.rb', line 47 def size self.serialize.size end |