Module: OneApm::Agent::Instrumentation::Memcache
- Defined in:
- lib/one_apm/inst/nosql/memcache.rb
Constant Summary collapse
- OA_METHODS =
[:get, :get_multi, :set, :add, :incr, :decr, :delete, :replace, :append, :prepend, :cas, :single_get, :multi_get, :single_cas, :multi_cas]
Class Method Summary collapse
- .enabled? ⇒ Boolean
- .instrument_methods(client_class, requested_methods = OA_METHODS) ⇒ Object
- .supported_methods_for(client_class, methods) ⇒ Object
Class Method Details
.enabled? ⇒ Boolean
11 12 13 |
# File 'lib/one_apm/inst/nosql/memcache.rb', line 11 def enabled? !OneApm::Manager.config[:disable_memcache] end |
.instrument_methods(client_class, requested_methods = OA_METHODS) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/one_apm/inst/nosql/memcache.rb', line 24 def instrument_methods(client_class, requested_methods = OA_METHODS) supported_methods_for(client_class, requested_methods).each do |method_name| visibility = OneApm::Helper.instance_method_visibility client_class, method_name method_name_without = :"#{method_name}_without_oneapm_trace" client_class.class_eval do alias_method method_name_without, method_name define_method method_name do |*args, &block| metrics = Datastore::MetricHelper.metrics_for("Memcached", method_name) OneApm::Support::MethodTracer.trace_execution_scoped(metrics) do t0 = Time.now begin send method_name_without, *args, &block ensure if OneApm::Manager.config[:capture_memcache_keys] OneApm::Manager.agent.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) ⇒ Object
18 19 20 21 22 |
# File 'lib/one_apm/inst/nosql/memcache.rb', line 18 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 |