class Fluent::FinagleInput

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_finagle.rb, line 16
def initialize
  super
end

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_finagle.rb, line 20
def configure(conf)
  super
end
run_periodic() click to toggle source

Main loop

# File lib/fluent/plugin/in_finagle.rb, line 44
def run_periodic
  until @finished
    sleep @run_interval

    begin
      response = @conn.get '/admin/metrics.json'
      json_response = JSON.parse(response.body)

      @metrics.split(",").each do |metric|
        router.emit(
          "#{@tag}.#{metric.gsub("/", "_")}",
          Engine.now.to_i,
          {"value" => json_response[metric]}
        )
      end
    rescue => e
      $log.warn "Failed to get Finagle metrics, but ignored: #{e.message}"
    end

  end
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_finagle.rb, line 35
def shutdown
  @finished = true
  @thread.join
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_finagle.rb, line 24
def start
  super
  @finished = false
  @thread = Thread.new(&method(:run_periodic))
  @conn = Faraday.new(:url => "http://#{@finagle_host}:#{@finagle_port}") do |faraday|
    faraday.request  :url_encoded             # form-encode POST params
    faraday.response :logger                  # log requests to STDOUT
    faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
  end
end