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

#interpolate_schema

Constructor Details

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

Returns a new instance of Graphite.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/wavefront/response.rb', line 58

def initialize(response, options={})
  super
  options[:prefix_length] ||= 1     # See also Wavefront::Client
  
  @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.



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

def graphite
  @graphite
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end