newrelic-redis 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 1.4.0 / 2012-10-31
2
+
3
+ HAPPY HALLOWEEN!
4
+
5
+ * 1 minor bugfix:
6
+ * Use DependencyDetection to load up properly
7
+
1
8
  === 1.3.2 / 2012-05-18
2
9
 
3
10
  * 1 minor bugfix:
@@ -1,87 +1,94 @@
1
1
  require 'new_relic/agent/method_tracer'
2
- require 'redis'
3
2
 
4
3
  # Redis instrumentation.
5
4
  # Originally contributed by Ashley Martens of ngmoco
6
5
  # Rewritten, reorganized, and repackaged by Evan Phoenix
7
6
 
8
- load_probes =
9
- !NewRelic::Control.instance['disable_redis'] &&
10
- ENV['NEWRELIC_ENABLE'].to_s !~ /false|off|no/i
7
+ DependencyDetection.defer do
8
+ @name = :redis
11
9
 
12
- # load_probes checked as a post condition
13
- ::Redis::Client.class_eval do
14
-
15
- include NewRelic::Agent::MethodTracer
16
-
17
- # Support older versions of Redis::Client that used the method
18
- # +raw_call_command+.
19
-
20
- call_method =
21
- ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
10
+ depends_on do
11
+ defined?(::Redis) &&
12
+ !NewRelic::Control.instance['disable_redis'] &&
13
+ ENV['NEWRELIC_ENABLE'].to_s !~ /false|off|no/i
14
+ end
22
15
 
23
- def call_with_newrelic_trace(*args, &blk)
24
- if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
25
- total_metric = 'Database/Redis/allWeb'
26
- else
27
- total_metric = 'Database/Redis/allOther'
28
- end
16
+ executes do
17
+ NewRelic::Agent.logger.debug 'Installing Redis Instrumentation'
18
+ end
29
19
 
30
- method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
31
- metrics = ["Database/Redis/#{method_name.to_s.upcase}", total_metric]
20
+ executes do
21
+ ::Redis::Client.class_eval do
22
+ # Support older versions of Redis::Client that used the method
23
+ # +raw_call_command+.
32
24
 
33
- self.class.trace_execution_scoped(metrics) do
34
- start = Time.now
25
+ call_method = ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command
35
26
 
36
- begin
37
- call_without_newrelic_trace(*args, &blk)
38
- ensure
39
- s = NewRelic::Agent.instance.transaction_sampler
40
- s.notice_nosql(args.inspect, (Time.now - start).to_f) rescue nil
41
- end
42
- end
43
- end
44
-
45
- alias_method :call_without_newrelic_trace, call_method
46
- alias_method call_method, :call_with_newrelic_trace
47
-
48
- # Older versions of Redis handle pipelining completely differently.
49
- # Don't bother supporting them for now.
50
- #
51
- if public_method_defined? :call_pipelined
52
- def call_pipelined_with_newrelic_trace(commands, *rest)
53
- if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
54
- total_metric = 'Database/Redis/allWeb'
55
- else
56
- total_metric = 'Database/Redis/allOther'
57
- end
27
+ def call_with_newrelic_trace(*args, &blk)
28
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
29
+ total_metric = 'Database/Redis/allWeb'
30
+ else
31
+ total_metric = 'Database/Redis/allOther'
32
+ end
58
33
 
59
- # Report each command as a metric under pipelined, so the user
60
- # can at least see what all the commands were. This prevents
61
- # metric namespace explosion.
34
+ method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
35
+ metrics = ["Database/Redis/#{method_name.to_s.upcase}", total_metric]
62
36
 
63
- metrics = ["Database/Redis/Pipelined", total_metric]
37
+ self.class.trace_execution_scoped(metrics) do
38
+ start = Time.now
64
39
 
65
- commands.each do |c|
66
- name = c.kind_of?(Array) ? c[0] : c
67
- metrics << "Database/Redis/Pipelined/#{name.to_s.upcase}"
40
+ begin
41
+ call_without_newrelic_trace(*args, &blk)
42
+ ensure
43
+ s = NewRelic::Agent.instance.transaction_sampler
44
+ s.notice_nosql(args.inspect, (Time.now - start).to_f) rescue nil
45
+ end
46
+ end
68
47
  end
69
48
 
