Class: Metrix::Metric
- Inherits:
-
Object
- Object
- Metrix::Metric
- Defined in:
- lib/metrix/metric.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #database ⇒ Object
- #graphite_prefix ⇒ Object
-
#initialize(key, value, time, tags = {}) ⇒ Metric
constructor
A new instance of Metric.
- #to_graphite ⇒ Object
- #to_opentsdb ⇒ Object
Constructor Details
#initialize(key, value, time, tags = {}) ⇒ Metric
Returns a new instance of Metric.
7 8 9 10 11 12 |
# File 'lib/metrix/metric.rb', line 7 def initialize(key, value, time, = {}) @key = key @value = value @time = time @tags = end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/metrix/metric.rb', line 5 def key @key end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
5 6 7 |
# File 'lib/metrix/metric.rb', line 5 def @tags end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/metrix/metric.rb', line 5 def time @time end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/metrix/metric.rb', line 5 def value @value end |
Instance Method Details
#database ⇒ Object
29 30 31 |
# File 'lib/metrix/metric.rb', line 29 def database [:database] end |
#graphite_prefix ⇒ Object
33 34 35 |
# File 'lib/metrix/metric.rb', line 33 def graphite_prefix "metrix.#{Metrix.hostname}" end |
#to_graphite ⇒ Object
22 23 24 25 26 27 |
# File 'lib/metrix/metric.rb', line 22 def to_graphite chunks = [graphite_prefix] chunks << "databases.#{database}" if database chunks << key "#{chunks.join(".")} #{value} #{time.utc.to_i}" end |