newrelic_rpm 3.1.1.beta3 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +4 -1
- data/lib/new_relic/agent/beacon_configuration.rb +12 -6
- data/lib/new_relic/agent/instrumentation/memcache.rb +35 -25
- data/lib/new_relic/control/instance_methods.rb +1 -0
- data/lib/new_relic/control/logging_methods.rb +34 -13
- data/lib/new_relic/version.rb +1 -1
- data/lib/newrelic_rpm.rb +1 -1
- data/newrelic_rpm.gemspec +2 -3
- data/test/new_relic/agent/agent_test_controller_test.rb +15 -13
- data/test/new_relic/agent/beacon_configuration_test.rb +8 -4
- data/test/new_relic/agent/memcache_instrumentation_test.rb +24 -7
- data/test/new_relic/control/configuration_test.rb +2 -1
- data/test/new_relic/control/logging_methods_test.rb +27 -16
- data/test/new_relic/delayed_job_injection_test.rb +12 -13
- metadata +4 -7
- data/log/newrelic_agent.log +0 -1
data/CHANGELOG
CHANGED
@@ -2,8 +2,11 @@ v3.1.1
|
|
2
2
|
* Support for Rails 3.1 (thanks to Ben Hoskings via github)
|
3
3
|
* Support for Rubinius
|
4
4
|
* Fixed issues affecting some Delayed Job users where log files were not appearing
|
5
|
-
* Fixed an issue where some instrumentation might not get loaded in Rails apps
|
5
|
+
* Fixed an issue where some instrumentation might not get loaded in Rails apps
|
6
|
+
* Fix for memcached cas method (thanks to Andrew Long and Joseph Palermo )
|
6
7
|
* Fix for logger deprecation warning (thanks to Jonathan del Strother via github)
|
8
|
+
* Support for logging to STDOUT
|
9
|
+
* Support for Spymemcached client on jruby
|
7
10
|
|
8
11
|
v3.1.0
|
9
12
|
* Support for aggregating data from short-running
|
@@ -62,20 +62,26 @@ module NewRelic
|
|
62
62
|
# including the episodes file dynamically (i.e. the user
|
63
63
|
# includes it themselves)
|
64
64
|
def build_load_file_js(connect_data)
|
65
|
-
|
66
|
-
|
67
|
-
episodes_url = connect_data.fetch('episodes_url', '')
|
68
|
-
|
69
|
-
<<-eos
|
65
|
+
js = <<-EOS
|
70
66
|
if (!NREUMQ.f) NREUMQ.f=function() {
|
71
67
|
NREUMQ.push(["load",new Date().getTime()]);
|
68
|
+
EOS
|
69
|
+
|
70
|
+
if connect_data.fetch('rum.load_episodes_file', true)
|
71
|
+
episodes_url = connect_data.fetch('episodes_url', '')
|
72
|
+
js << <<-EOS
|
72
73
|
var e=document.createElement(\"script\");
|
73
74
|
e.type=\"text/javascript\";e.async=true;e.src=\"#{episodes_url}\";
|
74
75
|
document.body.appendChild(e);
|
76
|
+
EOS
|
77
|
+
end
|
78
|
+
|
79
|
+
js << <<-EOS
|
75
80
|
if(NREUMQ.a)NREUMQ.a();
|
76
81
|
};
|
77
82
|
if(window.onload!==NREUMQ.f){NREUMQ.a=window.onload;window.onload=NREUMQ.f;};
|
78
|
-
|
83
|
+
EOS
|
84
|
+
js
|
79
85
|
end
|
80
86
|
|
81
87
|
# returns a copy of the static javascript header, in case people
|
@@ -10,24 +10,26 @@ module NewRelic
|
|
10
10
|
module Instrumentation
|
11
11
|
module Memcache
|
12
12
|
module_function
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
def instrument_methods(the_class, method_names)
|
14
|
+
method_names.each do |method_name|
|
15
|
+
next unless the_class.method_defined? method_name.to_sym
|
16
|
+
the_class.class_eval <<-EOD
|
17
|
+
def #{method_name}_with_newrelic_trace(*args, &block)
|
18
|
+
metrics = ["MemCache/#{method_name}",
|
19
|
+
(NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'MemCache/allWeb' : 'MemCache/allOther')]
|
20
|
+
self.class.trace_execution_scoped(metrics) do
|
21
|
+
t0 = Time.now
|
22
|
+
begin
|
23
|
+
#{method_name}_without_newrelic_trace(*args, &block)
|
24
|
+
ensure
|
25
|
+
#{memcache_key_snippet(method_name)}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
alias #{method_name}_without_newrelic_trace #{method_name}
|
30
|
+
alias #{method_name} #{method_name}_with_newrelic_trace
|
31
|
+
EOD
|
32
|
+
end
|
31
33
|
end
|
32
34
|
def memcache_key_snippet(method_name)
|
33
35
|
return "" unless NewRelic::Control.instance['capture_memcache_keys']
|
@@ -38,9 +40,6 @@ module NewRelic
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
43
|
DependencyDetection.defer do
|
45
44
|
depends_on do
|
46
45
|
!NewRelic::Control.instance['disable_memcache_instrumentation']
|
@@ -51,10 +50,21 @@ DependencyDetection.defer do
|
|
51
50
|
end
|
52
51
|
|
53
52
|
executes do
|
54
|
-
%w[get get_multi set add incr decr delete replace append prepend
|
55
|
-
|
56
|
-
NewRelic::Agent::Instrumentation::Memcache.
|
57
|
-
|
53
|
+
commands = %w[get get_multi set add incr decr delete replace append prepend]
|
54
|
+
if defined? ::MemCache
|
55
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::MemCache,
|
56
|
+
commands)
|
57
|
+
elsif defined? ::Memcached
|
58
|
+
commands << 'cas'
|
59
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Memcached,
|
60
|
+
commands)
|
61
|
+
elsif defined? ::Dalli::Client
|
62
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Dalli::Client,
|
63
|
+
commands)
|
64
|
+
elsif defined? ::Spymemcached
|
65
|
+
commands << 'multiget'
|
66
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Spymemcached,
|
67
|
+
commands)
|
58
68
|
end
|
59
69
|
end
|
60
70
|
end
|
@@ -147,6 +147,7 @@ module NewRelic
|
|
147
147
|
puts "Cannot find or read #{newrelic_file}"
|
148
148
|
@yaml = {}
|
149
149
|
else
|
150
|
+
YAML::ENGINE.yamler = 'syck' if defined?(YAML::ENGINE)
|
150
151
|
@yaml = YAML.load(ERB.new(File.read(newrelic_file)).result(binding))
|
151
152
|
end
|
152
153
|
rescue ScriptError, StandardError => e
|
@@ -11,9 +11,9 @@ module NewRelic
|
|
11
11
|
# logger pointing to standard out, if we're trying to log before
|
12
12
|
# a log exists
|
13
13
|
def log
|
14
|
-
|
14
|
+
if !@log
|
15
15
|
l = Logger.new(STDOUT)
|
16
|
-
l.level = Logger::INFO
|
16
|
+
l.level = Logger::INFO
|
17
17
|
return l
|
18
18
|
end
|
19
19
|
@log
|
@@ -55,7 +55,8 @@ module NewRelic
|
|
55
55
|
# patches the logger's format_message method to change the format just for our logger
|
56
56
|
def set_log_format!(logger)
|
57
57
|
def logger.format_message(severity, timestamp, progname, msg)
|
58
|
-
|
58
|
+
prefix = @logdev.dev == STDOUT ? '** [NewRelic]' : ''
|
59
|
+
prefix + "[#{timestamp.strftime("%m/%d/%y %H:%M:%S %z")} #{Socket.gethostname} (#{$$})] #{severity} : #{msg}\n"
|
59
60
|
end
|
60
61
|
logger
|
61
62
|
end
|
@@ -64,8 +65,14 @@ module NewRelic
|
|
64
65
|
#
|
65
66
|
# Control subclasses may override this, but it can be called multiple times.
|
66
67
|
def setup_log
|
67
|
-
|
68
|
-
|
68
|
+
if log_to_stdout?
|
69
|
+
@log = Logger.new(STDOUT)
|
70
|
+
else
|
71
|
+
@log_file = "#{log_path}/#{log_file_name}"
|
72
|
+
@log = Logger.new(@log_file) rescue nil
|
73
|
+
@log ||= Logger.new(STDOUT) # failsafe to STDOUT
|
74
|
+
end
|
75
|
+
|
69
76
|
if @log
|
70
77
|
set_log_format!(@log)
|
71
78
|
set_log_level!(@log)
|
@@ -88,18 +95,32 @@ module NewRelic
|
|
88
95
|
# 'log_file_path' in the configuration file.
|
89
96
|
def log_path
|
90
97
|
return @log_path if @log_path
|
91
|
-
|
98
|
+
if log_to_stdout?
|
99
|
+
@log_path = nil
|
100
|
+
else
|
101
|
+
@log_path = find_or_create_file_path(fetch('log_file_path', 'log'))
|
102
|
+
log!("Error creating log directory for New Relic log file, using standard out.", :error) unless @log_path
|
103
|
+
end
|
104
|
+
@log_path
|
105
|
+
end
|
106
|
+
|
107
|
+
def find_or_create_file_path(path_setting)
|
92
108
|
for abs_path in [ File.expand_path(path_setting),
|
93
109
|
File.expand_path(File.join(root, path_setting)) ] do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
110
|
+
if File.directory?(abs_path) || (Dir.mkdir(abs_path) rescue nil)
|
111
|
+
return abs_path[%r{^(.*?)/?$}]
|
112
|
+
end
|
98
113
|
end
|
99
|
-
|
100
|
-
@log_path ||= path_setting
|
114
|
+
nil
|
101
115
|
end
|
102
|
-
|
116
|
+
|
117
|
+
def log_to_stdout?
|
118
|
+
return true if @stdout
|
119
|
+
if fetch('log_file_path', 'log') == 'STDOUT'
|
120
|
+
@stdout = true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
103
124
|
# Retrieves the log file's name from the config file option
|
104
125
|
#'log_file_name', defaulting to 'newrelic_agent.log'
|
105
126
|
def log_file_name
|
data/lib/new_relic/version.rb
CHANGED
@@ -4,7 +4,7 @@ module NewRelic
|
|
4
4
|
MAJOR = 3
|
5
5
|
MINOR = 1
|
6
6
|
TINY = 1
|
7
|
-
BUILD =
|
7
|
+
BUILD = nil # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
|
8
8
|
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
|
9
9
|
end
|
10
10
|
|
data/lib/newrelic_rpm.rb
CHANGED
data/newrelic_rpm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{newrelic_rpm}
|
8
|
-
s.version = "3.1.1
|
8
|
+
s.version = "3.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-28}
|
13
13
|
s.description = %q{New Relic is a performance management system, developed by New Relic,
|
14
14
|
Inc (http://www.newrelic.com). New Relic provides you with deep
|
15
15
|
information about the performance of your web application as it runs
|
@@ -130,7 +130,6 @@ http://github.com/newrelic/rpm/
|
|
130
130
|
"lib/tasks/all.rb",
|
131
131
|
"lib/tasks/install.rake",
|
132
132
|
"lib/tasks/tests.rake",
|
133
|
-
"log/newrelic_agent.log",
|
134
133
|
"newrelic.yml",
|
135
134
|
"newrelic_rpm.gemspec",
|
136
135
|
"recipes/newrelic.rb",
|
@@ -7,12 +7,8 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
7
7
|
self.controller_class = NewRelic::Agent::AgentTestController
|
8
8
|
|
9
9
|
attr_accessor :agent, :engine
|
10
|
-
|
11
|
-
|
12
|
-
# setup is not called.
|
13
|
-
def initialize name
|
14
|
-
super name
|
15
|
-
|
10
|
+
|
11
|
+
def test_initialization
|
16
12
|
# Suggested by cee-dub for merb tests. I'm actually amazed if our tests work with merb.
|
17
13
|
if defined?(Merb::Router)
|
18
14
|
Merb::Router.prepare do |r|
|
@@ -45,6 +41,17 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
45
41
|
end
|
46
42
|
@engine = @agent.stats_engine
|
47
43
|
end
|
44
|
+
|
45
|
+
# Normally you can do this with #setup but for some reason in rails 2.0.2
|
46
|
+
# setup is not called.
|
47
|
+
if NewRelic::Control.instance.rails_version <= '2.1.0'
|
48
|
+
def initialize name
|
49
|
+
super name
|
50
|
+
test_initialization
|
51
|
+
end
|
52
|
+
else
|
53
|
+
alias_method :setup, :test_initialization
|
54
|
+
end
|
48
55
|
|
49
56
|
def teardown
|
50
57
|
Thread.current[:newrelic_ignore_controller] = nil
|
@@ -245,12 +252,8 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
245
252
|
assert_not_nil engine.lookup_stats('Controller/NewRelic::Agent::AgentTestController/internal_traced_action')
|
246
253
|
end
|
247
254
|
def test_action_instrumentation
|
248
|
-
|
249
|
-
|
250
|
-
assert_match /bar/, @response.body
|
251
|
-
#rescue ActionController::RoutingError
|
252
|
-
# you might get here if you don't have the default route installed.
|
253
|
-
end
|
255
|
+
get :index, :foo => 'bar'
|
256
|
+
assert_match /bar/, @response.body
|
254
257
|
end
|
255
258
|
|
256
259
|
def test_controller_params
|
@@ -274,7 +277,6 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
274
277
|
|
275
278
|
def test_busycalculation
|
276
279
|
engine.clear_stats
|
277
|
-
|
278
280
|
assert_equal 0, NewRelic::Agent::BusyCalculator.busy_count
|
279
281
|
get :index, 'social_security_number' => "001-555-1212", 'wait' => '0.05'
|
280
282
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
@@ -81,24 +81,28 @@ class NewRelic::Agent::BeaconConfigurationTest < Test::Unit::TestCase
|
|
81
81
|
def test_build_load_file_js_load_episodes_file_false
|
82
82
|
connect_data = {'rum.load_episodes_file' => false}
|
83
83
|
bc = NewRelic::Agent::BeaconConfiguration.new(connect_data)
|
84
|
-
assert_equal
|
84
|
+
assert_equal(186, bc.build_load_file_js(connect_data).size,
|
85
|
+
"should include timing footer but not rum.js load")
|
85
86
|
end
|
86
87
|
|
87
88
|
def test_build_load_file_js_load_episodes_file_missing
|
88
89
|
connect_data = {}
|
89
90
|
bc = NewRelic::Agent::BeaconConfiguration.new(connect_data)
|
90
|
-
assert_equal(304, bc.build_load_file_js(connect_data).size,
|
91
|
+
assert_equal(304, bc.build_load_file_js(connect_data).size,
|
92
|
+
"should output the javascript when there is no configuration")
|
91
93
|
end
|
92
94
|
|
93
95
|
def test_build_load_file_js_load_episodes_file_present
|
94
96
|
connect_data = {'rum.load_episodes_file' => true}
|
95
97
|
bc = NewRelic::Agent::BeaconConfiguration.new(connect_data)
|
96
|
-
assert_equal(304, bc.build_load_file_js(connect_data).size,
|
98
|
+
assert_equal(304, bc.build_load_file_js(connect_data).size,
|
99
|
+
"should output the javascript when rum.load_episodes_file is true")
|
97
100
|
end
|
98
101
|
|
99
102
|
def test_build_load_file_js_load_episodes_file_with_episodes_url
|
100
103
|
connect_data = {'episodes_url' => 'an episodes url'}
|
101
104
|
bc = NewRelic::Agent::BeaconConfiguration.new(connect_data)
|
102
|
-
assert(bc.build_load_file_js(connect_data).include?('an episodes url'),
|
105
|
+
assert(bc.build_load_file_js(connect_data).include?('an episodes url'),
|
106
|
+
"should include the episodes url by default")
|
103
107
|
end
|
104
108
|
end
|
@@ -2,9 +2,10 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
|
|
2
2
|
|
3
3
|
memcached_ready = false
|
4
4
|
classes = {
|
5
|
-
|
5
|
+
# 'memcache' => 'MemCache'
|
6
6
|
# 'dalli' => 'Dalli::Client'
|
7
7
|
# 'memcached' => 'Memcached'
|
8
|
+
'spymemcached' => 'Spymemcached'
|
8
9
|
}
|
9
10
|
begin
|
10
11
|
TCPSocket.new('localhost', 11211)
|
@@ -29,17 +30,29 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
29
30
|
NewRelic::Agent.manual_start
|
30
31
|
@engine = NewRelic::Agent.instance.stats_engine
|
31
32
|
|
32
|
-
|
33
|
+
case MEMCACHED_CLASS.name
|
34
|
+
when 'Memcached'
|
33
35
|
@cache = MEMCACHED_CLASS.new('localhost', :support_cas => true)
|
34
|
-
|
36
|
+
when 'Spymemcached'
|
37
|
+
@cache = MEMCACHED_CLASS.new('localhost:11211')
|
35
38
|
else
|
36
39
|
@cache = MEMCACHED_CLASS.new('localhost')
|
37
|
-
@cache.flush_all
|
38
40
|
end
|
39
41
|
@key = 'schluessel'
|
40
42
|
@cache.set('schluessel', 1)
|
41
43
|
end
|
42
|
-
|
44
|
+
|
45
|
+
def teardown
|
46
|
+
if MEMCACHED_CLASS.name == 'Memecached'
|
47
|
+
@cache.flush
|
48
|
+
elsif MEMCACHED_CLASS.name == 'Spymemcached'
|
49
|
+
@cache.flush
|
50
|
+
@cache.instance_eval{ @client.shutdown }
|
51
|
+
else
|
52
|
+
@cache.flush_all
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
43
56
|
def _call_test_method_in_web_transaction(method, *args)
|
44
57
|
@engine.clear_stats
|
45
58
|
perform_action_with_newrelic_trace(:name=>'action', :category => :controller) do
|
@@ -55,7 +68,9 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
55
68
|
end
|
56
69
|
|
57
70
|
def test_reads__web
|
58
|
-
|
71
|
+
commands = ['get']
|
72
|
+
commands << 'get_multi' unless MEMCACHED_CLASS.name == 'Spymemcached'
|
73
|
+
commands.each do |method|
|
59
74
|
if @cache.class.method_defined?(method)
|
60
75
|
_call_test_method_in_web_transaction(method)
|
61
76
|
compare_metrics ["MemCache/#{method}", "MemCache/allWeb", "MemCache/#{method}:Controller/NewRelic::Agent::MemcacheInstrumentationTest/action"],
|
@@ -84,7 +99,9 @@ class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
|
|
84
99
|
end
|
85
100
|
|
86
101
|
def test_reads__background
|
87
|
-
|
102
|
+
commands = ['get']
|
103
|
+
commands << 'get_multi' unless MEMCACHED_CLASS.name == 'Spymemcached'
|
104
|
+
commands.each do |method|
|
88
105
|
if @cache.class.method_defined?(method)
|
89
106
|
_call_test_method_in_background_task(method)
|
90
107
|
compare_metrics ["MemCache/#{method}", "MemCache/allOther", "MemCache/#{method}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"],
|
@@ -31,9 +31,10 @@ class NewRelic::Control::ConfigurationTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_log_file_path_uses_given_value
|
34
|
+
Dir.stubs(:mkdir).returns(true)
|
34
35
|
NewRelic::Control.instance['log_file_path'] = 'lerg'
|
35
36
|
NewRelic::Control.instance.setup_log
|
36
|
-
|
37
|
+
assert_match(/\/lerg\/newrelic_agent.log/,
|
37
38
|
NewRelic::Control.instance.log_file)
|
38
39
|
end
|
39
40
|
end
|
@@ -5,12 +5,15 @@ require 'fileutils'
|
|
5
5
|
class BaseLoggingMethods
|
6
6
|
# stub class to enable testing of the module
|
7
7
|
include NewRelic::Control::LoggingMethods
|
8
|
+
include NewRelic::Control::Configuration
|
8
9
|
def root; "."; end
|
9
10
|
end
|
10
11
|
|
11
12
|
class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
12
13
|
def setup
|
13
14
|
@base = BaseLoggingMethods.new
|
15
|
+
@base.settings['log_file_path'] = 'log/'
|
16
|
+
@base.settings['log_file_name'] = 'newrelic_agent.log'
|
14
17
|
super
|
15
18
|
end
|
16
19
|
|
@@ -37,6 +40,7 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
37
40
|
|
38
41
|
def test_logbang_should_not_log
|
39
42
|
@base.expects(:should_log?).returns(false)
|
43
|
+
@base.stubs(:to_stdout)
|
40
44
|
assert_equal nil, @base.log!('whee')
|
41
45
|
end
|
42
46
|
|
@@ -90,20 +94,10 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
90
94
|
assert fake_logger.respond_to?(:format_message)
|
91
95
|
end
|
92
96
|
|
93
|
-
def test_setup_log_file_not_exist
|
94
|
-
@base.expects(:log_path).returns('logpath')
|
95
|
-
@base.expects(:log_file_name).returns('logfilename')
|
96
|
-
fake_logger = mock('logger')
|
97
|
-
@base.expects(:log).returns(fake_logger)
|
98
|
-
@base.setup_log
|
99
|
-
assert_equal nil, @base.instance_eval { @log }
|
100
|
-
assert_equal 'logpath/logfilename', @base.instance_eval { @log_file }
|
101
|
-
end
|
102
|
-
|
103
97
|
def test_setup_log_existing_file
|
104
98
|
fake_logger = mock('logger')
|
105
99
|
Logger.expects(:new).with('logpath/logfilename').returns(fake_logger)
|
106
|
-
@base.expects(:log_path).returns('logpath')
|
100
|
+
@base.expects(:log_path).returns('logpath').at_least_once
|
107
101
|
@base.expects(:log_file_name).returns('logfilename')
|
108
102
|
@base.expects(:set_log_format!).with(fake_logger)
|
109
103
|
@base.expects(:set_log_level!).with(fake_logger)
|
@@ -124,7 +118,7 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
124
118
|
|
125
119
|
def test_log_path_path_exists
|
126
120
|
@base.instance_eval { @log_path = nil }
|
127
|
-
@base.
|
121
|
+
@base.settings['log_file_path'] = 'log'
|
128
122
|
assert File.directory?('log')
|
129
123
|
assert_equal File.expand_path('log'), @base.log_path
|
130
124
|
end
|
@@ -132,7 +126,7 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
132
126
|
def test_log_path_path_created
|
133
127
|
path = File.expand_path('tmp/log_path_test')
|
134
128
|
@base.instance_eval { @log_path = nil }
|
135
|
-
@base.
|
129
|
+
@base.settings['log_file_path'] = 'tmp/log_path_test'
|
136
130
|
assert !File.directory?(path) || FileUtils.rmdir(path)
|
137
131
|
@base.expects(:log!).never
|
138
132
|
assert_equal path, @base.log_path
|
@@ -142,17 +136,34 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
|
|
142
136
|
def test_log_path_path_unable_to_create
|
143
137
|
path = File.expand_path('tmp/log_path_test')
|
144
138
|
@base.instance_eval { @log_path = nil }
|
145
|
-
@base.
|
139
|
+
@base.settings['log_file_path'] = 'tmp/log_path_test'
|
146
140
|
assert !File.directory?(path) || FileUtils.rmdir(path)
|
147
|
-
@base.expects(:log!).with("Error creating log directory for New Relic log file
|
141
|
+
@base.expects(:log!).with("Error creating log directory for New Relic log file, using standard out.", :error)
|
148
142
|
Dir.expects(:mkdir).with(path).raises('cannot make directory bro!').at_least_once
|
149
|
-
|
143
|
+
assert_nil @base.log_path
|
150
144
|
assert !File.directory?(path)
|
145
|
+
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
151
146
|
end
|
152
147
|
|
153
148
|
def test_log_file_name
|
154
149
|
@base.expects(:fetch).with('log_file_name', 'newrelic_agent.log').returns('log_file_name')
|
155
150
|
assert_equal 'log_file_name', @base.log_file_name
|
156
151
|
end
|
152
|
+
|
153
|
+
def test_log_to_stdout_when_log_file_path_set_to_STDOUT
|
154
|
+
@base.stubs(:fetch).returns('whatever')
|
155
|
+
@base.expects(:fetch).with('log_file_path', 'log').returns('STDOUT')
|
156
|
+
Dir.expects(:mkdir).never
|
157
|
+
@base.setup_log
|
158
|
+
assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_logs_to_stdout_include_newrelic_prefix
|
162
|
+
@base.stubs(:fetch).returns('whatever')
|
163
|
+
@base.expects(:fetch).with('log_file_path', 'log').returns('STDOUT')
|
164
|
+
STDOUT.expects(:write).with(regexp_matches(/\*\* \[NewRelic\].*whee/))
|
165
|
+
@base.setup_log
|
166
|
+
@base.log.info('whee')
|
167
|
+
end
|
157
168
|
end
|
158
169
|
|
@@ -1,17 +1,16 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
2
|
-
module NewRelic
|
3
|
-
class DelayedJobInstrumentationTest < Test::Unit::TestCase
|
4
|
-
def test_skip_logging_if_no_logger_found
|
5
|
-
Object.const_set('Delayed', Module.new)
|
6
|
-
::Delayed.const_set('Worker', Class.new)
|
7
|
-
|
8
|
-
NewRelic::Agent.stubs(:logger).raises(NoMethodError,
|
9
|
-
'tempoarily not allowed')
|
10
|
-
NewRelic::Agent.stubs(:respond_to?).with(:logger).returns(false)
|
11
|
-
|
12
|
-
assert DependencyDetection.detect!
|
13
2
|
|
14
|
-
|
15
|
-
|
3
|
+
class NewRelic::DelayedJobInstrumentationTest < Test::Unit::TestCase
|
4
|
+
def test_skip_logging_if_no_logger_found
|
5
|
+
Object.const_set('Delayed', Module.new) unless defined?(Delayed)
|
6
|
+
::Delayed.const_set('Worker', Class.new)
|
7
|
+
|
8
|
+
NewRelic::Agent.stubs(:logger).raises(NoMethodError,
|
9
|
+
'tempoarily not allowed')
|
10
|
+
NewRelic::Agent.stubs(:respond_to?).with(:logger).returns(false)
|
11
|
+
|
12
|
+
assert DependencyDetection.detect!
|
13
|
+
|
14
|
+
Object.class_eval { remove_const('Delayed') }
|
16
15
|
end
|
17
16
|
end
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 1
|
10
|
-
|
11
|
-
- 3
|
12
|
-
version: 3.1.1.beta3
|
10
|
+
version: 3.1.1
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Bill Kayser
|
@@ -20,7 +18,7 @@ autorequire:
|
|
20
18
|
bindir: bin
|
21
19
|
cert_chain: []
|
22
20
|
|
23
|
-
date: 2011-07-
|
21
|
+
date: 2011-07-28 00:00:00 -07:00
|
24
22
|
default_executable:
|
25
23
|
dependencies:
|
26
24
|
- !ruby/object:Gem::Dependency
|
@@ -190,7 +188,6 @@ files:
|
|
190
188
|
- lib/tasks/all.rb
|
191
189
|
- lib/tasks/install.rake
|
192
190
|
- lib/tasks/tests.rake
|
193
|
-
- log/newrelic_agent.log
|
194
191
|
- newrelic.yml
|
195
192
|
- newrelic_rpm.gemspec
|
196
193
|
- recipes/newrelic.rb
|
data/log/newrelic_agent.log
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Logfile created on Wed Jul 13 16:08:03 -0700 2011 by logger.rb
|