newrelic_rpm 2.13.0.beta5 → 2.13.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 -0
- data/lib/new_relic/agent.rb +50 -50
- data/lib/new_relic/agent/agent.rb +24 -19
- data/lib/new_relic/agent/busy_calculator.rb +22 -22
- data/lib/new_relic/agent/chained_call.rb +3 -3
- data/lib/new_relic/agent/error_collector.rb +19 -19
- data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +11 -11
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +43 -43
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +6 -6
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache.rb +8 -8
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +4 -4
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +307 -303
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +8 -8
- data/lib/new_relic/agent/instrumentation/rack.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +10 -10
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
- data/lib/new_relic/agent/instrumentation/sinatra.rb +5 -5
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +55 -55
- data/lib/new_relic/agent/sampler.rb +42 -38
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +4 -4
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +7 -7
- data/lib/new_relic/agent/samplers/memory_sampler.rb +11 -11
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/shim_agent.rb +20 -16
- data/lib/new_relic/agent/stats_engine.rb +3 -3
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +28 -28
- data/lib/new_relic/agent/stats_engine/samplers.rb +16 -16
- data/lib/new_relic/agent/stats_engine/transactions.rb +25 -25
- data/lib/new_relic/agent/transaction_sampler.rb +68 -69
- data/lib/new_relic/agent/worker_loop.rb +13 -13
- data/lib/new_relic/collection_helper.rb +6 -6
- data/lib/new_relic/command.rb +14 -14
- data/lib/new_relic/commands/deployments.rb +19 -19
- data/lib/new_relic/commands/install.rb +25 -15
- data/lib/new_relic/control.rb +25 -25
- data/lib/new_relic/control/configuration.rb +17 -17
- data/lib/new_relic/control/frameworks/external.rb +3 -3
- data/lib/new_relic/control/frameworks/merb.rb +6 -6
- data/lib/new_relic/control/frameworks/rails.rb +17 -17
- data/lib/new_relic/control/frameworks/rails3.rb +11 -27
- data/lib/new_relic/control/frameworks/ruby.rb +6 -6
- data/lib/new_relic/control/frameworks/sinatra.rb +4 -4
- data/lib/new_relic/control/instrumentation.rb +8 -8
- data/lib/new_relic/control/logging_methods.rb +13 -13
- data/lib/new_relic/control/profiling.rb +2 -2
- data/lib/new_relic/control/server_methods.rb +17 -17
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/histogram.rb +73 -71
- data/lib/new_relic/local_environment.rb +45 -45
- data/lib/new_relic/merbtasks.rb +1 -1
- data/lib/new_relic/metric_data.rb +5 -5
- data/lib/new_relic/metric_parser.rb +22 -22
- data/lib/new_relic/metric_parser/action_mailer.rb +4 -4
- data/lib/new_relic/metric_parser/active_merchant.rb +8 -8
- data/lib/new_relic/metric_parser/active_record.rb +2 -2
- data/lib/new_relic/metric_parser/apdex.rb +86 -51
- data/lib/new_relic/metric_parser/controller.rb +10 -10
- data/lib/new_relic/metric_parser/controller_cpu.rb +5 -5
- data/lib/new_relic/metric_parser/errors.rb +1 -1
- data/lib/new_relic/metric_parser/external.rb +3 -3
- data/lib/new_relic/metric_parser/mem_cache.rb +2 -2
- data/lib/new_relic/metric_parser/other_transaction.rb +7 -7
- data/lib/new_relic/metric_parser/view.rb +5 -5
- data/lib/new_relic/metric_parser/web_frontend.rb +1 -1
- data/lib/new_relic/metric_parser/web_service.rb +1 -1
- data/lib/new_relic/metric_spec.rb +13 -13
- data/lib/new_relic/noticed_error.rb +4 -4
- data/lib/new_relic/rack/developer_mode.rb +33 -33
- data/lib/new_relic/rack/metric_app.rb +2 -2
- data/lib/new_relic/recipes.rb +9 -9
- data/lib/new_relic/stats.rb +57 -57
- data/lib/new_relic/timer_lib.rb +2 -2
- data/lib/new_relic/transaction_analysis.rb +19 -19
- data/lib/new_relic/transaction_sample.rb +101 -101
- data/lib/new_relic/url_rule.rb +3 -3
- data/lib/new_relic/version.rb +10 -10
- data/lib/newrelic_rpm.rb +6 -4
- data/lib/tasks/all.rb +1 -1
- data/newrelic_rpm.gemspec +3 -3
- data/test/new_relic/rack/episodes_test.rb +1 -0
- metadata +24 -42
@@ -13,7 +13,7 @@ module NewRelic
|
|
13
13
|
@local_env.dispatcher_instance_id = app_names.first
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|
18
18
|
@settings
|
19
19
|
end
|
@@ -36,29 +36,29 @@ module NewRelic
|
|
36
36
|
def merge_options(options, hash=self)
|
37
37
|
options.each do |key, val |
|
38
38
|
case
|
39
|
-
when key == :config then next
|
39
|
+
when key == :config then next
|
40
40
|
when val.is_a?(Hash)
|
41
41
|
merge_options(val, hash[key.to_s] ||= {})
|
42
42
|
when val.nil?
|
43
43
|
hash.delete(key.to_s)
|
44
|
-
else
|
44
|
+
else
|
45
45
|
hash[key.to_s] = val
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def [](key)
|
51
51
|
fetch(key)
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def []=(key, value)
|
55
55
|
settings[key] = value
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def fetch(key, default=nil)
|
59
59
|
settings.fetch(key, default)
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def apdex_t
|
63
63
|
# Always initialized with a default
|
64
64
|
fetch('apdex_t').to_f
|
@@ -73,12 +73,12 @@ module NewRelic
|
|
73
73
|
def monitor_mode?
|
74
74
|
fetch('monitor_mode', fetch('enabled'))
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# True if we are capturing data and displaying in /newrelic
|
78
78
|
def developer_mode?
|
79
79
|
fetch('developer_mode', fetch('developer'))
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def episodes_enabled?
|
83
83
|
fetch('episodes_enabled', true)
|
84
84
|
end
|
@@ -93,25 +93,25 @@ module NewRelic
|
|
93
93
|
def post_size_limit
|
94
94
|
fetch('post_size_limit', 2 * 1024 * 1024)
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
# Configuration option of the same name to indicate that we should connect
|
98
|
-
# to RPM synchronously on startup. This means when the agent is loaded it
|
98
|
+
# to RPM synchronously on startup. This means when the agent is loaded it
|
99
99
|
# won't return without trying to set up the server connection at least once
|
100
100
|
# which can make startup take longer. Defaults to false.
|
101
101
|
def sync_startup
|
102
102
|
fetch('sync_startup', false)
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
# Configuration option of the same name to indicate that we should flush
|
106
106
|
# data to the server on exiting. Defaults to true.
|
107
107
|
def send_data_on_exit
|
108
108
|
fetch('send_data_on_exit', true)
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
def dispatcher_instance_id
|
112
112
|
self['dispatcher_instance_id'] || @local_env.dispatcher_instance_id
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
def dispatcher
|
116
116
|
(self['dispatcher'] && self['dispatcher'].to_sym) || @local_env.dispatcher
|
117
117
|
end
|
@@ -123,17 +123,17 @@ module NewRelic
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
def validate_seed
|
126
|
-
self['validate_seed'] || ENV['NR_VALIDATE_SEED']
|
126
|
+
self['validate_seed'] || ENV['NR_VALIDATE_SEED']
|
127
127
|
end
|
128
128
|
def validate_token
|
129
129
|
self['validate_token'] || ENV['NR_VALIDATE_TOKEN']
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
def use_ssl?
|
133
133
|
@use_ssl = fetch('ssl', false) unless @use_ssl
|
134
134
|
@use_ssl
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def verify_certificate?
|
138
138
|
unless @verify_certificate
|
139
139
|
unless use_ssl?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# This is the control used when starting up in the context of
|
1
|
+
# This is the control used when starting up in the context of
|
2
2
|
# The New Relic Infrastructure Agent. We want to call this
|
3
3
|
# out specifically because in this context we are not monitoring
|
4
4
|
# the running process, but actually external things.
|
@@ -9,5 +9,5 @@ class NewRelic::Control::Frameworks::External < NewRelic::Control::Frameworks::R
|
|
9
9
|
def init_config(options={})
|
10
10
|
super
|
11
11
|
end
|
12
|
-
|
13
|
-
end
|
12
|
+
|
13
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
class NewRelic::Control::Frameworks::Merb < NewRelic::Control
|
2
|
-
|
2
|
+
|
3
3
|
def env
|
4
4
|
@env ||= ::Merb.env
|
5
5
|
end
|
6
|
-
def root
|
6
|
+
def root
|
7
7
|
::Merb.root
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def to_stdout(msg)
|
11
11
|
Merb.logger.info("NewRelic ~ " + msg)
|
12
12
|
rescue Exception => e
|
13
|
-
STDOUT.puts "NewRelic ~ " + msg
|
13
|
+
STDOUT.puts "NewRelic ~ " + msg
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def init_config options={}
|
17
17
|
::Merb::Plugins.add_rakefiles File.join(newrelic_root,"lib/tasks/all.rb")
|
18
|
-
|
18
|
+
|
19
19
|
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
|
20
20
|
::Merb::Plugins.config[:newrelic] = {
|
21
21
|
:config => self
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Control subclass instantiated when Rails is detected. Contains
|
2
|
-
# Rails specific configuration, instrumentation, environment values,
|
2
|
+
# Rails specific configuration, instrumentation, environment values,
|
3
3
|
# etc.
|
4
4
|
class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
5
5
|
|
@@ -9,9 +9,9 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
|
9
9
|
def root
|
10
10
|
RAILS_ROOT
|
11
11
|
end
|
12
|
-
|
13
|
-
# In versions of Rails prior to 2.0, the rails config was only available to
|
14
|
-
# the init.rb, so it had to be passed on from there.
|
12
|
+
|
13
|
+
# In versions of Rails prior to 2.0, the rails config was only available to
|
14
|
+
# the init.rb, so it had to be passed on from there.
|
15
15
|
def init_config(options={})
|
16
16
|
rails_config=options[:config]
|
17
17
|
if !agent_enabled?
|
@@ -24,18 +24,18 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
|
24
24
|
install_episodes rails_config
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def install_episodes(config)
|
29
29
|
return if config.nil? || !config.respond_to?(:middleware) || !episodes_enabled?
|
30
|
-
config.after_initialize do
|
30
|
+
config.after_initialize do
|
31
31
|
if defined?(NewRelic::Rack::Episodes)
|
32
|
-
config.middleware.use NewRelic::Rack::Episodes
|
32
|
+
config.middleware.use NewRelic::Rack::Episodes
|
33
33
|
log! "Installed episodes middleware"
|
34
34
|
::RAILS_DEFAULT_LOGGER.info "Installed episodes middleware"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def install_developer_mode(rails_config)
|
40
40
|
return if @installed
|
41
41
|
@installed = true
|
@@ -43,11 +43,11 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
|
43
43
|
begin
|
44
44
|
require 'new_relic/rack/developer_mode'
|
45
45
|
rails_config.middleware.use NewRelic::Rack::DeveloperMode
|
46
|
-
|
46
|
+
|
47
47
|
# inform user that the dev edition is available if we are running inside
|
48
48
|
# a webserver process
|
49
49
|
if @local_env.dispatcher_instance_id
|
50
|
-
port = @local_env.dispatcher_instance_id.to_s =~ /^\d+/ ? ":#{local_env.dispatcher_instance_id}" : ":port"
|
50
|
+
port = @local_env.dispatcher_instance_id.to_s =~ /^\d+/ ? ":#{local_env.dispatcher_instance_id}" : ":port"
|
51
51
|
log!("NewRelic Agent Developer Mode enabled.")
|
52
52
|
log!("To view performance information, go to http://localhost#{port}/newrelic")
|
53
53
|
end
|
@@ -58,7 +58,7 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
|
58
58
|
log!("Developer mode not available for Rails versions prior to 2.2", :warn)
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def log!(msg, level=:info)
|
63
63
|
return unless should_log?
|
64
64
|
begin
|
@@ -67,23 +67,23 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
|
67
67
|
super
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def to_stdout(message)
|
72
72
|
::RAILS_DEFAULT_LOGGER.info(message)
|
73
73
|
rescue Exception => e
|
74
74
|
super
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def rails_version
|
78
78
|
@rails_version ||= NewRelic::VersionNumber.new(::Rails::VERSION::STRING)
|
79
79
|
end
|
80
|
-
|
81
|
-
protected
|
80
|
+
|
81
|
+
protected
|
82
82
|
|
83
83
|
def rails_vendor_root
|
84
84
|
File.join(root,'vendor','rails')
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
# Collect the Rails::Info into an associative array as well as the list of plugins
|
88
88
|
def append_environment_info
|
89
89
|
local_env.append_environment_value('Rails version'){ ::Rails::VERSION::STRING }
|
@@ -122,5 +122,5 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
|
|
122
122
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
123
123
|
ActionController::Base.send :include, NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# Control subclass instantiated when Rails is detected. Contains
|
2
|
-
# Rails specific configuration, instrumentation, environment values,
|
2
|
+
# Rails specific configuration, instrumentation, environment values,
|
3
3
|
# etc.
|
4
|
-
|
5
|
-
|
4
|
+
require 'new_relic/control/frameworks/rails'
|
5
|
+
class NewRelic::Control::Frameworks::Rails3 < NewRelic::Control::Frameworks::Rails
|
6
|
+
|
6
7
|
def env
|
7
8
|
@env ||= ::Rails.env.to_s
|
8
9
|
end
|
@@ -14,8 +15,8 @@ class NewRelic::Control::Frameworks::Rails3 < NewRelic::Control
|
|
14
15
|
def logger
|
15
16
|
::Rails.logger
|
16
17
|
end
|
17
|
-
|
18
|
-
|
18
|
+
|
19
|
+
|
19
20
|
def log!(msg, level=:info)
|
20
21
|
return unless should_log?
|
21
22
|
logger.send(level, msg)
|
@@ -32,24 +33,13 @@ class NewRelic::Control::Frameworks::Rails3 < NewRelic::Control
|
|
32
33
|
def vendor_root
|
33
34
|
@vendor_root ||= File.join(root,'vendor','rails')
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
def version
|
37
38
|
@rails_version ||= NewRelic::VersionNumber.new(::Rails::VERSION::STRING)
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
if !agent_enabled?
|
43
|
-
# Might not be running if it does not think mongrel, thin, passenger, etc
|
44
|
-
# is running, if it things it's a rake task, or if the agent_enabled is false.
|
45
|
-
logger.info "New Relic Agent not running."
|
46
|
-
else
|
47
|
-
logger.info "Starting the New Relic Agent."
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
protected
|
52
|
-
|
41
|
+
protected
|
42
|
+
|
53
43
|
# Collect the Rails::Info into an associative array as well as the list of plugins
|
54
44
|
def append_environment_info
|
55
45
|
local_env.append_environment_value('Rails version'){ version }
|
@@ -63,14 +53,8 @@ class NewRelic::Control::Frameworks::Rails3 < NewRelic::Control
|
|
63
53
|
(gem.specification.respond_to?(:version) && gem.specification.version)
|
64
54
|
gem.name + (version ? "(#{version})" : "")
|
65
55
|
end
|
66
|
-
end
|
56
|
+
end
|
67
57
|
local_env.append_plugin_list { ::Rails.configuration.plugins }
|
68
58
|
end
|
69
|
-
|
70
|
-
def install_shim
|
71
|
-
super
|
72
|
-
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
73
|
-
ActionController::Base.send :include, NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim
|
74
|
-
end
|
75
|
-
|
59
|
+
|
76
60
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
# Looks for a newrelic.yml file in several locations
|
3
3
|
# including ./, ./config, $HOME/.newrelic and $HOME/.
|
4
4
|
# It loads the settings from the newrelic.yml section
|
5
|
-
# based on the value of RUBY_ENV or RAILS_ENV.
|
5
|
+
# based on the value of RUBY_ENV or RAILS_ENV.
|
6
6
|
class NewRelic::Control::Frameworks::Ruby < NewRelic::Control
|
7
|
-
|
7
|
+
|
8
8
|
def env
|
9
9
|
@env ||= ENV['RUBY_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
10
10
|
end
|
@@ -17,7 +17,7 @@ class NewRelic::Control::Frameworks::Ruby < NewRelic::Control
|
|
17
17
|
files << File.join(root,"config","newrelic.yml")
|
18
18
|
files << File.join(root,"newrelic.yml")
|
19
19
|
if ENV["HOME"]
|
20
|
-
files << File.join(ENV["HOME"], ".newrelic", "newrelic.yml")
|
20
|
+
files << File.join(ENV["HOME"], ".newrelic", "newrelic.yml")
|
21
21
|
files << File.join(ENV["HOME"], "newrelic.yml")
|
22
22
|
end
|
23
23
|
files << File.expand_path(ENV["NRCONFIG"]) if ENV["NRCONFIG"]
|
@@ -29,8 +29,8 @@ class NewRelic::Control::Frameworks::Ruby < NewRelic::Control
|
|
29
29
|
def to_stdout(msg)
|
30
30
|
STDOUT.puts msg
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def init_config(options={})
|
34
34
|
end
|
35
|
-
|
36
|
-
end
|
35
|
+
|
36
|
+
end
|
@@ -2,17 +2,17 @@
|
|
2
2
|
require 'new_relic/control/frameworks/ruby'
|
3
3
|
|
4
4
|
class NewRelic::Control::Frameworks::Sinatra < NewRelic::Control::Frameworks::Ruby
|
5
|
-
|
5
|
+
|
6
6
|
def env
|
7
7
|
@env ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
8
8
|
end
|
9
9
|
|
10
|
-
# This is the control used when starting up in the context of
|
10
|
+
# This is the control used when starting up in the context of
|
11
11
|
# The New Relic Infrastructure Agent. We want to call this
|
12
12
|
# out specifically because in this context we are not monitoring
|
13
13
|
# the running process, but actually external things.
|
14
14
|
def init_config(options={})
|
15
15
|
super
|
16
16
|
end
|
17
|
-
|
18
|
-
end
|
17
|
+
|
18
|
+
end
|
@@ -12,7 +12,7 @@ module NewRelic
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# Install stubs to the proper location so the app code will not fail
|
17
17
|
# if the agent is not running.
|
18
18
|
def install_shim
|
@@ -20,7 +20,7 @@ module NewRelic
|
|
20
20
|
raise "Cannot install the Agent shim after instrumentation has already been installed!" if @instrumented
|
21
21
|
NewRelic::Agent.agent = NewRelic::Agent::ShimAgent.instance
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# Add instrumentation. Don't call this directly. Use NewRelic::Agent#add_instrumentation.
|
25
25
|
# This will load the file synchronously if we've already loaded the default
|
26
26
|
# instrumentation.
|
@@ -52,7 +52,7 @@ module NewRelic
|
|
52
52
|
# an error if rails has not been initialised. which is totally sane.
|
53
53
|
_delayed_instrumentation
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def load_samplers
|
57
57
|
agent = NewRelic::Agent.instance
|
58
58
|
NewRelic::Agent::Sampler.sampler_classes.each do | subclass |
|
@@ -62,7 +62,7 @@ module NewRelic
|
|
62
62
|
if subclass.use_harvest_sampler?
|
63
63
|
agent.stats_engine.add_harvest_sampler sampler
|
64
64
|
log.debug "Registered #{subclass.name} for harvest time sampling"
|
65
|
-
else
|
65
|
+
else
|
66
66
|
agent.stats_engine.add_sampler sampler
|
67
67
|
log.debug "Registered #{subclass.name} for periodic sampling"
|
68
68
|
end
|
@@ -73,14 +73,14 @@ module NewRelic
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
private
|
78
|
-
|
78
|
+
|
79
79
|
def _install_instrumentation
|
80
80
|
return if @instrumented
|
81
|
-
|
81
|
+
|
82
82
|
@instrumented = true
|
83
|
-
|
83
|
+
|
84
84
|
# Instrumentation for the key code points inside rails for monitoring by NewRelic.
|
85
85
|
# note this file is loaded only if the newrelic agent is enabled (through config/newrelic.yml)
|
86
86
|
instrumentation_path = File.join(File.dirname(__FILE__), '..', 'agent','instrumentation')
|
@@ -2,9 +2,9 @@
|
|
2
2
|
module NewRelic
|
3
3
|
class Control
|
4
4
|
module LoggingMethods
|
5
|
-
|
5
|
+
|
6
6
|
attr_accessor :log_file
|
7
|
-
|
7
|
+
|
8
8
|
def log
|
9
9
|
# If we try to get a log before one has been set up, return a stdout log
|
10
10
|
unless @log
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
end
|
15
15
|
@log
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# send the given message to STDOUT so that it shows
|
19
19
|
# up in the console. This should be used for important informational messages at boot.
|
20
20
|
# The to_stdout may be implemented differently by different config subclasses.
|
@@ -24,24 +24,24 @@ module NewRelic
|
|
24
24
|
to_stdout msg
|
25
25
|
log.send level, msg if @log
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def should_log?
|
29
29
|
@settings && agent_enabled?
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# Control subclasses may override this, but it can be called multiple times.
|
33
33
|
def setup_log
|
34
34
|
@log_file = "#{log_path}/#{log_file_name}"
|
35
35
|
@log = Logger.new(@log_file) rescue nil
|
36
|
-
|
36
|
+
|
37
37
|
# change the format just for our logger
|
38
38
|
|
39
39
|
def log.format_message(severity, timestamp, progname, msg)
|
40
|
-
"[#{timestamp.strftime("%m/%d/%y %H:%M:%S %z")} #{Socket.gethostname} (#{$$})] #{severity} : #{msg}\n"
|
40
|
+
"[#{timestamp.strftime("%m/%d/%y %H:%M:%S %z")} #{Socket.gethostname} (#{$$})] #{severity} : #{msg}\n"
|
41
41
|
end
|
42
42
|
|
43
43
|
# set the log level as specified in the config file
|
44
|
-
|
44
|
+
|
45
45
|
case fetch("log_level","info").downcase
|
46
46
|
when "debug" then log.level = Logger::DEBUG
|
47
47
|
when "info" then log.level = Logger::INFO
|
@@ -52,20 +52,20 @@ module NewRelic
|
|
52
52
|
end
|
53
53
|
log
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def to_stdout(msg)
|
57
|
-
STDOUT.puts "** [NewRelic] " + msg
|
57
|
+
STDOUT.puts "** [NewRelic] " + msg
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def log_path
|
61
61
|
return if @log_path
|
62
62
|
@log_path = File.expand_path(fetch('log_file_path', 'log/'))
|
63
|
-
if !File.directory?(@log_path) && ! (Dir.mkdir(@log_path) rescue nil)
|
63
|
+
if !File.directory?(@log_path) && ! (Dir.mkdir(@log_path) rescue nil)
|
64
64
|
log!("Error creating New Relic log directory '#{@log_path}'", :error)
|
65
65
|
end
|
66
66
|
@log_path
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def log_file_name
|
70
70
|
fetch('log_file_name', 'newrelic_agent.log')
|
71
71
|
end
|