class Wavefront::Response::Graphite

Attributes

graphite[R]
options[R]
response[R]

Public Class Methods

new(response, options={}) click to toggle source
Calls superclass method Wavefront::Response::Ruby::new
# File lib/wavefront/response.rb, line 59
def initialize(response, options={})
  super
  options[:prefix_length] ||= Wavefront::Client::DEFAULT_PREFIX_LENGTH

  @graphite = Array.new
  self.timeseries.each do |ts|

    output_timeseries = Hash.new
    output_timeseries['target'] = interpolate_schema(ts['label'], ts['host'], options[:prefix_length])

    datapoints = Array.new
    ts['data'].each do |d|
      datapoints << [d[1], d[0]]
    end

    output_timeseries['datapoints'] = datapoints
    @graphite << output_timeseries

  end
end