Module: Oboe::Inst::MemcachedRails

Defined in:
lib/oboe/inst/memcached.rb

Overview

module Memcached

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(cls) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/oboe/inst/memcached.rb', line 44

def self.included(cls)
  cls.class_eval do
    if ::Memcached::Rails.method_defined? :get_multi
      alias get_multi_without_oboe get_multi
      alias get_multi get_multi_with_oboe
    elsif Oboe::Config[:verbose]
      Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcached.  Partial traces may occur." 
    end
  end
end

Instance Method Details

#get_multi_with_oboe(keys, raw = false) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/oboe/inst/memcached.rb', line 55

def get_multi_with_oboe(keys, raw=false)
  if Oboe.tracing?
    layer_kvs = {}
    layer_kvs[:KVOp] = :get_multi

    Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
      begin
        info_kvs = {}
        info_kvs[:KVKeyCount] = keys.flatten.length 

        values = get_multi_without_oboe(keys, raw)
        
        info_kvs[:KVHitCount] = values.length
        info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcached][:collect_backtraces]

        Oboe::API.log('memcache', 'info', info_kvs)
      rescue
        values = get_multi_without_oboe(keys, raw)
      end
      values 
    end
  else
    get_multi_without_oboe(keys, raw)
  end
end