Sha256: cf9be8a8ee31ae9f8bf3f081d823644230fb82d5cd4e3e41c4f46bee6a78a030
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 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 t0 = Time.now begin #{method_name}_without_newrelic_trace(*args) ensure #{memcache_key_snippet(method_name)} end end end alias #{method_name}_without_newrelic_trace #{method_name} alias #{method_name} #{method_name}_with_newrelic_trace EOD end def self.memcache_key_snippet(method_name) return "" unless NewRelic::Control.instance['capture_memcache_keys'] "NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil" end %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
3 entries across 3 versions & 1 rubygems