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,41 +1,41 @@
|
|
1
1
|
module NewRelic
|
2
2
|
class Control
|
3
|
-
|
3
|
+
|
4
4
|
# Structs holding info for the remote server and proxy server
|
5
5
|
class Server < Struct.new :name, :port, :ip #:nodoc:
|
6
6
|
def to_s; "#{name}:#{port}"; end
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
ProxyServer = Struct.new :name, :port, :user, :password #:nodoc:
|
10
|
-
|
10
|
+
|
11
11
|
module ServerMethods
|
12
12
|
|
13
13
|
def server
|
14
|
-
@remote_server ||= server_from_host(nil)
|
14
|
+
@remote_server ||= server_from_host(nil)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def api_server
|
18
|
-
api_host = self['api_host'] || 'rpm.newrelic.com'
|
19
|
-
@api_server ||=
|
18
|
+
api_host = self['api_host'] || 'rpm.newrelic.com'
|
19
|
+
@api_server ||=
|
20
20
|
NewRelic::Control::Server.new \
|
21
|
-
api_host,
|
22
|
-
(self['api_port'] || self['port'] || (use_ssl? ? 443 : 80)).to_i,
|
21
|
+
api_host,
|
22
|
+
(self['api_port'] || self['port'] || (use_ssl? ? 443 : 80)).to_i,
|
23
23
|
nil
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def proxy_server
|
27
27
|
@proxy_server ||=
|
28
|
-
NewRelic::Control::ProxyServer.new self['proxy_host'], self['proxy_port'], self['proxy_user'], self['proxy_pass']
|
28
|
+
NewRelic::Control::ProxyServer.new self['proxy_host'], self['proxy_port'], self['proxy_user'], self['proxy_pass']
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def server_from_host(hostname=nil)
|
32
32
|
host = hostname || self['host'] || 'collector.newrelic.com'
|
33
|
-
|
33
|
+
|
34
34
|
# if the host is not an IP address, turn it into one
|
35
|
-
NewRelic::Control::Server.new host, (self['port'] || (use_ssl? ? 443 : 80)).to_i, convert_to_ip_address(host)
|
35
|
+
NewRelic::Control::Server.new host, (self['port'] || (use_ssl? ? 443 : 80)).to_i, convert_to_ip_address(host)
|
36
36
|
end
|
37
37
|
|
38
|
-
# Look up the ip address of the host using the pure ruby lookup
|
38
|
+
# Look up the ip address of the host using the pure ruby lookup
|
39
39
|
# to prevent blocking. If that fails, fall back to the regular
|
40
40
|
# IPSocket library. Return nil if we can't find the host ip
|
41
41
|
# address and don't have a good default.
|
@@ -56,7 +56,7 @@ module NewRelic
|
|
56
56
|
end
|
57
57
|
ip_address
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
# Return the Net::HTTP with proxy configuration given the NewRelic::Control::Server object.
|
61
61
|
# Default is the collector but for api calls you need to pass api_server
|
62
62
|
#
|
@@ -67,7 +67,7 @@ module NewRelic
|
|
67
67
|
def http_connection(host = nil)
|
68
68
|
host ||= server
|
69
69
|
# Proxy returns regular HTTP if @proxy_host is nil (the default)
|
70
|
-
http_class = Net::HTTP::Proxy(proxy_server.name, proxy_server.port,
|
70
|
+
http_class = Net::HTTP::Proxy(proxy_server.name, proxy_server.port,
|
71
71
|
proxy_server.user, proxy_server.password)
|
72
72
|
http = http_class.new(host.ip || host.name, host.port)
|
73
73
|
log.debug("Http Connection opened to #{host.ip||host.name}:#{host.port}")
|
@@ -21,7 +21,7 @@ Delayed::Worker.class_eval do
|
|
21
21
|
NewRelic::DelayedJobInjection.worker_name = worker_name
|
22
22
|
NewRelic::Agent.manual_start :dispatcher => :delayed_job, :dispatcher_instance_id => dispatcher_instance_id
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
alias initialize_without_new_relic initialize
|
26
26
|
alias initialize initialize_with_new_relic
|
27
27
|
end if defined?(::Delayed::Worker) and not NewRelic::Control.instance['disable_dj']
|
data/lib/new_relic/histogram.rb
CHANGED
@@ -5,85 +5,87 @@
|
|
5
5
|
# Histogram builds a set of buckets of geometrically growing size, with the assumption that most
|
6
6
|
# apps have long-tail response times, and therefore you need the most granularity at the lowest
|
7
7
|
# r/t level.
|
8
|
-
|
8
|
+
module NewRelic
|
9
|
+
class Histogram
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
# Stores statistics for response times falling in a particular range.
|
15
|
-
# A bucket has a min and max response time. A response time event
|
16
|
-
# falls in a bucket if min <= r/t < max. A bucket also
|
17
|
-
# has an associated metric for reporting data to RPM. The
|
18
|
-
# bucket range is encoded in the metic name
|
19
|
-
class Bucket
|
20
|
-
|
21
|
-
attr_reader :min, :max, :stats
|
22
|
-
|
23
|
-
def initialize(min, max = nil)
|
24
|
-
@min = min
|
25
|
-
@max = max
|
11
|
+
# Used to stub out API methods when the agent is not enabled
|
12
|
+
module Shim
|
13
|
+
def process(response_time); end
|
26
14
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# a value < 0 if the value belongs in a bucket with a lower range
|
36
|
-
# you can guess what it returns if the value belongs in a bucket
|
37
|
-
# with a higher range. (Hint: it's not 0, and it's not less than zero.)
|
38
|
-
def process(value)
|
39
|
-
if value < min
|
40
|
-
return -1
|
41
|
-
|
42
|
-
# max == nil means unlimited max (last bucket)
|
43
|
-
elsif max && value >= max
|
44
|
-
return 1
|
15
|
+
# Stores statistics for response times falling in a particular range.
|
16
|
+
# A bucket has a min and max response time. A response time event
|
17
|
+
# falls in a bucket if min <= r/t < max. A bucket also
|
18
|
+
# has an associated metric for reporting data to RPM. The
|
19
|
+
# bucket range is encoded in the metic name
|
20
|
+
class Bucket
|
21
|
+
|
22
|
+
attr_reader :min, :max, :stats
|
45
23
|
|
46
|
-
|
47
|
-
|
48
|
-
|
24
|
+
def initialize(min, max = nil)
|
25
|
+
@min = min
|
26
|
+
@max = max
|
49
27
|
end
|
50
|
-
end
|
51
28
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
29
|
+
def stats
|
30
|
+
NewRelic::Agent.get_stats("Response Times/#{min_millis}/#{max_millis}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# This has return value like <=> but does something more
|
34
|
+
# than simply compare. If the value falls within range for
|
35
|
+
# the bucket, increment count and return 0; otherwise return
|
36
|
+
# a value < 0 if the value belongs in a bucket with a lower range
|
37
|
+
# you can guess what it returns if the value belongs in a bucket
|
38
|
+
# with a higher range. (Hint: it's not 0, and it's not less than zero.)
|
39
|
+
def process(value)
|
40
|
+
if value < min
|
41
|
+
return -1
|
42
|
+
|
43
|
+
# max == nil means unlimited max (last bucket)
|
44
|
+
elsif max && value >= max
|
45
|
+
return 1
|
46
|
+
|
47
|
+
else
|
48
|
+
stats.record_data_point(value)
|
49
|
+
return 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def min_millis
|
54
|
+
(min * 1000).round
|
55
|
+
end
|
56
|
+
|
57
|
+
def max_millis
|
58
|
+
max.nil? ? nil : (max * 1000).round
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_s
|
62
|
+
"#{min_millis} - #{max_millis}: #{stats.call_count}"
|
63
|
+
end
|
62
64
|
end
|
63
|
-
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
66
|
+
attr_reader :buckets
|
67
|
+
|
68
|
+
# Histogram uses apdex T / 10 as its minimum bucket size, and grows from there.
|
69
|
+
# 30 data points should be adequate resolution.
|
70
|
+
def initialize(first_bucket_max = 0.010, bucket_count = 30, multiplier = 1.3)
|
71
|
+
@buckets = []
|
72
|
+
|
73
|
+
min = 0
|
74
|
+
max = first_bucket_max
|
75
|
+
|
76
|
+
(bucket_count - 1).times do
|
77
|
+
@buckets << Bucket.new(min, max)
|
78
|
+
min = max
|
79
|
+
max *= multiplier
|
80
|
+
end
|
81
|
+
@buckets << Bucket.new(max)
|
79
82
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
return if found == 0
|
83
|
+
|
84
|
+
def process(response_time)
|
85
|
+
buckets.each do |bucket|
|
86
|
+
found = bucket.process(response_time)
|
87
|
+
return if found == 0
|
88
|
+
end
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'set'
|
2
2
|
require 'new_relic/version'
|
3
3
|
|
4
|
-
module NewRelic
|
4
|
+
module NewRelic
|
5
5
|
# An instance of LocalEnvironment is responsible for determining
|
6
|
-
# three things:
|
6
|
+
# three things:
|
7
7
|
#
|
8
8
|
# * Framework - :rails, :rails3, :merb, :ruby, :external, :test
|
9
9
|
# * Dispatcher - A supported dispatcher, or nil (:mongrel, :thin, :passenger, :webrick, etc)
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
#
|
12
12
|
# If the environment can't be determined, it will be set to
|
13
13
|
# nil and dispatcher_instance_id will have nil.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# NewRelic::LocalEnvironment should be accessed through NewRelic::Control#env (via the NewRelic::Control singleton).
|
16
16
|
class LocalEnvironment
|
17
17
|
|
@@ -21,15 +21,15 @@ module NewRelic
|
|
21
21
|
attr_reader :mongrel # The mongrel instance, if there is one, captured as a convenience
|
22
22
|
attr_reader :processors # The number of cpus, if detected, or nil
|
23
23
|
alias environment dispatcher
|
24
|
-
|
24
|
+
|
25
25
|
def initialize
|
26
26
|
# Extend self with any any submodules of LocalEnvironment. These can override
|
27
|
-
# the discover methods to discover new framworks and dispatchers.
|
27
|
+
# the discover methods to discover new framworks and dispatchers.
|
28
28
|
NewRelic::LocalEnvironment.constants.each do | const |
|
29
29
|
mod = NewRelic::LocalEnvironment.const_get const
|
30
30
|
self.extend mod if mod.instance_of? Module
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
discover_framework
|
34
34
|
discover_dispatcher
|
35
35
|
@dispatcher = nil if @dispatcher == :none
|
@@ -38,32 +38,32 @@ module NewRelic
|
|
38
38
|
@config = Hash.new
|
39
39
|
end
|
40
40
|
|
41
|
-
# Add the given key/value pair to the app environment
|
41
|
+
# Add the given key/value pair to the app environment
|
42
42
|
# settings. Must pass either a value or a block. Block
|
43
43
|
# is called to get the value and any raised errors are
|
44
44
|
# silently ignored.
|
45
45
|
def append_environment_value name, value = nil
|
46
|
-
value = yield if block_given?
|
46
|
+
value = yield if block_given?
|
47
47
|
@config[name] = value if value
|
48
48
|
rescue Exception
|
49
|
-
# puts "#{e}\n #{e.backtrace.join("\n ")}"
|
50
|
-
raise if @framework == :test
|
49
|
+
# puts "#{e}\n #{e.backtrace.join("\n ")}"
|
50
|
+
raise if @framework == :test
|
51
51
|
end
|
52
52
|
|
53
53
|
def append_gem_list
|
54
54
|
@gems += yield
|
55
55
|
rescue Exception => e
|
56
56
|
# puts "#{e}\n #{e.backtrace.join("\n ")}"
|
57
|
-
raise if @framework == :test
|
57
|
+
raise if @framework == :test
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def append_plugin_list
|
61
61
|
@plugins += yield
|
62
62
|
rescue Exception
|
63
|
-
# puts "#{e}\n #{e.backtrace.join("\n ")}"
|
64
|
-
raise if @framework == :test
|
63
|
+
# puts "#{e}\n #{e.backtrace.join("\n ")}"
|
64
|
+
raise if @framework == :test
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def dispatcher_instance_id
|
68
68
|
if @dispatcher_instance_id.nil?
|
69
69
|
if @dispatcher.nil?
|
@@ -72,7 +72,7 @@ module NewRelic
|
|
72
72
|
end
|
73
73
|
@dispatcher_instance_id
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
# Collect base statistics about the environment and record them for
|
77
77
|
# comparison and change detection.
|
78
78
|
def gather_environment_info
|
@@ -91,7 +91,7 @@ module NewRelic
|
|
91
91
|
end
|
92
92
|
append_environment_value('OS version') { `uname -v` }
|
93
93
|
append_environment_value('OS') { `uname -s` } ||
|
94
|
-
append_environment_value('OS') { ENV['OS'] }
|
94
|
+
append_environment_value('OS') { ENV['OS'] }
|
95
95
|
append_environment_value('Arch') { `uname -p` } ||
|
96
96
|
append_environment_value('Arch') { ENV['PROCESSOR_ARCHITECTURE'] }
|
97
97
|
# See what the number of cpus is, works only on linux.
|
@@ -129,23 +129,23 @@ module NewRelic
|
|
129
129
|
# Returns an associative array
|
130
130
|
def snapshot
|
131
131
|
i = @config.to_a
|
132
|
-
i << [ 'Plugin List', @plugins.to_a] if not @plugins.empty?
|
132
|
+
i << [ 'Plugin List', @plugins.to_a] if not @plugins.empty?
|
133
133
|
i << [ 'Gems', @gems.to_a] if not @gems.empty?
|
134
134
|
i
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def mongrel
|
138
138
|
# Note that the odd defined? sequence is necessary to work around a bug in an older version
|
139
139
|
# of JRuby.
|
140
|
-
return @mongrel if @mongrel || ! (defined?(::Mongrel) && defined?(::Mongrel::HttpServer))
|
140
|
+
return @mongrel if @mongrel || ! (defined?(::Mongrel) && defined?(::Mongrel::HttpServer))
|
141
141
|
ObjectSpace.each_object(Mongrel::HttpServer) do |mongrel|
|
142
142
|
@mongrel = mongrel
|
143
143
|
end unless defined?(::JRuby) && !JRuby.runtime.is_object_space_enabled
|
144
144
|
@mongrel
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
def unicorn
|
148
|
-
return @unicorn if @unicorn || ! (defined?(::Unicorn) && defined?(::Unicorn::HttpServer))
|
148
|
+
return @unicorn if @unicorn || ! (defined?(::Unicorn) && defined?(::Unicorn::HttpServer))
|
149
149
|
ObjectSpace.each_object(Unicorn::HttpServer) do |unicorn|
|
150
150
|
@unicorn = unicorn
|
151
151
|
end unless defined?(::JRuby) && !JRuby.runtime.is_object_space_enabled
|
@@ -159,7 +159,7 @@ module NewRelic
|
|
159
159
|
end
|
160
160
|
|
161
161
|
private
|
162
|
-
|
162
|
+
|
163
163
|
# Although you can override the framework with NEWRELIC_DISPATCHER this
|
164
164
|
# is not advisable since it implies certain api's being available.
|
165
165
|
def discover_dispatcher
|
@@ -169,7 +169,7 @@ module NewRelic
|
|
169
169
|
send 'check_for_'+(dispatchers.shift)
|
170
170
|
end
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
def discover_framework
|
174
174
|
# Although you can override the framework with NEWRELIC_FRAMEWORK this
|
175
175
|
# is not advisable since it implies certain api's being available.
|
@@ -181,14 +181,14 @@ module NewRelic
|
|
181
181
|
when defined?(::NewRelic::TEST) then :test
|
182
182
|
when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
|
183
183
|
when defined?(::Rails) then check_rails_version
|
184
|
-
when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
|
184
|
+
when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
|
185
185
|
when defined?(::NewRelic::IA) then :external
|
186
186
|
else :ruby
|
187
|
-
end
|
187
|
+
end
|
188
188
|
end
|
189
189
|
|
190
190
|
def check_rails_version
|
191
|
-
if Rails::VERSION::MAJOR < 3
|
191
|
+
if Rails::VERSION::MAJOR < 3
|
192
192
|
:rails
|
193
193
|
else
|
194
194
|
:rails3
|
@@ -197,7 +197,7 @@ module NewRelic
|
|
197
197
|
|
198
198
|
def check_for_torquebox
|
199
199
|
return unless defined?(::JRuby) &&
|
200
|
-
( Java::OrgTorqueboxRailsWebDeployers::RailsRackDeployer rescue nil)
|
200
|
+
( Java::OrgTorqueboxRailsWebDeployers::RailsRackDeployer rescue nil)
|
201
201
|
@dispatcher = :torquebox
|
202
202
|
end
|
203
203
|
|
@@ -214,13 +214,13 @@ module NewRelic
|
|
214
214
|
def check_for_webrick
|
215
215
|
return unless defined?(::WEBrick) && defined?(::WEBrick::VERSION)
|
216
216
|
@dispatcher = :webrick
|
217
|
-
if defined?(::OPTIONS) && OPTIONS.respond_to?(:fetch)
|
217
|
+
if defined?(::OPTIONS) && OPTIONS.respond_to?(:fetch)
|
218
218
|
# OPTIONS is set by script/server
|
219
219
|
@dispatcher_instance_id = OPTIONS.fetch(:port)
|
220
220
|
end
|
221
221
|
@dispatcher_instance_id = default_port unless @dispatcher_instance_id
|
222
222
|
end
|
223
|
-
|
223
|
+
|
224
224
|
def check_for_fastcgi
|
225
225
|
return unless defined?(::FCGI)
|
226
226
|
@dispatcher = :fastcgi
|
@@ -230,35 +230,35 @@ module NewRelic
|
|
230
230
|
def check_for_mongrel
|
231
231
|
return unless defined?(::Mongrel) && defined?(::Mongrel::HttpServer)
|
232
232
|
@dispatcher = :mongrel
|
233
|
-
|
233
|
+
|
234
234
|
# Get the port from the server if it's started
|
235
235
|
|
236
236
|
if mongrel && mongrel.respond_to?(:port)
|
237
237
|
@dispatcher_instance_id = mongrel.port.to_s
|
238
238
|
end
|
239
|
-
|
239
|
+
|
240
240
|
# Get the port from the configurator if one was created
|
241
241
|
if @dispatcher_instance_id.nil? && defined?(::Mongrel::Configurator)
|
242
242
|
ObjectSpace.each_object(Mongrel::Configurator) do |mongrel|
|
243
243
|
@dispatcher_instance_id = mongrel.defaults[:port] && mongrel.defaults[:port].to_s
|
244
244
|
end unless defined?(::JRuby) && !JRuby.runtime.is_object_space_enabled
|
245
245
|
end
|
246
|
-
|
246
|
+
|
247
247
|
# Still can't find the port. Let's look at ARGV to fall back
|
248
248
|
@dispatcher_instance_id = default_port if @dispatcher_instance_id.nil?
|
249
249
|
end
|
250
|
-
|
250
|
+
|
251
251
|
def check_for_unicorn
|
252
252
|
return unless defined?(::Unicorn) && defined?(::Unicorn::HttpServer)
|
253
|
-
|
254
|
-
# unlike mongrel, unicorn manages muliple threads and ports, so we
|
253
|
+
|
254
|
+
# unlike mongrel, unicorn manages muliple threads and ports, so we
|
255
255
|
# have to map multiple processes into one instance, as we do with passenger
|
256
256
|
@dispatcher = :unicorn
|
257
257
|
end
|
258
|
-
|
258
|
+
|
259
259
|
def check_for_sinatra
|
260
260
|
return unless defined?(::Sinatra) && defined?(::Sinatra::Base)
|
261
|
-
|
261
|
+
|
262
262
|
begin
|
263
263
|
version = ::Sinatra::VERSION
|
264
264
|
rescue
|
@@ -271,7 +271,7 @@ module NewRelic
|
|
271
271
|
|
272
272
|
@dispatcher = :sinatra
|
273
273
|
end
|
274
|
-
|
274
|
+
|
275
275
|
def check_for_thin
|
276
276
|
if defined?(::Thin) && defined?(::Thin::Server)
|
277
277
|
# This case covers the thin web dispatcher
|
@@ -295,19 +295,19 @@ module NewRelic
|
|
295
295
|
@dispatcher_instance_id = default_port
|
296
296
|
end
|
297
297
|
end
|
298
|
-
|
298
|
+
|
299
299
|
def check_for_litespeed
|
300
300
|
if caller.pop =~ /fcgi-bin\/RailsRunner\.rb/
|
301
301
|
@dispatcher = :litespeed
|
302
302
|
end
|
303
303
|
end
|
304
|
-
|
304
|
+
|
305
305
|
def check_for_passenger
|
306
|
-
if (defined?(::Passenger) && defined?(::Passenger::AbstractServer)) || defined?(::IN_PHUSION_PASSENGER)
|
306
|
+
if (defined?(::Passenger) && defined?(::Passenger::AbstractServer)) || defined?(::IN_PHUSION_PASSENGER)
|
307
307
|
@dispatcher = :passenger
|
308
308
|
end
|
309
309
|
end
|
310
|
-
|
310
|
+
|
311
311
|
|
312
312
|
def default_port
|
313
313
|
require 'optparse'
|
@@ -319,8 +319,8 @@ module NewRelic
|
|
319
319
|
end
|
320
320
|
default_port
|
321
321
|
end
|
322
|
-
|
323
|
-
public
|
322
|
+
|
323
|
+
public
|
324
324
|
def to_s
|
325
325
|
s = "LocalEnvironment["
|
326
326
|
s << @framework.to_s
|