Module: NewRelic::Agent::Instrumentation::Memcache::Dalli
- Extended by:
- Helper
- Included in:
- DalliCAS
- Defined in:
- lib/new_relic/agent/instrumentation/memcache/dalli.rb
Class Method Summary
collapse
Methods included from Helper
correctly_encoded, executable_in_path?, instance_method_visibility, instance_methods_include?, normalize_version, rubygems_specs, run_command, time_to_millis, version_equals?, version_greater_than?, version_less_than?, version_satisfied?
Class Method Details
.instrument! ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/new_relic/agent/instrumentation/memcache/dalli.rb', line 14
def instrument!
if supports_datastore_instances?
instrument_methods(::Dalli::Client, dalli_methods)
instrument_multi_method(:get_multi)
instrument_send_multiget
instrument_read_multi_req if supports_read_multi_req?
instrument_server_for_key
else
instrument_methods(::Dalli::Client, client_methods)
end
end
|
.instrument_multi_method(method_name) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/new_relic/agent/instrumentation/memcache/dalli.rb', line 26
def instrument_multi_method(method_name)
visibility = NewRelic::Helper.instance_method_visibility(::Dalli::Client, method_name)
method_name_without = :"#{method_name}_without_newrelic_trace"
::Dalli::Client.class_eval do
alias_method(method_name_without, method_name)
define_method(method_name) do |*args, &block|
get_multi_with_newrelic_tracing(method_name) { __send__(method_name_without, *args, &block) }
end
__send__(visibility, method_name)
__send__(visibility, method_name_without)
end
end
|
.instrument_read_multi_req ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/new_relic/agent/instrumentation/memcache/dalli.rb', line 54
def instrument_read_multi_req
::Dalli::Protocol::Meta.class_eval do
include NewRelic::Agent::Instrumentation::Memcache::Tracer
alias_method(:read_multi_req_without_newrelic_trace, :read_multi_req)
def read_multi_req(keys)
send_multiget_with_newrelic_tracing(keys) { read_multi_req_without_newrelic_trace(keys) }
end
end
end
|
.instrument_send_multiget ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/new_relic/agent/instrumentation/memcache/dalli.rb', line 66
def instrument_send_multiget
if supports_meta_protocol?
::Dalli::Protocol::Base
elsif supports_binary_protocol?
::Dalli::Protocol::Binary
else
::Dalli::Server
end.class_eval do
include NewRelic::Agent::Instrumentation::Memcache::Tracer
if NewRelic::Helper.version_satisfied?(::Dalli::VERSION, '>=', '3.1.0')
alias_method(:pipelined_get_without_newrelic_trace, :pipelined_get)
def pipelined_get(keys)
send_multiget_with_newrelic_tracing(keys) { pipelined_get_without_newrelic_trace(keys) }
end
else
alias_method(:send_multiget_without_newrelic_trace, :send_multiget)
def send_multiget(keys)
send_multiget_with_newrelic_tracing(keys) { send_multiget_without_newrelic_trace(keys) }
end
end
end
end
|
.instrument_server_for_key ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/new_relic/agent/instrumentation/memcache/dalli.rb', line 42
def instrument_server_for_key
::Dalli::Ring.class_eval do
include NewRelic::Agent::Instrumentation::Memcache::Tracer
alias_method(:server_for_key_without_newrelic_trace, :server_for_key)
def server_for_key(key)
server_for_key_with_newrelic_tracing { server_for_key_without_newrelic_trace(key) }
end
end
end
|