class MyStuff::Fb303::ProxyHandler

Public Class Methods

new(server) click to toggle source
# File lib/my_stuff/fb303/proxy_handler.rb, line 6
def initialize server
  @s = server
end

Public Instance Methods

method_missing(meth, *args) click to toggle source
# File lib/my_stuff/fb303/proxy_handler.rb, line 10
def method_missing meth, *args
  @s.increment_counter "#{meth}.called"
  begin
    result = @s.send(meth, *args)
    @s.increment_counter "#{meth}.success"
    result
  rescue => e
    @s.increment_counter "#{meth}.exception"
    @s.increment_counter "#{meth}.exception.#{e.class.name}"

    if e.is_a? Thrift::Exception
      # Presumably defined in the Thrift interface file
      level = :warn
    else
      # Definitely not :(
      level = :error
    end

    begin
      # MyStuff::Logger exception, allowing us to specify the
      # backtrace.
      @s.logger.raw_log e.backtrace, level, e
    rescue NoMethodError
      @s.logger.send level, e
    end

    raise
  end
end