lib/one_apm/inst/nosql/redis.rb in oneapm_rpm-1.3.7 vs lib/one_apm/inst/nosql/redis.rb in oneapm_rpm-1.4.0
- old
+ new
@@ -19,18 +19,23 @@
::Redis::Client.class_eval do
# Support older versions of Redis::Client that used the method
# +raw_call_command+.
call_method = ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
+
+ def oneapm_product
+ @product ||= OneApm::Agent::Datastore.oneapm_product("Redis", host, port)
+ end
+ private :oneapm_product
def call_with_oneapm_trace(*args, &blk)
method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
filtered_command = filter method_name
callback = proc do |result, metric, elapsed|
_send_to_one_apm(args, elapsed)
end
- OneApm::Agent::Datastore.wrap("Redis", filtered_command, nil, callback) do
+ OneApm::Agent::Datastore.wrap(oneapm_product, filtered_command, nil, callback) do
call_without_oneapm_trace(*args, &blk)
end
end
alias_method :call_without_oneapm_trace, call_method
@@ -43,11 +48,11 @@
def call_pipelined_with_oneapm_trace(commands, *rest)
# Report each command as a metric suffixed with _pipelined, so the
# user can at least see what all the commands were.
additional = commands.map do |c|
name = c.kind_of?(Array) ? c[0] : c
- "Datastore/operation/Redis/#{name.to_s.downcase}_pipelined"
+ "Datastore/operation/#{oneapm_product}/#{name.to_s.downcase}_pipelined"
end
callback = proc do |result, metric, elapsed|
_send_to_one_apm(commands, elapsed)
additional.each do |additional_metric|
@@ -55,10 +60,10 @@
# No-op, just getting them as placeholders in the trace tree
end
end
end
- OneApm::Agent::Datastore.wrap("Redis", "pipelined", nil, callback) do
+ OneApm::Agent::Datastore.wrap(oneapm_product, 'pipelined', nil, callback) do
call_pipelined_without_oneapm_trace commands, *rest
end
end
alias_method :call_pipelined_without_oneapm_trace, :call_pipelined