module NewRelic::Agent::Instrumentation::Memcache::Helper

Constants

BINARY_PROTOCOL_SUPPORTED_VERSION
DATASTORE_INSTANCES_SUPPORTED_VERSION

Public Instance Methods

client_methods() click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/helper.rb, line 19
def client_methods
  [:get, :get_multi, :set, :add, :incr, :decr, :delete, :replace, :append,
    :prepend, :cas, :single_get, :multi_get, :single_cas, :multi_cas]
end
dalli_cas_methods() click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/helper.rb, line 28
def dalli_cas_methods
  [:get_cas, :set_cas, :replace_cas, :delete_cas]
end
dalli_methods() click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/helper.rb, line 24
def dalli_methods
  [:get, :set, :add, :incr, :decr, :delete, :replace, :append, :prepend, :cas]
end
instrument_methods(client_class, requested_methods = METHODS) click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/helper.rb, line 38
def instrument_methods(client_class, requested_methods = METHODS)
  supported_methods_for(client_class, requested_methods).each do |method_name|
    visibility = NewRelic::Helper.instance_method_visibility(client_class, method_name)
    method_name_without = :"#{method_name}_without_newrelic_trace"

    client_class.class_eval do
      include NewRelic::Agent::Instrumentation::Memcache::Tracer

      alias_method(method_name_without, method_name)

      define_method(method_name) do |*args, &block|
        with_newrelic_tracing(method_name, *args) { __send__(method_name_without, *args, &block) }
      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/new_relic/agent/instrumentation/memcache/helper.rb, line 32
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
supports_binary_protocol?() click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/helper.rb, line 15
def supports_binary_protocol?
  BINARY_PROTOCOL_SUPPORTED_VERSION <= Gem::Version.new(::Dalli::VERSION)
end
supports_datastore_instances?() click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/helper.rb, line 11
def supports_datastore_instances?
  DATASTORE_INSTANCES_SUPPORTED_VERSION <= Gem::Version.new(::Dalli::VERSION)
end