lib/oboe/inst/memcache.rb in oboe-2.3.4.1 vs lib/oboe/inst/memcache.rb in oboe-2.4.0.1
- old
+ new
@@ -27,83 +27,70 @@
end
class_eval "alias #{m}_without_oboe #{m}"
class_eval "alias #{m} #{m}_with_oboe"
end
-
+ end
+
+ [:request_setup, :cache_get, :get_multi].each do |m|
if ::MemCache.method_defined? :request_setup
- alias request_setup_without_oboe request_setup
- alias request_setup request_setup_with_oboe
+ cls.class_eval "alias #{m}_without_oboe #{m}"
+ cls.class_eval "alias #{m} #{m}_with_oboe"
elsif Oboe::Config[:verbose]
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
+ Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache: #{m}"
end
-
- if ::MemCache.method_defined? :cache_get
- alias cache_get_without_oboe cache_get
- alias cache_get cache_get_with_oboe
- elsif Oboe::Config[:verbose]
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
- end
-
- if ::MemCache.method_defined? :get_multi
- alias get_multi_without_oboe get_multi
- alias get_multi get_multi_with_oboe
- elsif Oboe::Config[:verbose]
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
- end
end
end
def get_multi_with_oboe(*args)
- if Oboe.tracing?
- layer_kvs = {}
- layer_kvs[:KVOp] = :get_multi
-
- Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
- begin
- info_kvs = {}
- info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
-
- if args.last.is_a?(Hash) || args.last.nil?
- info_kvs[:KVKeyCount] = args.flatten.length - 1
- else
- info_kvs[:KVKeyCount] = args.flatten.length
- end
-
- values = get_multi_without_oboe(args)
-
- info_kvs[:KVHitCount] = values.length
- Oboe::API.log('memcache', 'info', info_kvs)
- rescue
- values = get_multi_without_oboe(args)
- end
- values
+ return get_multi_without_oboe(args) unless Oboe.tracing?
+
+ info_kvs = {}
+
+ begin
+ info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
+
+ if args.last.is_a?(Hash) || args.last.nil?
+ info_kvs[:KVKeyCount] = args.flatten.length - 1
+ else
+ info_kvs[:KVKeyCount] = args.flatten.length
end
- else
- get_multi_without_oboe(args)
+ rescue StandardError => e
+ Oboe.logger.debug "[oboe/debug] Error collecting info keys: #{e.message}"
+ Oboe.logger.debug e.backtrace
end
+
+ Oboe::API.trace('memcache', {:KVOp => :get_multi}, :get_multi) do
+ values = get_multi_without_oboe(args)
+
+ info_kvs[:KVHitCount] = values.length
+ Oboe::API.log('memcache', 'info', info_kvs)
+
+ values
+ end
end
def request_setup_with_oboe(*args)
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
server, cache_key = request_setup_without_oboe(*args)
-
+
info_kvs = { :KVKey => cache_key, :RemoteHost => server.host }
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
-
Oboe::API.log('memcache', 'info', info_kvs)
+
+ [server, cache_key]
else
- server, cache_key = request_setup_without_oboe(*args)
+ request_setup_without_oboe(*args)
end
- return [server, cache_key]
end
def cache_get_with_oboe(server, cache_key)
result = cache_get_without_oboe(server, cache_key)
info_kvs = { :KVHit => memcache_hit?(result) }
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
Oboe::API.log('memcache', 'info', info_kvs)
+
result
end
end # module MemCache
end # module Inst