Sha256: 67e01667280b0dfbc4c2c6244f72a013c06eff60e08c42f506f3e8efbc3c1b88

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

# NOTE there are multiple implementations of the MemCache client in Ruby,
# each with slightly different API's and semantics.  
# See:
#     http://www.deveiate.org/code/Ruby-MemCache/ (Gem: Ruby-MemCache)
#     http://seattlerb.rubyforge.org/memcache-client/ (Gem: memcache-client)
unless NewRelic::Control.instance['disable_memcache_instrumentation']
  
  def self.instrument_method(the_class, method_name)
    return unless the_class.method_defined? method_name.to_sym
    the_class.class_eval <<-EOD
        def #{method_name}_with_newrelic_trace(*args)
          metrics = ["MemCache/#{method_name}", 
                     (NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'MemCache/allWeb' : 'MemCache/allOther')]
          self.class.trace_execution_scoped(metrics) do
            #{method_name}_without_newrelic_trace(*args)
          end
        end
        alias #{method_name}_without_newrelic_trace #{method_name}
        alias #{method_name} #{method_name}_with_newrelic_trace
    EOD
  end
  # Support for libmemcached through Evan Weaver's memcached wrapper
  # http://blog.evanweaver.com/files/doc/fauna/memcached/classes/Memcached.html    
  %w[get get_multi set add incr decr delete replace append prepand cas].each do | method_name |
    instrument_method(::MemCache, method_name) if defined? ::MemCache  
    instrument_method(::Memcached, method_name) if defined? ::Memcached  
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
newrelic_rpm-2.12.3 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.12.2 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.12.2.beta2 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.12.2.beta lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.12.1 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.12.1.alpha lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.12.0 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.3 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.2 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.2.beta2 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.2.beta lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.1 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.0.beta2 lib/new_relic/agent/instrumentation/memcache.rb
newrelic_rpm-2.11.0.beta lib/new_relic/agent/instrumentation/memcache.rb