class FFWD::Plugin::Carbon::Connection

Public Class Methods

new(bind, core, config) click to toggle source
# File lib/ffwd/plugin/carbon/connection.rb, line 23
def initialize bind, core, config
  @bind = bind
  @core = core
  @key = config[:key]
end

Public Instance Methods

parse(line) click to toggle source
# File lib/ffwd/plugin/carbon/connection.rb, line 29
def parse line
  path, value, timestamp = line.split ' ', 3
  raise "invalid frame" if timestamp.nil?

  return nil if path.empty? or value.empty? or timestamp.empty?

  value = value.to_f unless value.nil?
  time = Time.at(timestamp.to_i)

  a = {:what => path}

  return {:key => @key, :value => value, :time => time, :attributes => a}
end
receive_line(line) click to toggle source
# File lib/ffwd/plugin/carbon/connection.rb, line 43
def receive_line line
  metric = parse line
  return if metric.nil?
  @core.input.metric metric
  @bind.increment :received_metrics
rescue => e
  @bind.log.error "Failed to receive data", e
  @bind.increment :failed_metrics
end