Skip to content
Browse files

Pass a block through to call properly. Fixes #5

  • Loading branch information...
1 parent 1c08393 commit c17d5a261252717557df7c0090ce310ba6a29869 @evanphx committed May 18, 2012
Showing with 16 additions and 2 deletions.
  1. +2 −2 lib/newrelic_redis/instrumentation.rb
  2. +14 −0 test/test_newrelic_redis.rb
View
4 lib/newrelic_redis/instrumentation.rb
@@ -20,7 +20,7 @@
call_method =
::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
- def call_with_newrelic_trace(*args)
+ def call_with_newrelic_trace(*args, &blk)
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
total_metric = 'Database/Redis/allWeb'
else
@@ -34,7 +34,7 @@ def call_with_newrelic_trace(*args)
start = Time.now
begin
- call_without_newrelic_trace(*args)
+ call_without_newrelic_trace(*args, &blk)
ensure
s = NewRelic::Agent.instance.transaction_sampler
s.notice_nosql(args.inspect, (Time.now - start).to_f) rescue nil
View
14 test/test_newrelic_redis.rb
@@ -55,4 +55,18 @@ def test_call_pipelined
prm = @sampler.builder.current_segment.params
assert_equal "[[:select, 15]];\n[[:hgetall, \"foo\"], [:incr, \"bar\"]]", prm[:key]
end
+
+ def test_call_with_block
+ rep = nil
+
+ @redis.client.call [:info] do |reply|
+ rep = reply
+ end
+
+ if Redis::VERSION.split(".").first.to_i >= 3
+ assert_kind_of String, rep
+ else
+ assert_nil rep
+ end
+ end
end

0 comments on commit c17d5a2

Please sign in to comment.
Something went wrong with that request. Please try again.