newrelic_rpm 2.9.3 → 2.9.4
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 +6 -1
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +107 -59
- data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +3 -4
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb +4 -7
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +14 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -4
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +4 -4
- data/lib/new_relic/agent/samplers/memory_sampler.rb +3 -1
- data/lib/new_relic/agent/samplers/mongrel_sampler.rb +1 -1
- data/lib/new_relic/agent/stats_engine.rb +8 -1
- data/lib/new_relic/agent/transaction_sampler.rb +2 -1
- data/lib/new_relic/local_environment.rb +2 -2
- data/lib/new_relic/metric_parser.rb +4 -0
- data/lib/new_relic/metric_parser/controller.rb +1 -1
- data/lib/new_relic/metric_spec.rb +7 -3
- data/lib/new_relic/noticed_error.rb +2 -2
- data/lib/new_relic/version.rb +1 -1
- data/newrelic.yml +3 -4
- data/newrelic_rpm.gemspec +2 -2
- data/test/new_relic/agent/active_record_instrumentation_test.rb +3 -0
- data/test/ui/newrelic_helper_test.rb +3 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
v2.9.4
|
2
|
+
* Clamp size of data sent to server
|
3
|
+
* Reset statistics for passenger when forking to avoid erroneous data
|
4
|
+
* Fix problem deserializing errors from the server
|
5
|
+
* Fix incompatibility with postgres introduced in 2.9.
|
6
|
+
|
1
7
|
v2.9.3.
|
2
8
|
* Fix startup failure in Windows due to memory sampler
|
3
9
|
* Add JRuby environment information
|
4
|
-
|
5
10
|
v2.9.2.
|
6
11
|
* change default apdex_t to 0.5 seconds
|
7
12
|
* fix bug in deployments introduced by multi_homed setting
|
data/init.rb
CHANGED
@@ -21,7 +21,7 @@ begin
|
|
21
21
|
if ! defined?(::NEWRELIC_STARTED)
|
22
22
|
::NEWRELIC_STARTED = "#{caller.join("\n")}"
|
23
23
|
|
24
|
-
NewRelic::Control.instance.init_plugin
|
24
|
+
NewRelic::Control.instance.init_plugin(defined?(config) ? {:config => config} : {})
|
25
25
|
else
|
26
26
|
NewRelic::Control.instance.log.debug "Attempt to initialize the plugin twice!"
|
27
27
|
NewRelic::Control.instance.log.debug "Original call: \n#{::NEWRELIC_STARTED}"
|
@@ -202,7 +202,7 @@ module NewRelic::Agent
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
control.log! "New Relic RPM Agent #{NewRelic::VERSION::STRING} Initialized: pid = #{$$}"
|
205
|
-
control.log! "Agent Log found in #{NewRelic::Control.instance.log_file}"
|
205
|
+
control.log! "Agent Log found in #{NewRelic::Control.instance.log_file}" if NewRelic::Control.instance.log_file
|
206
206
|
end
|
207
207
|
|
208
208
|
private
|
@@ -322,10 +322,10 @@ module NewRelic::Agent
|
|
322
322
|
# wait a few seconds for the web server to boot, necessary in development
|
323
323
|
connect_retry_period = 5
|
324
324
|
connect_attempts = 0
|
325
|
-
|
325
|
+
@agent_id = nil
|
326
326
|
begin
|
327
327
|
sleep connect_retry_period.to_i
|
328
|
-
@agent_id
|
328
|
+
@agent_id ||= invoke_remote :start, @local_host, {
|
329
329
|
:pid => $$,
|
330
330
|
:launch_time => @launch_time.to_f,
|
331
331
|
:agent_version => NewRelic::VERSION::STRING,
|
@@ -375,16 +375,14 @@ module NewRelic::Agent
|
|
375
375
|
# retry logic
|
376
376
|
connect_attempts += 1
|
377
377
|
case connect_attempts
|
378
|
-
when 1..
|
379
|
-
connect_retry_period, period_msg = 5, nil
|
380
|
-
when 6..10 then
|
381
|
-
connect_retry_period, period_msg = 30, nil
|
382
|
-
when 11..20 then
|
378
|
+
when 1..2
|
383
379
|
connect_retry_period, period_msg = 60, "1 minute"
|
380
|
+
when 3..5 then
|
381
|
+
connect_retry_period, period_msg = 60 * 2, "2 minutes"
|
384
382
|
else
|
385
383
|
connect_retry_period, period_msg = 10*60, "10 minutes"
|
386
384
|
end
|
387
|
-
log.info "Will re-attempt in #{period_msg}"
|
385
|
+
log.info "Will re-attempt in #{period_msg}"
|
388
386
|
retry
|
389
387
|
end
|
390
388
|
end
|
@@ -445,14 +443,23 @@ module NewRelic::Agent
|
|
445
443
|
unless @traces.empty?
|
446
444
|
now = Time.now
|
447
445
|
log.debug "Sending (#{@traces.length}) transaction traces"
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
446
|
+
begin
|
447
|
+
# take the traces and prepare them for sending across the
|
448
|
+
# wire. This includes gathering SQL explanations, stripping
|
449
|
+
# out stack traces, and normalizing SQL. note that we
|
450
|
+
# explain only the sql statements whose segments' execution
|
451
|
+
# times exceed our threshold (to avoid unnecessary overhead
|
452
|
+
# of running explains on fast queries.)
|
453
|
+
traces = @traces.collect {|trace| trace.prepare_to_send(:explain_sql => @explain_threshold, :record_sql => @record_sql, :keep_backtraces => true, :explain_enabled => @explain_enabled)}
|
454
|
+
|
455
|
+
|
456
|
+
invoke_remote :transaction_sample_data, @agent_id, traces
|
457
|
+
rescue PostTooBigException
|
458
|
+
# we tried to send too much data, drop the first trace and
|
459
|
+
# try again
|
460
|
+
@traces.shift
|
461
|
+
retry
|
462
|
+
end
|
456
463
|
|
457
464
|
log.debug "#{now}: sent slowest sample (#{@agent_id}) in #{Time.now - now} seconds"
|
458
465
|
end
|
@@ -472,38 +479,57 @@ module NewRelic::Agent
|
|
472
479
|
@unsent_errors = @error_collector.harvest_errors(@unsent_errors)
|
473
480
|
if @unsent_errors && @unsent_errors.length > 0
|
474
481
|
log.debug "Sending #{@unsent_errors.length} errors"
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
482
|
+
begin
|
483
|
+
invoke_remote :error_data, @agent_id, @unsent_errors
|
484
|
+
rescue PostTooBigException
|
485
|
+
@unsent_errors.shift
|
486
|
+
retry
|
487
|
+
end
|
488
|
+
# if the remote invocation fails, then we never clear
|
489
|
+
# @unsent_errors, and therefore we can re-attempt to send on
|
490
|
+
# the next heartbeat. Note the error collector maxes out at
|
491
|
+
# 20 instances to prevent leakage
|
481
492
|
@unsent_errors = []
|
482
493
|
end
|
483
494
|
end
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
# we currently optimize for CPU here since we get roughly a 10x reduction in
|
488
|
-
# message size with this, and CPU overhead is at a premium. If we wanted
|
489
|
-
# to go for higher compression instead, we could use Zlib::BEST_COMPRESSION and
|
490
|
-
# pay a little more CPU.
|
491
|
-
data = Marshal.dump(args)
|
492
|
-
encoding = data.size > 2000 ? 'deflate' : 'identity' # don't compress small payloads
|
493
|
-
post_data = encoding == 'deflate' ? Zlib::Deflate.deflate(data, Zlib::BEST_SPEED) : data
|
494
|
-
http = control.http_connection(collector)
|
495
|
+
|
496
|
+
def compress_data(object)
|
497
|
+
dump = Marshal.dump(object)
|
495
498
|
|
496
|
-
|
497
|
-
|
499
|
+
# we currently optimize for CPU here since we get roughly a 10x
|
500
|
+
# reduction in message size with this, and CPU overhead is at a
|
501
|
+
# premium. For extra-large posts, we use the higher compression
|
502
|
+
# since otherwise it actually errors out.
|
503
|
+
|
504
|
+
dump_size = dump.size
|
505
|
+
|
506
|
+
# small payloads don't need compression
|
507
|
+
return [dump, 'identity'] if dump_size < 2000
|
498
508
|
|
499
|
-
|
509
|
+
# medium payloads get fast compression, to save CPU
|
510
|
+
# big payloads get all the compression possible, to stay under
|
511
|
+
# the 2,000,000 byte post threshold
|
512
|
+
compression = dump_size < 2000000 ? Zlib::BEST_SPEED : Zlib::BEST_COMPRESSION
|
513
|
+
|
514
|
+
[Zlib::Deflate.deflate(dump, compression), 'deflate']
|
515
|
+
end
|
516
|
+
|
517
|
+
def check_post_size(post_string)
|
518
|
+
# TODO: define this as a config option on the server side
|
519
|
+
return if post_string.size < 2000000
|
520
|
+
log.warn "Tried to send too much data, retrying with less: #{post_string.size} bytes"
|
521
|
+
raise PostTooBigException
|
522
|
+
end
|
523
|
+
|
524
|
+
def send_request(opts)
|
525
|
+
request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'ACCEPT-ENCODING' => 'gzip', 'HOST' => opts[:collector].name)
|
500
526
|
request.content_type = "application/octet-stream"
|
501
|
-
request.body =
|
527
|
+
request.body = opts[:data]
|
502
528
|
|
503
|
-
log.debug "connect to #{collector}#{uri}"
|
529
|
+
log.debug "connect to #{opts[:collector]}#{opts[:uri]}"
|
504
530
|
|
505
531
|
response = nil
|
506
|
-
|
532
|
+
http = control.http_connection(collector)
|
507
533
|
begin
|
508
534
|
timeout(@request_timeout) do
|
509
535
|
response = http.request(request)
|
@@ -513,26 +539,48 @@ module NewRelic::Agent
|
|
513
539
|
raise IgnoreSilentlyException
|
514
540
|
end
|
515
541
|
|
516
|
-
if response.is_a? Net::HTTPSuccess
|
517
|
-
body = nil
|
518
|
-
if response['content-encoding'] == 'gzip'
|
519
|
-
log.debug "Decompressing return value"
|
520
|
-
i = Zlib::GzipReader.new(StringIO.new(response.body))
|
521
|
-
body = i.read
|
522
|
-
else
|
523
|
-
log.debug "Uncompressed content returned"
|
524
|
-
body = response.body
|
525
|
-
end
|
526
|
-
return_value = Marshal.load(body)
|
527
|
-
if return_value.is_a? Exception
|
528
|
-
raise return_value
|
529
|
-
else
|
530
|
-
return return_value
|
531
|
-
end
|
532
|
-
else
|
542
|
+
if !(response.is_a? Net::HTTPSuccess)
|
533
543
|
log.debug "Unexpected response from server: #{response.code}: #{response.message}"
|
534
544
|
raise IgnoreSilentlyException
|
535
|
-
end
|
545
|
+
end
|
546
|
+
response
|
547
|
+
end
|
548
|
+
|
549
|
+
def decompress_response(response)
|
550
|
+
if response['content-encoding'] != 'gzip'
|
551
|
+
log.debug "Uncompressed content returned"
|
552
|
+
return response.body
|
553
|
+
end
|
554
|
+
log.debug "Decompressing return value"
|
555
|
+
i = Zlib::GzipReader.new(StringIO.new(response.body))
|
556
|
+
i.read
|
557
|
+
end
|
558
|
+
|
559
|
+
def check_for_exception(response)
|
560
|
+
dump = decompress_response(response)
|
561
|
+
value = Marshal.load(dump)
|
562
|
+
raise value if value.is_a? Exception
|
563
|
+
value
|
564
|
+
end
|
565
|
+
|
566
|
+
def remote_method_uri(method)
|
567
|
+
uri = "/agent_listener/#{PROTOCOL_VERSION}/#{control.license_key}/#{method}"
|
568
|
+
uri << "?run_id=#{@agent_id}" if @agent_id
|
569
|
+
uri
|
570
|
+
end
|
571
|
+
|
572
|
+
# send a message via post
|
573
|
+
def invoke_remote(method, *args)
|
574
|
+
#determines whether to zip the data or send plain
|
575
|
+
post_data, encoding = compress_data(args)
|
576
|
+
|
577
|
+
# this checks to make sure mongrel won't choke on big uploads
|
578
|
+
check_post_size(post_data)
|
579
|
+
|
580
|
+
response = send_request({:uri => remote_method_uri(method), :encoding => encoding, :collector => collector, :data => post_data})
|
581
|
+
|
582
|
+
# raises the right exception if the remote server tells it to die
|
583
|
+
return check_for_exception(response)
|
536
584
|
rescue ForceDisconnectException => e
|
537
585
|
log.error "RPM forced this agent to disconnect (#{e.message})\n" \
|
538
586
|
"Restart this process to resume monitoring via rpm.newrelic.com."
|
@@ -562,7 +610,7 @@ module NewRelic::Agent
|
|
562
610
|
rescue Timeout::Error, StandardError
|
563
611
|
end
|
564
612
|
else
|
565
|
-
log.debug "Bypassing graceful shutdown - agent
|
613
|
+
log.debug "Bypassing graceful shutdown - agent not connected"
|
566
614
|
end
|
567
615
|
end
|
568
616
|
end
|
@@ -13,14 +13,13 @@ if defined?(ActiveRecord::Base) && !NewRelic::Control.instance['skip_ar_instrume
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def active_record_all_stats
|
16
|
-
|
17
|
-
@@active_record_all ||= NewRelic::Agent.instance.stats_engine.get_stats_no_scope("ActiveRecord/all")
|
16
|
+
NewRelic::Agent.instance.stats_engine.get_stats_no_scope("ActiveRecord/all")
|
18
17
|
end
|
19
18
|
|
20
19
|
def log_with_newrelic_instrumentation(sql, name, &block)
|
21
20
|
# Capture db config if we are going to try to get the explain plans
|
22
|
-
if (defined?
|
23
|
-
(defined?
|
21
|
+
if (defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)) ||
|
22
|
+
(defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter))
|
24
23
|
supported_config = @config
|
25
24
|
end
|
26
25
|
if name && (parts = name.split " ") && parts.size == 2
|
@@ -175,7 +175,7 @@ module NewRelic::Agent::Instrumentation
|
|
175
175
|
|
176
176
|
private
|
177
177
|
def apdex_overall_stat
|
178
|
-
|
178
|
+
NewRelic::Agent.instance.stats_engine.get_custom_stats("Apdex", NewRelic::ApdexStats)
|
179
179
|
end
|
180
180
|
|
181
181
|
def is_filtered?(ignore_actions)
|
@@ -32,7 +32,7 @@ module NewRelic::Agent::Instrumentation
|
|
32
32
|
newrelic_dispatcher_start_time = Thread.current[:newrelic_dispatcher_start]
|
33
33
|
response_code = newrelic_response_code
|
34
34
|
if response_code
|
35
|
-
stats =
|
35
|
+
stats = NewRelic::Agent.agent.stats_engine.get_stats_no_scope("HTTP/Response/#{response_code}")
|
36
36
|
stats.trace_call(dispatcher_end_time - newrelic_dispatcher_start_time)
|
37
37
|
end
|
38
38
|
dispatch_stat.trace_call(dispatcher_end_time - newrelic_dispatcher_start_time)
|
@@ -55,13 +55,10 @@ module NewRelic::Agent::Instrumentation
|
|
55
55
|
private
|
56
56
|
# memoize the stats to avoid the cost of the lookup each time.
|
57
57
|
def dispatch_stat
|
58
|
-
|
58
|
+
NewRelic::Agent.agent.stats_engine.get_stats_no_scope 'Rails/HTTP Dispatch'
|
59
59
|
end
|
60
60
|
def mongrel_queue_stat
|
61
|
-
|
62
|
-
end
|
63
|
-
def response_stats
|
64
|
-
@@newrelic_response_stats ||= { '200' => NewRelic::Agent.agent.stats_engine.get_stats('HTTP/Response/200')}
|
61
|
+
NewRelic::Agent.agent.stats_engine.get_stats_no_scope 'WebFrontend/Mongrel/Average Queue Time'
|
65
62
|
end
|
66
63
|
|
67
64
|
# This won't work with Rails 2.2 multi-threading
|
@@ -121,7 +118,7 @@ module NewRelic::Agent::Instrumentation
|
|
121
118
|
private
|
122
119
|
def instance_busy_stats
|
123
120
|
# Late binding on the Instance/busy stats
|
124
|
-
|
121
|
+
NewRelic::Agent.agent.stats_engine.get_stats_no_scope 'Instance/Busy'
|
125
122
|
end
|
126
123
|
|
127
124
|
end
|
@@ -1,7 +1,20 @@
|
|
1
1
|
if defined?(PhusionPassenger)
|
2
|
-
NewRelic::Control.instance.log.debug "Installing Passenger
|
2
|
+
NewRelic::Control.instance.log.debug "Installing Passenger event hooks."
|
3
|
+
|
3
4
|
PhusionPassenger.on_event(:stopping_worker_process) do
|
4
5
|
NewRelic::Control.instance.log.info "Passenger stopping this process, shutdown the agent."
|
5
6
|
NewRelic::Agent.instance.shutdown
|
6
7
|
end
|
8
|
+
|
9
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
10
|
+
if forked
|
11
|
+
# We want to reset the stats from the stats engine in case any carried
|
12
|
+
# over into the spawned process. Don't clear them in case any were
|
13
|
+
# cached.
|
14
|
+
NewRelic::Agent.instance.stats_engine.reset_stats
|
15
|
+
else
|
16
|
+
# We're in conservative spawning mode. We don't need to do anything.
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
7
20
|
end
|
@@ -34,10 +34,6 @@ if defined? ActionController
|
|
34
34
|
alias_method :perform_action, :perform_action_with_newrelic_trace
|
35
35
|
private :perform_action
|
36
36
|
|
37
|
-
#add_method_tracer :render_for_file, 'View/#{args[0]}/ForFile/Rendering'
|
38
|
-
#add_method_tracer :render_for_text, 'View/#{newrelic_metric_path}/Text/Rendering'
|
39
|
-
#add_method_tracer :render, 'View/#{newrelic_metric_path}/Rendering'
|
40
|
-
|
41
37
|
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
42
38
|
write_inheritable_attribute(attr_name, value)
|
43
39
|
end
|
@@ -6,16 +6,16 @@ module NewRelic::Agent::Samplers
|
|
6
6
|
poll
|
7
7
|
end
|
8
8
|
def user_util_stats
|
9
|
-
|
9
|
+
stats_engine.get_stats_no_scope("CPU/User/Utilization")
|
10
10
|
end
|
11
11
|
def system_util_stats
|
12
|
-
|
12
|
+
stats_engine.get_stats_no_scope("CPU/System/Utilization")
|
13
13
|
end
|
14
14
|
def usertime_stats
|
15
|
-
|
15
|
+
stats_engine.get_stats_no_scope("CPU/User Time")
|
16
16
|
end
|
17
17
|
def systemtime_stats
|
18
|
-
|
18
|
+
stats_engine.get_stats_no_scope("CPU/System Time")
|
19
19
|
end
|
20
20
|
def poll
|
21
21
|
now = Time.now
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module NewRelic::Agent::Samplers
|
2
2
|
|
3
3
|
class MemorySampler < NewRelic::Agent::Sampler
|
4
|
+
attr_accessor :sampler
|
5
|
+
|
4
6
|
def initialize
|
5
7
|
super :memory
|
6
8
|
|
@@ -35,7 +37,7 @@ module NewRelic::Agent::Samplers
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def stats
|
38
|
-
|
40
|
+
stats_engine.get_stats("Memory/Physical", false)
|
39
41
|
end
|
40
42
|
def poll
|
41
43
|
sample = @sampler.get_sample
|
@@ -5,7 +5,7 @@ module NewRelic::Agent::Samplers
|
|
5
5
|
super :mongrel
|
6
6
|
end
|
7
7
|
def queue_stats
|
8
|
-
|
8
|
+
stats_engine.get_stats("Mongrel/Queue Length", false)
|
9
9
|
end
|
10
10
|
def poll
|
11
11
|
mongrel = NewRelic::Control.instance.local_env.mongrel
|
@@ -252,9 +252,16 @@ module NewRelic::Agent
|
|
252
252
|
Thread::current[:newrelic_transaction_name] = nil
|
253
253
|
end
|
254
254
|
|
255
|
-
|
255
|
+
# Remove all stats. For test code only.
|
256
|
+
def clear_stats
|
256
257
|
@stats_hash.clear
|
257
258
|
end
|
259
|
+
|
260
|
+
# Reset each of the stats, such as when a new passenger instance starts up.
|
261
|
+
def reset_stats
|
262
|
+
@stats_hash.values.each { |s| s.reset }
|
263
|
+
end
|
264
|
+
|
258
265
|
private
|
259
266
|
|
260
267
|
# Call poll on each of the samplers. Remove
|
@@ -178,7 +178,6 @@ module NewRelic::Agent
|
|
178
178
|
|
179
179
|
if (@harvest_count % @sampling_rate) == 0
|
180
180
|
result << @random_sample if @random_sample
|
181
|
-
@random_sample = nil
|
182
181
|
end
|
183
182
|
end
|
184
183
|
|
@@ -192,6 +191,8 @@ module NewRelic::Agent
|
|
192
191
|
result << previous_slowest
|
193
192
|
end
|
194
193
|
end
|
194
|
+
|
195
|
+
@random_sample = nil
|
195
196
|
end
|
196
197
|
result
|
197
198
|
end
|
@@ -75,7 +75,7 @@ module NewRelic
|
|
75
75
|
append_environment_value('Ruby version'){ RUBY_VERSION }
|
76
76
|
append_environment_value('Ruby platform') { RUBY_PLATFORM }
|
77
77
|
append_environment_value('Ruby patchlevel') { RUBY_PATCHLEVEL }
|
78
|
-
if defined?
|
78
|
+
if defined? ::JRUBY_VERSION
|
79
79
|
append_environment_value('JRuby version') { JRUBY_VERSION }
|
80
80
|
append_environment_value('Java VM version') { ENV_JAVA['java.vm.version']}
|
81
81
|
end
|
@@ -160,7 +160,7 @@ module NewRelic
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def check_for_glassfish
|
163
|
-
return unless defined?(Java) &&
|
163
|
+
return unless defined?(::Java) &&
|
164
164
|
(((com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory rescue nil) &&
|
165
165
|
defined?(com::sun::grizzly::jruby::rack::DefaultRackApplicationFactory)) ||
|
166
166
|
((org.jruby.rack.DefaultRackApplicationFactory rescue nil) &&
|
@@ -23,7 +23,7 @@ class NewRelic::MetricParser::Controller < NewRelic::MetricParser
|
|
23
23
|
# return the cpu measuring equivalent. It may be nil since this metric was not
|
24
24
|
# present in earlier versions of the agent.
|
25
25
|
def cpu_metric
|
26
|
-
Metric.lookup((["ControllerCPU"] + segments[1..-1]).join('/'),
|
26
|
+
Metric.lookup((["ControllerCPU"] + segments[1..-1]).join('/'), :create => false)
|
27
27
|
end
|
28
28
|
|
29
29
|
def short_name
|
@@ -4,9 +4,9 @@ class NewRelic::MetricSpec
|
|
4
4
|
attr_accessor :name
|
5
5
|
attr_accessor :scope
|
6
6
|
|
7
|
-
def initialize (
|
8
|
-
self.name =
|
9
|
-
self.scope =
|
7
|
+
def initialize (metric_name, metric_scope = '')
|
8
|
+
self.name = metric_name
|
9
|
+
self.scope = metric_scope
|
10
10
|
end
|
11
11
|
|
12
12
|
def eql? (o)
|
@@ -20,6 +20,10 @@ class NewRelic::MetricSpec
|
|
20
20
|
h
|
21
21
|
end
|
22
22
|
|
23
|
+
def to_s
|
24
|
+
"#{name}:#{scope}"
|
25
|
+
end
|
26
|
+
|
23
27
|
def to_json(*a)
|
24
28
|
{'name' => name,
|
25
29
|
'scope' => scope}.to_json(*a)
|
@@ -11,9 +11,9 @@ class NewRelic::NoticedError
|
|
11
11
|
self.exception_class = exception.class.name
|
12
12
|
|
13
13
|
if exception.respond_to?('original_exception')
|
14
|
-
self.message = exception.original_exception.message
|
14
|
+
self.message = exception.original_exception.message.to_s
|
15
15
|
else
|
16
|
-
self.message = exception.message
|
16
|
+
self.message = exception.message.to_s
|
17
17
|
end
|
18
18
|
|
19
19
|
# clamp long messages to 4k so that we don't send a lot of
|
data/lib/new_relic/version.rb
CHANGED
data/newrelic.yml
CHANGED
@@ -75,7 +75,6 @@ common: &default_settings
|
|
75
75
|
# http://support.newrelic.com/faqs/general/apdex
|
76
76
|
|
77
77
|
apdex_t: 0.5
|
78
|
-
|
79
78
|
|
80
79
|
# Proxy settings for connecting to the RPM server.
|
81
80
|
#
|
@@ -156,9 +155,9 @@ common: &default_settings
|
|
156
155
|
|
157
156
|
development:
|
158
157
|
<<: *default_settings
|
159
|
-
#
|
160
|
-
# for initial evaluation purposes, you may want to temporarily
|
161
|
-
# the agent on in development mode.
|
158
|
+
# Turn off communication to RPM service in development mode.
|
159
|
+
# NOTE: for initial evaluation purposes, you may want to temporarily
|
160
|
+
# turn the agent on in development mode.
|
162
161
|
enabled: false
|
163
162
|
|
164
163
|
# When running in Developer Mode, the New Relic Agent will present
|
data/newrelic_rpm.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{newrelic_rpm}
|
5
|
-
s.version = "2.9.
|
5
|
+
s.version = "2.9.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Bill Kayser"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-22}
|
10
10
|
s.description = %q{New Relic Ruby Performance Monitoring Agent}
|
11
11
|
s.email = %q{bkayser@newrelic.com}
|
12
12
|
s.executables = ["mongrel_rpm", "newrelic_cmd"]
|
@@ -54,6 +54,7 @@ class ActiveRecordInstrumentationTest < Test::Unit::TestCase
|
|
54
54
|
# This doesn't work on hudson because the sampler metrics creep in.
|
55
55
|
# metrics = NewRelic::Agent.instance.stats_engine.metrics.select { |mname| mname =~ /ActiveRecord\/ActiveRecordFixtures::Order\// }.sort
|
56
56
|
expected = %W[
|
57
|
+
ActiveRecord/all
|
57
58
|
ActiveRecord/create
|
58
59
|
ActiveRecord/find
|
59
60
|
ActiveRecord/ActiveRecordFixtures::Order/create
|
@@ -75,6 +76,7 @@ class ActiveRecordInstrumentationTest < Test::Unit::TestCase
|
|
75
76
|
# This doesn't work on hudson because the sampler metrics creep in.
|
76
77
|
# metrics = NewRelic::Agent.instance.stats_engine.metrics.select { |mname| mname =~ /ActiveRecord\/ActiveRecordFixtures::Order\// }.sort
|
77
78
|
compare_metrics %W[
|
79
|
+
ActiveRecord/all
|
78
80
|
ActiveRecord/destroy
|
79
81
|
ActiveRecord/ActiveRecordFixtures::Order/destroy
|
80
82
|
Database/SQL/insert
|
@@ -95,6 +97,7 @@ class ActiveRecordInstrumentationTest < Test::Unit::TestCase
|
|
95
97
|
list = ActiveRecordFixtures::Order.connection.select_rows "select * from #{ActiveRecordFixtures::Order.table_name}"
|
96
98
|
metrics = NewRelic::Agent.instance.stats_engine.metrics
|
97
99
|
compare_metrics %W[
|
100
|
+
ActiveRecord/all
|
98
101
|
Database/SQL/select
|
99
102
|
], metrics
|
100
103
|
assert_equal 1, NewRelic::Agent.get_stats("Database/SQL/select").call_count
|
@@ -45,9 +45,9 @@ class NewRelic::Agent::NewrelicHelperTest < Test::Unit::TestCase
|
|
45
45
|
private
|
46
46
|
def assert_clean(backtrace, rails=false)
|
47
47
|
if !rails
|
48
|
-
assert_equal 0, backtrace.grep('/rails/').size, backtrace.
|
48
|
+
assert_equal 0, backtrace.grep('/rails/').size, backtrace.join("\n")
|
49
49
|
end
|
50
|
-
assert_equal 0, backtrace.grep(/trace/).size, backtrace.
|
51
|
-
assert_equal 0, backtrace.grep(/newrelic_rpm\/
|
50
|
+
assert_equal 0, backtrace.grep(/trace/).size, backtrace.join("\n")
|
51
|
+
assert_equal 0, backtrace.grep(/newrelic_rpm\/agent/).size, backtrace.join("\n")
|
52
52
|
end
|
53
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Kayser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-22 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|