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
data/CHANGELOG
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
v2.13.1
|
2
|
+
* Add missing require in rails 3 framework control
|
3
|
+
|
1
4
|
v2.13.0
|
2
5
|
* developer mode is now a rack middleware and can be used on any framework;
|
3
6
|
it is no longer supported automatically on versions of Rails prior to 2.3;
|
@@ -63,6 +66,7 @@ v2.11.0
|
|
63
66
|
* optimizations to background thread, controller instrumentation, memory
|
64
67
|
usage
|
65
68
|
* add logger method to public_api
|
69
|
+
* support list notation for ignored exceptions in the newrelic.yml
|
66
70
|
|
67
71
|
v2.10.8
|
68
72
|
* fix bug in delayed_job instrumentation that caused the job queue sampler
|
data/lib/new_relic/agent.rb
CHANGED
@@ -12,11 +12,11 @@
|
|
12
12
|
#
|
13
13
|
# == Getting Started
|
14
14
|
# For instructions on installation and setup, see
|
15
|
-
# the README[link:./files/README_rdoc.html] file.
|
15
|
+
# the README[link:./files/README_rdoc.html] file.
|
16
16
|
#
|
17
17
|
# == Using with Rack/Metal
|
18
18
|
#
|
19
|
-
# To instrument Rack middlwares or Metal apps, refer to the docs in
|
19
|
+
# To instrument Rack middlwares or Metal apps, refer to the docs in
|
20
20
|
# NewRelic::Agent::Instrumentation::Rack.
|
21
21
|
#
|
22
22
|
# == Agent API
|
@@ -24,7 +24,7 @@
|
|
24
24
|
# For details on the Agent API, refer to NewRelic::Agent.
|
25
25
|
#
|
26
26
|
# == Customizing RPM
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# For detailed information on customizing the RPM Agent
|
29
29
|
# please visit our {support and documentation site}[http://support.newrelic.com].
|
30
30
|
#
|
@@ -32,7 +32,7 @@ module NewRelic
|
|
32
32
|
# == Agent APIs
|
33
33
|
# This module contains the public API methods for the Agent.
|
34
34
|
#
|
35
|
-
# For adding custom instrumentation to method invocations, refer to
|
35
|
+
# For adding custom instrumentation to method invocations, refer to
|
36
36
|
# the docs in the class NewRelic::Agent::MethodTracer.
|
37
37
|
#
|
38
38
|
# For information on how to customize the controller
|
@@ -71,7 +71,7 @@ module NewRelic
|
|
71
71
|
require 'new_relic/noticed_error'
|
72
72
|
require 'new_relic/histogram'
|
73
73
|
require 'new_relic/timer_lib'
|
74
|
-
|
74
|
+
|
75
75
|
require 'new_relic/agent/chained_call'
|
76
76
|
require 'new_relic/agent/agent'
|
77
77
|
require 'new_relic/agent/shim_agent'
|
@@ -84,7 +84,7 @@ module NewRelic
|
|
84
84
|
require 'new_relic/agent/sampler'
|
85
85
|
|
86
86
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
87
|
-
|
87
|
+
|
88
88
|
require 'new_relic/agent/samplers/cpu_sampler'
|
89
89
|
require 'new_relic/agent/samplers/memory_sampler'
|
90
90
|
require 'new_relic/agent/samplers/object_sampler'
|
@@ -92,29 +92,29 @@ module NewRelic
|
|
92
92
|
require 'set'
|
93
93
|
require 'thread'
|
94
94
|
require 'resolv'
|
95
|
-
|
95
|
+
|
96
96
|
# An exception that is thrown by the server if the agent license is invalid.
|
97
97
|
class LicenseException < StandardError; end
|
98
|
-
|
98
|
+
|
99
99
|
# An exception that forces an agent to stop reporting until its mongrel is restarted.
|
100
100
|
class ForceDisconnectException < StandardError; end
|
101
|
-
|
101
|
+
|
102
102
|
# An exception that forces an agent to restart.
|
103
103
|
class ForceRestartException < StandardError; end
|
104
|
-
|
104
|
+
|
105
105
|
# Used to blow out of a periodic task without logging a an error, such as for routine
|
106
106
|
# failures.
|
107
107
|
class ServerConnectionException < StandardError; end
|
108
|
-
|
108
|
+
|
109
109
|
# Used for when a transaction trace or error report has too much
|
110
110
|
# data, so we reset the queue to clear the extra-large item
|
111
111
|
class PostTooBigException < ServerConnectionException; end
|
112
|
-
|
112
|
+
|
113
113
|
# Reserved for future use. Meant to represent a problem on the server side.
|
114
114
|
class ServerError < StandardError; end
|
115
115
|
|
116
116
|
class BackgroundLoadingError < StandardError; end
|
117
|
-
|
117
|
+
|
118
118
|
@agent = nil
|
119
119
|
|
120
120
|
# The singleton Agent instance. Used internally.
|
@@ -122,11 +122,11 @@ module NewRelic
|
|
122
122
|
raise "Plugin not initialized!" if @agent.nil?
|
123
123
|
@agent
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
def agent= new_instance #:nodoc:
|
127
127
|
@agent = new_instance
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
alias instance agent #:nodoc:
|
131
131
|
|
132
132
|
# Get or create a statistics gatherer that will aggregate numerical data
|
@@ -140,18 +140,18 @@ module NewRelic
|
|
140
140
|
def get_stats(metric_name, use_scope=false)
|
141
141
|
@agent.stats_engine.get_stats(metric_name, use_scope)
|
142
142
|
end
|
143
|
-
|
144
|
-
alias get_stats_no_scope get_stats
|
145
|
-
|
143
|
+
|
144
|
+
alias get_stats_no_scope get_stats
|
145
|
+
|
146
146
|
# Get the logger for the agent. Available after the agent has initialized.
|
147
147
|
# This sends output to the agent log file.
|
148
148
|
def logger
|
149
149
|
NewRelic::Control.instance.log
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
# Call this to manually start the Agent in situations where the Agent does
|
153
153
|
# not auto-start.
|
154
|
-
#
|
154
|
+
#
|
155
155
|
# When the app environment loads, so does the Agent. However, the
|
156
156
|
# Agent will only connect to RPM if a web front-end is found. If
|
157
157
|
# you want to selectively monitor ruby processes that don't use
|
@@ -168,15 +168,15 @@ module NewRelic
|
|
168
168
|
raise unless Hash === options
|
169
169
|
NewRelic::Control.instance.init_plugin({ :agent_enabled => true, :sync_startup => true }.merge(options))
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
# Register this method as a callback for processes that fork
|
173
|
-
# jobs.
|
173
|
+
# jobs.
|
174
174
|
#
|
175
175
|
# If the master/parent connects to the agent prior to forking the
|
176
176
|
# agent in the forked process will use that agent_run. Otherwise
|
177
177
|
# the forked process will establish a new connection with the
|
178
178
|
# server.
|
179
|
-
#
|
179
|
+
#
|
180
180
|
# Use this especially when you fork the process to run background
|
181
181
|
# jobs or other work. If you are doing this with a web dispatcher
|
182
182
|
# that forks worker processes then you will need to force the
|
@@ -184,17 +184,17 @@ module NewRelic
|
|
184
184
|
# Unicorn are already handled, nothing special needed for them.
|
185
185
|
#
|
186
186
|
# Options:
|
187
|
-
# * <tt>:force_reconnect => true</tt> to force the spawned process to
|
187
|
+
# * <tt>:force_reconnect => true</tt> to force the spawned process to
|
188
188
|
# establish a new connection, such as when forking a long running process.
|
189
189
|
# The default is false--it will only connect to the server if the parent
|
190
190
|
# had not connected.
|
191
|
-
# * <tt>:keep_retrying => false</tt> if we try to initiate a new
|
191
|
+
# * <tt>:keep_retrying => false</tt> if we try to initiate a new
|
192
192
|
# connection, this tells me to only try it once so this method returns
|
193
193
|
# quickly if there is some kind of latency with the server.
|
194
194
|
def after_fork(options={})
|
195
195
|
agent.after_fork(options)
|
196
196
|
end
|
197
|
-
|
197
|
+
|
198
198
|
# Clear out any unsent metric data.
|
199
199
|
def reset_stats
|
200
200
|
agent.reset_stats
|
@@ -204,7 +204,7 @@ module NewRelic
|
|
204
204
|
# and kills the background thread.
|
205
205
|
def shutdown
|
206
206
|
agent.shutdown
|
207
|
-
end
|
207
|
+
end
|
208
208
|
|
209
209
|
# Add instrumentation files to the agent. The argument should be
|
210
210
|
# a glob matching ruby scripts which will be executed at the time
|
@@ -229,21 +229,21 @@ module NewRelic
|
|
229
229
|
# NewRelic::Agent.set_sql_obfuscator(:replace) do |sql|
|
230
230
|
# my_obfuscator(sql)
|
231
231
|
# end
|
232
|
-
#
|
232
|
+
#
|
233
233
|
def set_sql_obfuscator(type = :replace, &block)
|
234
234
|
agent.set_sql_obfuscator type, &block
|
235
235
|
end
|
236
|
-
|
237
|
-
|
236
|
+
|
237
|
+
|
238
238
|
# This method sets the state of sql recording in the transaction
|
239
239
|
# sampler feature. Within the given block, no sql will be recorded
|
240
240
|
#
|
241
241
|
# usage:
|
242
242
|
#
|
243
243
|
# NewRelic::Agent.disable_sql_recording do
|
244
|
-
# ...
|
244
|
+
# ...
|
245
245
|
# end
|
246
|
-
#
|
246
|
+
#
|
247
247
|
def disable_sql_recording
|
248
248
|
state = agent.set_record_sql(false)
|
249
249
|
begin
|
@@ -252,9 +252,9 @@ module NewRelic
|
|
252
252
|
agent.set_record_sql(state)
|
253
253
|
end
|
254
254
|
end
|
255
|
-
|
255
|
+
|
256
256
|
# This method disables the recording of transaction traces in the given
|
257
|
-
# block. See also #disable_all_tracing
|
257
|
+
# block. See also #disable_all_tracing
|
258
258
|
def disable_transaction_tracing
|
259
259
|
state = agent.set_record_tt(false)
|
260
260
|
begin
|
@@ -263,7 +263,7 @@ module NewRelic
|
|
263
263
|
agent.set_record_tt(state)
|
264
264
|
end
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
# Cancel the collection of the current transaction in progress, if
|
268
268
|
# any. Only affects the transaction started on this thread once
|
269
269
|
# it has started and before it has completed.
|
@@ -273,7 +273,7 @@ module NewRelic
|
|
273
273
|
NewRelic::Agent::Instrumentation::MetricFrame.abort_transaction!
|
274
274
|
end
|
275
275
|
end
|
276
|
-
|
276
|
+
|
277
277
|
# Yield to the block without collecting any metrics or traces in
|
278
278
|
# any of the subsequent calls. If executed recursively, will keep
|
279
279
|
# track of the first entry point and turn on tracing again after
|
@@ -285,10 +285,10 @@ module NewRelic
|
|
285
285
|
ensure
|
286
286
|
agent.pop_trace_execution_flag
|
287
287
|
end
|
288
|
-
|
288
|
+
|
289
289
|
# Check to see if we are capturing metrics currently on this thread.
|
290
290
|
def is_execution_traced?
|
291
|
-
Thread.current[:newrelic_untraced].nil? || Thread.current[:newrelic_untraced].last != false
|
291
|
+
Thread.current[:newrelic_untraced].nil? || Thread.current[:newrelic_untraced].last != false
|
292
292
|
end
|
293
293
|
|
294
294
|
# Set a filter to be applied to errors that RPM will track. The
|
@@ -296,17 +296,17 @@ module NewRelic
|
|
296
296
|
# different from the original exception) or nil to ignore this
|
297
297
|
# exception.
|
298
298
|
#
|
299
|
-
# The block is yielded to with the exception to filter.
|
300
|
-
#
|
299
|
+
# The block is yielded to with the exception to filter.
|
300
|
+
#
|
301
301
|
# Return the new block or the existing filter Proc if no block is passed.
|
302
302
|
#
|
303
303
|
def ignore_error_filter(&block)
|
304
304
|
agent.error_collector.ignore_error_filter(&block)
|
305
305
|
end
|
306
|
-
|
306
|
+
|
307
307
|
# Record the given error in RPM. It will be passed through the
|
308
308
|
# #ignore_error_filter if there is one.
|
309
|
-
#
|
309
|
+
#
|
310
310
|
# * <tt>exception</tt> is the exception which will be recorded. May also be
|
311
311
|
# an error message.
|
312
312
|
# Options:
|
@@ -328,11 +328,11 @@ module NewRelic
|
|
328
328
|
def add_custom_parameters(params)
|
329
329
|
NewRelic::Agent::Instrumentation::MetricFrame.add_custom_parameters(params)
|
330
330
|
end
|
331
|
-
|
331
|
+
|
332
332
|
# The #add_request_parameters method is aliased to #add_custom_parameters
|
333
333
|
# and is now deprecated.
|
334
334
|
alias add_request_parameters add_custom_parameters #:nodoc:
|
335
|
-
|
335
|
+
|
336
336
|
# Yield to a block that is run with a database metric name
|
337
337
|
# context. This means the Database instrumentation will use this
|
338
338
|
# for the metric name if it does not otherwise know about a model.
|
@@ -348,9 +348,9 @@ module NewRelic
|
|
348
348
|
yield
|
349
349
|
end
|
350
350
|
end
|
351
|
-
|
352
|
-
# Record a web transaction from an external source. This will
|
353
|
-
# process the response time, error, and score an apdex value.
|
351
|
+
|
352
|
+
# Record a web transaction from an external source. This will
|
353
|
+
# process the response time, error, and score an apdex value.
|
354
354
|
#
|
355
355
|
# First argument is a float value, time in seconds. Option
|
356
356
|
# keys are strings.
|
@@ -363,7 +363,7 @@ module NewRelic
|
|
363
363
|
# provided.
|
364
364
|
#
|
365
365
|
# == Error options
|
366
|
-
# Provide one of the following:
|
366
|
+
# Provide one of the following:
|
367
367
|
# * <tt>'is_error' => true</tt> if an unknown error occurred
|
368
368
|
# * <tt>'error_message' => msg</tt> if an error message is available
|
369
369
|
# * <tt>'exception' => exception</tt> if a ruby exception is recorded
|
@@ -378,5 +378,5 @@ module NewRelic
|
|
378
378
|
def record_transaction(response_sec, options = {})
|
379
379
|
agent.record_transaction(response_sec, options)
|
380
380
|
end
|
381
|
-
end
|
382
|
-
end
|
381
|
+
end
|
382
|
+
end
|
@@ -28,7 +28,7 @@ module NewRelic
|
|
28
28
|
|
29
29
|
|
30
30
|
def initialize
|
31
|
-
|
31
|
+
|
32
32
|
@launch_time = Time.now
|
33
33
|
|
34
34
|
@metric_ids = {}
|
@@ -68,10 +68,10 @@ module NewRelic
|
|
68
68
|
metric ||= options['uri'] # normalize this with url rules
|
69
69
|
raise "metric or uri arguments required" unless metric
|
70
70
|
metric_info = NewRelic::MetricParser.for_metric_named(metric)
|
71
|
-
|
71
|
+
|
72
72
|
if metric_info.is_web_transaction?
|
73
73
|
NewRelic::Agent::Instrumentation::MetricFrame.record_apdex(metric_info, duration_seconds, duration_seconds, is_error)
|
74
|
-
histogram.process(duration_seconds)
|
74
|
+
histogram.process(duration_seconds)
|
75
75
|
end
|
76
76
|
metrics = metric_info.summary_metrics
|
77
77
|
|
@@ -80,12 +80,16 @@ module NewRelic
|
|
80
80
|
stats = stats_engine.get_stats_no_scope(name)
|
81
81
|
stats.record_data_point(duration_seconds)
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
if is_error
|
85
|
-
if
|
86
|
-
e =
|
87
|
-
|
85
|
+
if options['exception']
|
86
|
+
e = options['exception']
|
87
|
+
elsif options['error_message']
|
88
|
+
e = Exception.new options['error_message']
|
89
|
+
else
|
90
|
+
e = Exception.new 'Unknown Error'
|
88
91
|
end
|
92
|
+
error_collector.notice_error e, :uri => options['uri'], :metric => metric
|
89
93
|
end
|
90
94
|
# busy time ?
|
91
95
|
end
|
@@ -100,7 +104,7 @@ module NewRelic
|
|
100
104
|
# not assume the agent started.
|
101
105
|
#
|
102
106
|
# The call is idempotent, but not re-entrant.
|
103
|
-
#
|
107
|
+
#
|
104
108
|
# * It clears any metrics carried over from the parent process
|
105
109
|
# * Restarts the sampler thread if necessary
|
106
110
|
# * Initiates a new agent run and worker loop unless that was done
|
@@ -141,7 +145,7 @@ module NewRelic
|
|
141
145
|
def started?
|
142
146
|
@started
|
143
147
|
end
|
144
|
-
|
148
|
+
|
145
149
|
# Return nil if not yet connected, true if successfully started
|
146
150
|
# and false if we failed to start.
|
147
151
|
def connected?
|
@@ -264,7 +268,7 @@ module NewRelic
|
|
264
268
|
@slowest_transaction_threshold = @slowest_transaction_threshold.to_f
|
265
269
|
|
266
270
|
log.warn "Agent is configured to send raw SQL to RPM service" if @record_sql == :raw
|
267
|
-
|
271
|
+
|
268
272
|
case
|
269
273
|
when !control.monitor_mode?
|
270
274
|
log.warn "Agent configured not to send data in this environment - edit newrelic.yml to change this"
|
@@ -272,25 +276,25 @@ module NewRelic
|
|
272
276
|
log.error "No license key found. Please edit your newrelic.yml file and insert your license key."
|
273
277
|
when control.license_key.length != 40
|
274
278
|
log.error "Invalid license key: #{control.license_key}"
|
275
|
-
when [:passenger, :unicorn].include?(control.dispatcher)
|
279
|
+
when [:passenger, :unicorn].include?(control.dispatcher)
|
276
280
|
log.info "Connecting workers after forking."
|
277
281
|
else
|
278
282
|
# Do the connect in the foreground if we are in sync mode
|
279
283
|
NewRelic::Agent.disable_all_tracing { connect(:keep_retrying => false) } if control.sync_startup
|
280
|
-
|
284
|
+
|
281
285
|
# Start the event loop and initiate connection if necessary
|
282
286
|
start_worker_thread
|
283
|
-
|
287
|
+
|
284
288
|
# Our shutdown handler needs to run after other shutdown handlers
|
285
289
|
# that may be doing things like running the app (hello sinatra).
|
286
290
|
if control.send_data_on_exit
|
287
|
-
if RUBY_VERSION =~ /rubinius/i
|
291
|
+
if RUBY_VERSION =~ /rubinius/i
|
288
292
|
list = at_exit { shutdown }
|
289
293
|
# move the shutdown handler to the front of the list, to
|
290
294
|
# execute last:
|
291
295
|
list.unshift(list.pop)
|
292
296
|
elsif !defined?(JRuby) or !defined?(Sinatra::Application)
|
293
|
-
at_exit { at_exit { shutdown } }
|
297
|
+
at_exit { at_exit { shutdown } }
|
294
298
|
end
|
295
299
|
end
|
296
300
|
end
|
@@ -334,6 +338,7 @@ module NewRelic
|
|
334
338
|
else
|
335
339
|
@transaction_sampler.enable # otherwise ensure TT's are enabled
|
336
340
|
end
|
341
|
+
|
337
342
|
log.info "Reporting performance data every #{@report_period} seconds."
|
338
343
|
log.debug "Running worker loop"
|
339
344
|
# Note if the agent attempts to report more frequently than allowed by the server
|
@@ -445,7 +450,7 @@ module NewRelic
|
|
445
450
|
end
|
446
451
|
log.debug "Transaction tracing threshold is #{@slowest_transaction_threshold} seconds."
|
447
452
|
else
|
448
|
-
log.debug "Transaction traces will not be sent to the RPM service."
|
453
|
+
log.debug "Transaction traces will not be sent to the RPM service."
|
449
454
|
end
|
450
455
|
|
451
456
|
# Ask for permission to collect error data
|
@@ -495,7 +500,7 @@ module NewRelic
|
|
495
500
|
def determine_home_directory
|
496
501
|
control.root
|
497
502
|
end
|
498
|
-
|
503
|
+
|
499
504
|
def is_application_spawner?
|
500
505
|
$0 =~ /ApplicationSpawner|^unicorn\S* master/
|
501
506
|
end
|
@@ -551,7 +556,7 @@ module NewRelic
|
|
551
556
|
# times exceed our threshold (to avoid unnecessary overhead
|
552
557
|
# of running explains on fast queries.)
|
553
558
|
options = { :keep_backtraces => true }
|
554
|
-
options[:record_sql] = @record_sql unless @record_sql == :off
|
559
|
+
options[:record_sql] = @record_sql unless @record_sql == :off
|
555
560
|
options[:explain_sql] = @explain_threshold if @explain_enabled
|
556
561
|
traces = @traces.collect {|trace| trace.prepare_to_send(options)}
|
557
562
|
invoke_remote :transaction_sample_data, @agent_id, traces
|
@@ -627,7 +632,7 @@ module NewRelic
|
|
627
632
|
end
|
628
633
|
|
629
634
|
def send_request(opts)
|
630
|
-
request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'HOST' => opts[:collector].name)
|
635
|
+
request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'HOST' => opts[:collector].name)
|
631
636
|
request.content_type = "application/octet-stream"
|
632
637
|
request.body = opts[:data]
|
633
638
|
|