Class: FFWD::Metric

Inherits:
MetricStruct show all
Defined in:
lib/ffwd/metric.rb

Overview

A convenience class for each individual metric.

Instance Attribute Summary

Attributes inherited from MetricStruct

#attributes, #host, #key, #source, #tags, #time, #value

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.make(opts = {}) ⇒ Object



37
38
39
40
# File 'lib/ffwd/metric.rb', line 37

def self.make opts={}
  new(opts[:time], opts[:key], opts[:value], opts[:host], opts[:source],
      opts[:tags], opts[:attributes])
end

Instance Method Details

#to_hObject

Convert metric to a sparse hash.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ffwd/metric.rb', line 43

def to_h
  d = {}
  d[:time] = time.to_i if time
  d[:key] = key if key
  d[:value] = value if value
  d[:host] = host if host
  d[:source] = source if source
  d[:tags] = tags.to_a if tags
  d[:attributes] = attributes if attributes
  d
end