module Mmtrix::Agent::Instrumentation::Memcache
Constants
- METHODS
Public Instance Methods
enabled?()
click to toggle source
# File lib/mmtrix/agent/instrumentation/memcache.rb, line 16 def enabled? !::Mmtrix::Agent.config[:disable_memcache_instrumentation] end
instrument_methods(client_class, requested_methods = METHODS)
click to toggle source
# File lib/mmtrix/agent/instrumentation/memcache.rb, line 29 def instrument_methods(client_class, requested_methods = METHODS) supported_methods_for(client_class, requested_methods).each do |method_name| visibility = Mmtrix::Helper.instance_method_visibility client_class, method_name method_name_without = :"#{method_name}_without_mmtrix_trace" client_class.class_eval do alias_method method_name_without, method_name define_method method_name do |*args, &block| metrics = Datastores::MetricHelper.metrics_for("Memcached", method_name) Mmtrix::Agent::MethodTracer.trace_execution_scoped(metrics) do t0 = Time.now begin send method_name_without, *args, &block ensure if Mmtrix::Agent.config[:capture_memcache_keys] Mmtrix::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil end end end end send visibility, method_name send visibility, method_name_without end end end
supported_methods_for(client_class, methods)
click to toggle source
# File lib/mmtrix/agent/instrumentation/memcache.rb, line 23 def supported_methods_for(client_class, methods) methods.select do |method_name| client_class.method_defined?(method_name) || client_class.private_method_defined?(method_name) end end