newrelic-redis 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,14 @@ NewRelic::Agent.logger.debug 'Installing Redis instrumentation'
30
30
  metrics = ["Database/Redis/#{method_name.to_s.upcase}", total_metric]
31
31
 
32
32
  self.class.trace_execution_scoped(metrics) do
33
- call_without_newrelic_trace(*args)
33
+ start = Time.now
34
+
35
+ begin
36
+ call_without_newrelic_trace(*args)
37
+ ensure
38
+ s = NewRelic::Agent.instance.transaction_sampler
39
+ s.notice_nosql(args.inspect, (Time.now - start).to_f) rescue nil
40
+ end
34
41
  end
35
42
  end
36
43
 
@@ -52,7 +59,7 @@ NewRelic::Agent.logger.debug 'Installing Redis instrumentation'
52
59
  # can at least see what all the commands were. This prevents
53
60
  # metric namespace explosion.
54
61
 
55
- metrics = [total_metric, "Database/Redis/Pipelined"]
62
+ metrics = ["Database/Redis/Pipelined", total_metric]
56
63
 
57
64
  commands.each do |c|
58
65
  name = c.kind_of?(Array) ? c[0] : c
@@ -60,7 +67,14 @@ NewRelic::Agent.logger.debug 'Installing Redis instrumentation'
60
67
  end
61
68
 
62
69
  self.class.trace_execution_scoped(metrics) do
63
- call_pipelined_without_newrelic_trace commands, options
70
+ start = Time.now
71
+
72
+ begin
73
+ call_pipelined_without_newrelic_trace commands, options
74
+ ensure
75
+ s = NewRelic::Agent.instance.transaction_sampler
76
+ s.notice_nosql(commands.inspect, (Time.now - start).to_f) rescue nil
77
+ end
64
78
  end
65
79
  end
66
80
 
@@ -1,3 +1,3 @@
1
1
  class NewRelicRedis
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "newrelic-redis"
5
- s.version = "1.0.0"
5
+ s.version = "1.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Phoenix"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = "Redis instrumentation for Newrelic."
11
11
  s.email = ["evan@phx.io"]
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
13
- s.files = [".autotest", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/newrelic_redis.rb", "lib/newrelic_redis/instrumentation.rb", "lib/newrelic_redis/version.rb", "test/test_newrelic_redis.rb", ".gemtest"]
13
+ s.files = [".autotest", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/newrelic-redis.rb", "lib/newrelic_redis/instrumentation.rb", "lib/newrelic_redis/version.rb", "newrelic-redis.gemspec", "test/test_newrelic_redis.rb", ".gemtest"]
14
14
  s.homepage = "http://github.com/evanphx/newrelic-redis"
15
15
  s.rdoc_options = ["--main", "README.txt"]
16
16
  s.require_paths = ["lib"]
@@ -26,6 +26,11 @@ class TestNewRelicRedis < Test::Unit::TestCase
26
26
  @engine = NewRelic::Agent.instance.stats_engine
27
27
  @engine.clear_stats
28
28
 
29
+ @sampler = NewRelic::Agent.instance.transaction_sampler
30
+ @sampler.enable
31
+ @sampler.reset!
32
+ @sampler.start_builder
33
+
29
34
  @redis = Redis.new :path => "/tmp/redis"
30
35
  @client = @redis.client
31
36
  class << @client
@@ -33,6 +38,10 @@ class TestNewRelicRedis < Test::Unit::TestCase
33
38
  end
34
39
  end
35
40
 
41
+ def teardown
42
+ @sampler.clear_builder
43
+ end
44
+
36
45
  def assert_metrics(*m)
37
46
  assert_equal m.sort, @engine.metrics.sort
38
47
  end
@@ -41,6 +50,9 @@ class TestNewRelicRedis < Test::Unit::TestCase
41
50
  @redis.hgetall "foo"
42
51
  assert_equal [[[:hgetall, "foo"]]], @client.process_args
43
52
  assert_metrics "Database/Redis/HGETALL", "Database/Redis/allOther"
53
+
54
+ prm = @sampler.builder.current_segment.params
55
+ assert_equal "[[:hgetall, \"foo\"]]", prm[:key]
44
56
  end
45
57
 
46
58
  def test_call_pipelined
@@ -50,9 +62,12 @@ class TestNewRelicRedis < Test::Unit::TestCase
50
62
  end
51
63
 
52
64
  assert_equal [[[:hgetall, "foo"], [:inc, "bar"]]], @client.process_args
53
- assert_metrics "Database/Redis/Pipelined/HGETALL",
65
+ assert_metrics "Database/Redis/Pipelined",
66
+ "Database/Redis/Pipelined/HGETALL",
54
67
  "Database/Redis/Pipelined/INC",
55
- "Database/Redis/Pipelined",
56
68
  "Database/Redis/allOther"
69
+
70
+ prm = @sampler.builder.current_segment.params
71
+ assert_equal "[[:hgetall, \"foo\"], [:inc, \"bar\"]]", prm[:key]
57
72
  end
58
73
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic-redis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Phoenix