Class: Neutrino::Client::Metric

Inherits:
Hashie::Dash
  • Object
show all
Defined in:
lib/neutrino/metric.rb

Direct Known Subclasses

MuninMetric, ShellMetric

Instance Method Summary collapse

Instance Method Details

#metric_idObject



16
17
18
# File 'lib/neutrino/metric.rb', line 16

def metric_id
  Digest::MD5.hexdigest("#{name}#{hostname}")
end

#to_hObject

Raises:

  • (StandardError)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/neutrino/metric.rb', line 24

def to_h
  raise StandardError.new("Requires name") unless name
  raise StandardError.new("Requires values") unless values
  raise StandardError.new("Requires hostname") unless hostname
  {
    :metadata => ( || {}).merge({
      :name => self.name,
      :group => self.group,
      :type => self.type,
      :hostname => self.hostname
    }),
    :display_options => self.display_options,
    :name => self.metric_id,
    :values => self.values || {}
  }
end

#to_jsonObject



20
21
22
# File 'lib/neutrino/metric.rb', line 20

def to_json
  to_h.to_json
end