Class: Panoptimon::Metric

Inherits:
Hash
  • Object
show all
Defined in:
lib/panoptimon/collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, data) ⇒ Metric

Returns a new instance of Metric.



60
61
62
63
# File 'lib/panoptimon/collector.rb', line 60

def initialize (name, data)
  name = data.delete('_name') if data['_name']
  self.merge!(_flatten_hash({}, name, data))
end

Instance Method Details

#_flatten_hash(i, p, h) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/panoptimon/collector.rb', line 65

def _flatten_hash (i,p,h)
  h.each {|k,v|
    ok = "#{p}|#{k}"
    # TODO reject non-numeric data?
    if k != '_info' and v.is_a?(Hash)
      _flatten_hash(i, ok, v)
    else
      i[ok] = v
    end
  }
  return i
end