module Oboe::Inst::Memcached
Public Class Methods
included(cls)
click to toggle source
# File lib/oboe/inst/memcached.rb, line 9 def self.included(cls) Oboe.logger.info '[oboe/loading] Instrumenting memcached' if Oboe::Config[:verbose] cls.class_eval do MEMCACHE_OPS.reject { |m| !method_defined?(m) }.each do |m| define_method("#{m}_with_oboe") do |*args| opts = { :KVOp => m } if args.length && !args[0].is_a?(Array) opts[:KVKey] = args[0].to_s rhost = remote_host(args[0].to_s) opts[:RemoteHost] = rhost if rhost end Oboe::API.trace('memcache', opts) do result = send("#{m}_without_oboe", *args) info_kvs = {} info_kvs[:KVHit] = memcache_hit?(result) if m == :get && args.length && args[0].class == String info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcached][:collect_backtraces] Oboe::API.log('memcache', 'info', info_kvs) unless info_kvs.empty? result end end class_eval "alias #{m}_without_oboe #{m}" class_eval "alias #{m} #{m}_with_oboe" end end end