70
- self.class.trace_execution_scoped(metrics) do
71
- start = Time.now
72
-
73
- begin
74
- call_pipelined_without_newrelic_trace commands, *rest
75
- ensure
76
- s = NewRelic::Agent.instance.transaction_sampler
77
- s.notice_nosql(commands.inspect, (Time.now - start).to_f) rescue nil
49
+ alias_method :call_without_newrelic_trace, call_method
50
+ alias_method call_method, :call_with_newrelic_trace
51
+
52
+ # Older versions of Redis handle pipelining completely differently.
53
+ # Don't bother supporting them for now.
54
+ #
55
+ if public_method_defined? :call_pipelined
56
+ def call_pipelined_with_newrelic_trace(commands, *rest)
57
+ if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
58
+ total_metric = 'Database/Redis/allWeb'
59
+ else
60
+ total_metric = 'Database/Redis/allOther'
61
+ end
62
+
63
+ # Report each command as a metric under pipelined, so the user
64
+ # can at least see what all the commands were. This prevents
65
+ # metric namespace explosion.
66
+
67
+ metrics = ["Database/Redis/Pipelined", total_metric]
68
+
69
+ commands.each do |c|
70
+ name = c.kind_of?(Array) ? c[0] : c
71
+ metrics << "Database/Redis/Pipelined/#{name.to_s.upcase}"
72
+ end
73
+
74
+ self.class.trace_execution_scoped(metrics) do
75
+ start = Time.now
76
+
77
+ begin
78
+ call_pipelined_without_newrelic_trace commands, *rest
79
+ ensure
80
+ s = NewRelic::Agent.instance.transaction_sampler
81
+ s.notice_nosql(commands.inspect, (Time.now - start).to_f) rescue nil
82
+ end
83
+ end
78
84
  end
85
+
86
+ alias_method :call_pipelined_without_newrelic_trace, :call_pipelined
87
+ alias_method :call_pipelined, :call_pipelined_with_newrelic_trace
79
88
  end
80
89
  end
90
+ end
81
91
 
92
+ end
82
93
 
83
- alias_method :call_pipelined_without_newrelic_trace, :call_pipelined
84
- alias_method :call_pipelined, :call_pipelined_with_newrelic_trace
85
- end
86
- end if load_probes
87
94
 
@@ -1,3 +1,3 @@
1
1
  class NewRelicRedis
2
- VERSION = '1.3.2'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -21,6 +21,8 @@ class TestNewRelicRedis < Test::Unit::TestCase
21
21
 
22
22
  @redis = Redis.new OPTIONS
23
23
  @client = @redis.client
24
+
25
+ DependencyDetection.detect!
24
26
  end
25
27
 
26
28
  def teardown
metadata CHANGED
@@ -1,94 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: newrelic-redis
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 2
10
- version: 1.3.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Evan Phoenix
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-05-18 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: redis
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - <
27
- - !ruby/object:Gem::Version
28
- hash: 27
29
- segments:
30
- - 4
31
- - 0
32
- version: "4.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: newrelic_rpm
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - <
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: newrelic_rpm
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
- requirements:
34
+ requirements:
41
35
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 3
46
- - 0
47
- version: "3.0"
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
48
38
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rdoc
52
39
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
54
49
  none: false
55
- requirements:
50
+ requirements:
56
51
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 19
59
- segments:
60
- - 3
61
- - 10
62
- version: "3.10"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.10'
63
54
  type: :development
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: hoe
67
55
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.10'
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe
64
+ requirement: !ruby/object:Gem::Requirement
69
65
  none: false
70
- requirements:
66
+ requirements:
71
67
  - - ~>
72
- - !ruby/object:Gem::Version
73
- hash: 7
74
- segments:
75
- - 3
76
- - 0
77
- version: "3.0"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
78
70
  type: :development
79
- version_requirements: *id004
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
80
78
  description: Redis instrumentation for Newrelic.
81
- email:
79
+ email:
82
80
  - evan@phx.io
83
81
  executables: []
84
-
85
82
  extensions: []
86
-
87
- extra_rdoc_files:
83
+ extra_rdoc_files:
88
84
  - History.txt
89
85
  - Manifest.txt
90
86
  - README.txt
91
- files:
87
+ files:
92
88
  - .autotest
93
89
  - History.txt
94
90
  - Manifest.txt
@@ -103,37 +99,29 @@ files:
103
99
  - .gemtest
104
100
  homepage: http://github.com/evanphx/newrelic-redis
105
101
  licenses: []
106
-
107
102
  post_install_message:
108
- rdoc_options:
103
+ rdoc_options:
109
104
  - --main
110
105
  - README.txt
111
- require_paths:
106
+ require_paths:
112
107
  - lib
113
- required_ruby_version: !ruby/object:Gem::Requirement
108
+ required_ruby_version: !ruby/object:Gem::Requirement
114
109
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
122
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
115
  none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
- version: "0"
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
131
120
  requirements: []
132
-
133
121
  rubyforge_project: newrelic-redis
134
- rubygems_version: 1.8.22
122
+ rubygems_version: 1.8.24
135
123
  signing_key:
136
124
  specification_version: 3
137
125
  summary: Redis instrumentation for Newrelic.
138
- test_files:
126
+ test_files:
139
127
  - test/test_newrelic_redis.rb