Class: Wavefront::Response::Graphite

Inherits:
Ruby
  • Object
show all
Includes:
Mixins
Defined in:
lib/wavefront/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins

#call_delete, #call_get, #call_post, #hash_to_qs, #interpolate_schema, #load_file, #parse_time, #time_to_ms, #uri_concat

Constructor Details

#initialize(response, options = {}) ⇒ Graphite

Returns a new instance of Graphite.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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

Instance Attribute Details

#graphiteObject (readonly)

Returns the value of attribute graphite.



57
58
59
# File 'lib/wavefront/response.rb', line 57

def graphite
  @graphite
end

#optionsObject (readonly)

Returns the value of attribute options.



57
58
59
# File 'lib/wavefront/response.rb', line 57

def options
  @options
end

#responseObject (readonly)

Returns the value of attribute response.



57
58
59
# File 'lib/wavefront/response.rb', line 57

def response
  @response
end