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
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'thread'
|
2
2
|
module NewRelic
|
3
3
|
module Agent
|
4
|
-
|
5
|
-
# A worker loop executes a set of registered tasks on a single thread.
|
6
|
-
# A task is a proc or block with a specified call period in seconds.
|
4
|
+
|
5
|
+
# A worker loop executes a set of registered tasks on a single thread.
|
6
|
+
# A task is a proc or block with a specified call period in seconds.
|
7
7
|
class WorkerLoop
|
8
|
-
|
8
|
+
|
9
9
|
def initialize
|
10
10
|
@log = log
|
11
11
|
@should_run = true
|
12
|
-
@next_invocation_time = Time.now
|
12
|
+
@next_invocation_time = Time.now
|
13
13
|
@period = 60.0
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def lock
|
17
17
|
@@lock ||= Mutex.new
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def log
|
21
21
|
NewRelic::Control.instance.log
|
22
22
|
end
|
@@ -38,19 +38,19 @@ module NewRelic
|
|
38
38
|
run_task if keep_running
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def keep_running
|
43
43
|
@should_run
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def stop
|
47
47
|
@should_run = false
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def run_task
|
51
51
|
begin
|
52
52
|
lock.synchronize do
|
53
|
-
@task.call
|
53
|
+
@task.call
|
54
54
|
end
|
55
55
|
rescue ServerError => e
|
56
56
|
log.debug "Server Error: #{e}"
|
@@ -68,13 +68,13 @@ module NewRelic
|
|
68
68
|
raise
|
69
69
|
rescue Exception => e
|
70
70
|
# Don't blow out the stack for anything that hasn't already propagated
|
71
|
-
log.error "Error running task in Agent Worker Loop '#{e}': #{e.backtrace.first}"
|
71
|
+
log.error "Error running task in Agent Worker Loop '#{e}': #{e.backtrace.first}"
|
72
72
|
log.debug e.backtrace.join("\n")
|
73
73
|
end
|
74
74
|
now = Time.now
|
75
75
|
while @next_invocation_time <= now && @period > 0
|
76
76
|
@next_invocation_time += @period
|
77
|
-
end
|
77
|
+
end
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -24,10 +24,10 @@ module NewRelic
|
|
24
24
|
truncate(flatten(params))
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# Return an array of strings (backtrace), cleaned up for readability
|
29
29
|
# Return nil if there is no backtrace
|
30
|
-
|
30
|
+
|
31
31
|
def strip_nr_from_backtrace(backtrace)
|
32
32
|
if backtrace
|
33
33
|
# this is for 1.9.1, where strings no longer have Enumerable
|
@@ -40,12 +40,12 @@ module NewRelic
|
|
40
40
|
end
|
41
41
|
backtrace
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
private
|
45
|
-
|
45
|
+
|
46
46
|
# Convert any kind of object to a short string.
|
47
47
|
def flatten(object)
|
48
|
-
s = case object
|
48
|
+
s = case object
|
49
49
|
when nil then ''
|
50
50
|
when object.instance_of?(String) then object
|
51
51
|
when String then String.new(object) # convert string subclasses to strings
|
@@ -64,7 +64,7 @@ module NewRelic
|
|
64
64
|
end
|
65
65
|
real_string
|
66
66
|
else
|
67
|
-
truncate(flatten(string), len)
|
67
|
+
truncate(flatten(string), len)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
data/lib/new_relic/command.rb
CHANGED
@@ -15,15 +15,15 @@ module NewRelic
|
|
15
15
|
@options = opt_parser
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def info(message)
|
20
20
|
STDOUT.puts message
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def err(message)
|
24
24
|
STDERR.puts message
|
25
|
-
end
|
26
|
-
|
25
|
+
end
|
26
|
+
|
27
27
|
def initialize(command_line_args)
|
28
28
|
if Hash === command_line_args
|
29
29
|
# command line args is an options hash
|
@@ -37,22 +37,22 @@ module NewRelic
|
|
37
37
|
end
|
38
38
|
@leftover = @options.parse(command_line_args)
|
39
39
|
end
|
40
|
-
rescue OptionParser::ParseError => e
|
40
|
+
rescue OptionParser::ParseError => e
|
41
41
|
raise CommandFailure.new e.message, @options
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
@commands = []
|
45
45
|
def self.inherited(subclass)
|
46
46
|
@commands << subclass
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
cmds = File.expand_path(File.join(File.dirname(__FILE__), 'commands', '*.rb'))
|
50
50
|
Dir[cmds].each{|command| require command }
|
51
|
-
|
51
|
+
|
52
52
|
def self.run
|
53
|
-
|
54
|
-
@command_names = @commands.map
|
55
|
-
|
53
|
+
|
54
|
+
@command_names = @commands.map{ |c| c.command }
|
55
|
+
|
56
56
|
extra = []
|
57
57
|
options = ARGV.options do |opts|
|
58
58
|
script_name = File.basename($0)
|
@@ -74,12 +74,12 @@ module NewRelic
|
|
74
74
|
STDERR.puts "Unrecognized command: #{command}"
|
75
75
|
STDERR.puts options
|
76
76
|
else
|
77
|
-
command_class = @commands.find{ |c| c.command == command}
|
77
|
+
command_class = @commands.find{ |c| c.command == command}
|
78
78
|
command_class.new(extra).run
|
79
79
|
end
|
80
80
|
rescue OptionParser::InvalidOption => e
|
81
81
|
raise NewRelic::Command::CommandFailure, e.message
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
85
|
-
end
|
84
|
+
|
85
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# This is a class for executing commands related to deployment
|
1
|
+
# This is a class for executing commands related to deployment
|
2
2
|
# events. It runs without loading the rails environment
|
3
3
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'net/http'
|
6
6
|
require 'rexml/document'
|
7
7
|
|
8
|
-
# We need to use the Control object but we don't want to load
|
8
|
+
# We need to use the Control object but we don't want to load
|
9
9
|
# the rails/merb environment. The defined? clause is so that
|
10
10
|
# it won't load it twice, something it does when run inside a test
|
11
11
|
require 'new_relic/control' unless defined? NewRelic::Control
|
12
12
|
|
13
13
|
class NewRelic::Command::Deployments < NewRelic::Command
|
14
14
|
attr_reader :config
|
15
|
-
def self.command; "deployments"; end
|
16
|
-
|
15
|
+
def self.command; "deployments"; end
|
16
|
+
|
17
17
|
# Initialize the deployment uploader with command line args.
|
18
18
|
# Use -h to see options.
|
19
19
|
# When command_line_args is a hash, we are invoking directly and
|
@@ -22,7 +22,7 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
22
22
|
# and :changes.
|
23
23
|
#
|
24
24
|
# Will throw CommandFailed exception if there's any error.
|
25
|
-
#
|
25
|
+
#
|
26
26
|
def initialize command_line_args
|
27
27
|
@config = NewRelic::Control.instance
|
28
28
|
super(command_line_args)
|
@@ -31,7 +31,7 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
31
31
|
config.env = @environment if @environment
|
32
32
|
@appname ||= config.app_names[0] || config.env || 'development'
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
# Run the Deployment upload in RPM via Active Resource.
|
36
36
|
# Will possibly print errors and exit the VM
|
37
37
|
def run
|
@@ -39,8 +39,8 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
39
39
|
@description = nil if @description && @description.strip.empty?
|
40
40
|
create_params = {}
|
41
41
|
{
|
42
|
-
:application_id => @appname,
|
43
|
-
:host => Socket.gethostname,
|
42
|
+
:application_id => @appname,
|
43
|
+
:host => Socket.gethostname,
|
44
44
|
:description => @description,
|
45
45
|
:user => @user,
|
46
46
|
:revision => @revision,
|
@@ -49,25 +49,25 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
49
49
|
create_params["deployment[#{k}]"] = v unless v.nil? || v == ''
|
50
50
|
end
|
51
51
|
http = config.http_connection(config.api_server)
|
52
|
-
|
52
|
+
|
53
53
|
uri = "/deployments.xml"
|
54
|
-
|
54
|
+
|
55
55
|
raise "license_key was not set in newrelic.yml for #{config.env}" if config['license_key'].nil?
|
56
56
|
request = Net::HTTP::Post.new(uri, {'x-license-key' => config['license_key']})
|
57
57
|
request.content_type = "application/octet-stream"
|
58
|
-
|
58
|
+
|
59
59
|
request.set_form_data(create_params)
|
60
|
-
|
60
|
+
|
61
61
|
response = http.request(request)
|
62
|
-
|
62
|
+
|
63
63
|
if response.is_a? Net::HTTPSuccess
|
64
64
|
info "Recorded deployment to '#{@appname}' (#{@description || Time.now })"
|
65
65
|
else
|
66
66
|
err_string = REXML::Document.new(response.body).elements['errors/error'].map(&:to_s).join("; ") rescue response.message
|
67
67
|
raise NewRelic::Command::CommandFailure, "Deployment not recorded: #{err_string}"
|
68
|
-
end
|
68
|
+
end
|
69
69
|
rescue SystemCallError, SocketError => e
|
70
|
-
# These include Errno connection errors
|
70
|
+
# These include Errno connection errors
|
71
71
|
err_string = "Transient error attempting to connect to #{config.api_server} (#{e})"
|
72
72
|
raise NewRelic::Command::CommandFailure.new(err_string)
|
73
73
|
rescue NewRelic::Command::CommandFailure
|
@@ -78,9 +78,9 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
78
78
|
raise NewRelic::Command::CommandFailure.new(e.to_s)
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
private
|
83
|
-
|
83
|
+
|
84
84
|
def options
|
85
85
|
OptionParser.new %Q{Usage: #{$0} #{self.class.command} [OPTIONS] ["description"] }, 40 do |o|
|
86
86
|
o.separator "OPTIONS:"
|
@@ -95,11 +95,11 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
95
95
|
"Default: #{@user || '<none>'}") { | u | @user = u }
|
96
96
|
o.on("-r", "--revision=REV", String,
|
97
97
|
"Specify the revision being deployed") { | r | @revision = r }
|
98
|
-
o.on("-c", "--changes",
|
98
|
+
o.on("-c", "--changes",
|
99
99
|
"Read in a change log from the standard input") { @changelog = STDIN.read }
|
100
100
|
yield o if block_given?
|
101
101
|
end
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
|
105
105
|
end
|
@@ -5,9 +5,9 @@ require 'erb'
|
|
5
5
|
class NewRelic::Command::Install < NewRelic::Command
|
6
6
|
|
7
7
|
NO_LICENSE_KEY = "<PASTE LICENSE KEY HERE>"
|
8
|
-
|
9
|
-
def self.command; "install"; end
|
10
|
-
|
8
|
+
|
9
|
+
def self.command; "install"; end
|
10
|
+
|
11
11
|
# Use -h to see options.
|
12
12
|
# When command_line_args is a hash, we are invoking directly and
|
13
13
|
# it's treated as an options with optional string values for
|
@@ -15,7 +15,7 @@ class NewRelic::Command::Install < NewRelic::Command
|
|
15
15
|
# and :changes.
|
16
16
|
#
|
17
17
|
# Will throw CommandFailed exception if there's any error.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
attr_reader :dest_dir, :license_key, :generated_for_user, :quiet, :src_file, :app_name
|
20
20
|
def initialize command_line_args={}
|
21
21
|
super command_line_args
|
@@ -32,20 +32,20 @@ class NewRelic::Command::Install < NewRelic::Command
|
|
32
32
|
raise CommandFailure.new("Application name required.", @options) unless @app_name && @app_name.size > 0
|
33
33
|
@generated_for_user ||= @user_string || ""
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def run
|
37
37
|
dest_file = File.expand_path(@dest_dir + "/newrelic.yml")
|
38
38
|
if File.exist?(dest_file)
|
39
39
|
raise NewRelic::Command::CommandFailure, "newrelic.yml file already exists. Move it out of the way."
|
40
40
|
end
|
41
41
|
File.open(dest_file, 'w') { | out | out.puts(content) }
|
42
|
-
|
42
|
+
|
43
43
|
puts <<-EOF unless quiet
|
44
44
|
|
45
|
-
Installed a default configuration file at
|
45
|
+
Installed a default configuration file at
|
46
46
|
#{dest_file}.
|
47
47
|
EOF
|
48
|
-
puts <<-EOF unless quiet || @license_key != NO_LICENSE_KEY
|
48
|
+
puts <<-EOF unless quiet || @license_key != NO_LICENSE_KEY
|
49
49
|
|
50
50
|
To monitor your application in production mode, sign up for an account
|
51
51
|
at www.newrelic.com, and replace the newrelic.yml file with the one
|
@@ -56,17 +56,27 @@ you receive upon registration.
|
|
56
56
|
E-mail support@newrelic.com with any problems or questions.
|
57
57
|
|
58
58
|
EOF
|
59
|
-
|
59
|
+
puts <<-EOF
|
60
|
+
|
61
|
+
Installing the plugin from Rubyforge is deprecated. This repository will not be updated after January 2011
|
62
|
+
|
63
|
+
Please use one of the following options:
|
64
|
+
|
65
|
+
Gems: gem install newrelic_rpm
|
66
|
+
|
67
|
+
Github! git clone git://github.com/newrelic/rpm.git vendor/plugins/newrelic_rpm
|
68
|
+
|
69
|
+
EOF
|
60
70
|
end
|
61
|
-
|
71
|
+
|
62
72
|
def content
|
63
|
-
@src_file ||= File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","newrelic.yml"))
|
73
|
+
@src_file ||= File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","newrelic.yml"))
|
64
74
|
template = File.read(@src_file)
|
65
75
|
ERB.new(template).result(binding)
|
66
76
|
end
|
67
|
-
|
77
|
+
|
68
78
|
private
|
69
|
-
|
79
|
+
|
70
80
|
def options
|
71
81
|
OptionParser.new "Usage: #{$0} #{self.class.command} [ OPTIONS] 'application name'", 40 do |o|
|
72
82
|
o.on("-l", "--license_key=NAME", String,
|
@@ -76,6 +86,6 @@ E-mail support@newrelic.com with any problems or questions.
|
|
76
86
|
yield o if block_given?
|
77
87
|
end
|
78
88
|
end
|
79
|
-
|
80
|
-
|
89
|
+
|
90
|
+
|
81
91
|
end
|
data/lib/new_relic/control.rb
CHANGED
@@ -11,30 +11,30 @@ require 'new_relic/control/configuration'
|
|
11
11
|
require 'new_relic/control/server_methods'
|
12
12
|
require 'new_relic/control/instrumentation'
|
13
13
|
|
14
|
-
module NewRelic
|
15
|
-
|
14
|
+
module NewRelic
|
15
|
+
|
16
16
|
# The Control is a singleton responsible for the startup and
|
17
|
-
# initialization sequence. The initializer uses a LocalEnvironment to
|
17
|
+
# initialization sequence. The initializer uses a LocalEnvironment to
|
18
18
|
# detect the framework and instantiates the framework specific
|
19
19
|
# subclass.
|
20
20
|
#
|
21
21
|
# The Control also implements some of the public API for the agent.
|
22
|
-
#
|
22
|
+
#
|
23
23
|
class Control
|
24
24
|
# used for framework-specific subclasses
|
25
25
|
module Frameworks; end
|
26
|
-
|
26
|
+
|
27
27
|
include Profiling
|
28
28
|
include LoggingMethods
|
29
29
|
include Configuration
|
30
30
|
include ServerMethods
|
31
31
|
include Instrumentation
|
32
|
-
|
32
|
+
|
33
33
|
# The env is the setting used to identify which section of the newrelic.yml
|
34
34
|
# to load. This defaults to a framework specific value, such as ENV['RAILS_ENV']
|
35
35
|
# but can be overridden as long as you set it before calling #init_plugin
|
36
36
|
attr_writer :env
|
37
|
-
|
37
|
+
|
38
38
|
attr_reader :local_env
|
39
39
|
|
40
40
|
module ClassMethods
|
@@ -42,7 +42,7 @@ module NewRelic
|
|
42
42
|
def instance
|
43
43
|
@instance ||= new_instance
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# Create the concrete class for environment specific behavior:
|
47
47
|
def new_instance
|
48
48
|
@local_env = NewRelic::LocalEnvironment.new
|
@@ -72,7 +72,7 @@ module NewRelic
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
extend ClassMethods
|
75
|
-
|
75
|
+
|
76
76
|
# Initialize the plugin/gem and start the agent. This does the necessary configuration based on the
|
77
77
|
# framework environment and determines whether or not to start the agent. If the
|
78
78
|
# agent is not going to be started then it loads the agent shim which has stubs
|
@@ -81,8 +81,8 @@ module NewRelic
|
|
81
81
|
# This may be invoked multiple times, as long as you don't attempt to uninstall
|
82
82
|
# the agent after it has been started.
|
83
83
|
#
|
84
|
-
# If the plugin is initialized and it determines that the agent is not enabled, it
|
85
|
-
# will skip starting it and install the shim. But if you later call this with
|
84
|
+
# If the plugin is initialized and it determines that the agent is not enabled, it
|
85
|
+
# will skip starting it and install the shim. But if you later call this with
|
86
86
|
# <tt>:agent_enabled => true</tt>, then it will install the real agent and start it.
|
87
87
|
#
|
88
88
|
# What determines whether the agent is launched is the result of calling agent_enabled?
|
@@ -94,17 +94,17 @@ module NewRelic
|
|
94
94
|
#
|
95
95
|
def init_plugin(options={})
|
96
96
|
options['app_name'] = ENV['NEWRELIC_APP_NAME'] if ENV['NEWRELIC_APP_NAME']
|
97
|
-
|
97
|
+
|
98
98
|
require 'new_relic/agent'
|
99
|
-
|
99
|
+
|
100
100
|
# Load the DJ injection now. If you do it sooner, DJ might not be loaded and
|
101
101
|
# you'll miss it.
|
102
102
|
require 'new_relic/delayed_job_injection'
|
103
|
-
|
103
|
+
|
104
104
|
# Merge the stringified options into the config as overrides:
|
105
105
|
logger_override = options.delete(:log)
|
106
106
|
environment_name = options.delete(:env) and self.env = environment_name
|
107
|
-
dispatcher = options.delete(:dispatcher) and @local_env.dispatcher = dispatcher
|
107
|
+
dispatcher = options.delete(:dispatcher) and @local_env.dispatcher = dispatcher
|
108
108
|
dispatcher_instance_id = options.delete(:dispatcher_instance_id) and @local_env.dispatcher_instance_id = dispatcher_instance_id
|
109
109
|
|
110
110
|
# Clear out the settings, if they've already been loaded. It may be that
|
@@ -135,12 +135,12 @@ module NewRelic
|
|
135
135
|
install_shim
|
136
136
|
end
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# Install the real agent into the Agent module, and issue the start command.
|
140
140
|
def start_agent
|
141
141
|
NewRelic::Agent.agent.start
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
# True if dev mode or monitor mode are enabled, and we are running
|
145
145
|
# inside a valid dispatcher like mongrel or passenger. Can be overridden
|
146
146
|
# by NEWRELIC_ENABLE env variable, monitor_daemons config option when true, or
|
@@ -148,14 +148,14 @@ module NewRelic
|
|
148
148
|
def agent_enabled?
|
149
149
|
return false if !developer_mode? && !monitor_mode?
|
150
150
|
return self['agent_enabled'].to_s =~ /true|on|yes/i if !self['agent_enabled'].nil? && self['agent_enabled'] != 'auto'
|
151
|
-
return false if ENV['NEWRELIC_ENABLE'].to_s =~ /false|off|no/i
|
151
|
+
return false if ENV['NEWRELIC_ENABLE'].to_s =~ /false|off|no/i
|
152
152
|
return true if self['monitor_daemons'].to_s =~ /true|on|yes/i
|
153
153
|
return true if ENV['NEWRELIC_ENABLE'].to_s =~ /true|on|yes/i
|
154
154
|
# When in 'auto' mode the agent is enabled if there is a known
|
155
155
|
# dispatcher running
|
156
156
|
return true if @local_env.dispatcher != nil
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
def app
|
160
160
|
@local_env.framework
|
161
161
|
end
|
@@ -164,17 +164,17 @@ module NewRelic
|
|
164
164
|
def to_s
|
165
165
|
"Control[#{self.app}]"
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
protected
|
169
|
-
|
169
|
+
|
170
170
|
# Append framework specific environment information for uploading to
|
171
171
|
# the server for change detection. Override in subclasses
|
172
172
|
def append_environment_info; end
|
173
|
-
|
173
|
+
|
174
174
|
def config_file
|
175
175
|
File.expand_path(File.join(root,"config","newrelic.yml"))
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
def initialize local_env, config_file_override=nil
|
179
179
|
@local_env = local_env
|
180
180
|
@instrumentation_files = []
|
@@ -194,10 +194,10 @@ module NewRelic
|
|
194
194
|
puts e.backtrace.join("\n")
|
195
195
|
raise "Error reading newrelic.yml file: #{e}"
|
196
196
|
end
|
197
|
-
|
197
|
+
|
198
198
|
def newrelic_root
|
199
199
|
self.class.newrelic_root
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
end
|
203
203
|
end
|