class FFWD::Metric

A convenience class for each individual metric.

Public Class Methods

make(opts={}) click to toggle source
# File lib/ffwd/metric.rb, line 43
def self.make opts={}
  new(opts[:time], opts[:key], opts[:value], opts[:host], opts[:source],
      opts[:tags], opts[:fixed_tags],
      opts[:attributes], opts[:fixed_attr])
end

Public Instance Methods

attributes() click to toggle source

maintained for backwards compatibility, but implementors are encouraged to use internal/external attributes directly.

# File lib/ffwd/metric.rb, line 51
def attributes
  FFWD.merge_hashes fixed_attr, external_attr
end
tags() click to toggle source
# File lib/ffwd/metric.rb, line 55
def tags
  FFWD.merge_sets fixed_tags, external_tags
end
to_h() click to toggle source

Convert metric to a sparse hash.

# File lib/ffwd/metric.rb, line 60
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

  if t = tags and not t.empty?
    d[:tags] = t
  end

  if a = attributes and not a.empty?
    d[:attributes] = a
  end

  d
end