Module: Oboe::Inst::Dalli
Constant Summary
API::Memcache::MEMCACHE_OPS
Class Method Summary
collapse
Instance Method Summary
collapse
#memcache_hit?, #remote_host
Class Method Details
.included(cls) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/oboe/inst/dalli.rb', line 9
def self.included(cls)
cls.class_eval do
Oboe.logger.info "[oboe/loading] Instrumenting memcache (dalli)" if Oboe::Config[:verbose]
if ::Dalli::Client.private_method_defined? :perform
alias perform_without_oboe perform
alias perform perform_with_oboe
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache (Dalli). Partial traces may occur."
end
if ::Dalli::Client.method_defined? :get_multi
alias get_multi_without_oboe get_multi
alias get_multi get_multi_with_oboe
end
end
end
|
Instance Method Details
#get_multi_with_oboe(*keys) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/oboe/inst/dalli.rb', line 48
def get_multi_with_oboe(*keys)
if Oboe.tracing?
layer_kvs = {}
layer_kvs[:KVOp] = :get_multi
Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
begin
info_kvs = {}
if keys.last.is_a?(Hash) || keys.last.nil?
info_kvs[:KVKeyCount] = keys.flatten.length - 1
else
info_kvs[:KVKeyCount] = keys.flatten.length
end
values = get_multi_without_oboe(keys)
info_kvs[:KVHitCount] = values.length
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:dalli][:collect_backtraces]
Oboe::API.log('memcache', 'info', info_kvs)
rescue
values = get_multi_without_oboe(keys)
end
values
end
else
get_multi_without_oboe(keys)
end
end
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/oboe/inst/dalli.rb', line 25
def perform_with_oboe(*all_args, &blk)
op, key, *args = *all_args
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
opts = {}
opts[:KVOp] = op
opts[:KVKey] = key
Oboe::API.trace('memcache', opts || {}) do
result = perform_without_oboe(*all_args, &blk)
info_kvs = {}
info_kvs[:KVHit] = memcache_hit?(result) if op == :get and key.class == String
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:dalli][:collect_backtraces]
Oboe::API.log('memcache', 'info', info_kvs) unless info_kvs.empty?
result
end
else
perform_without_oboe(*all_args, &blk)
end
end
|