newrelic_rpm 3.6.0.83 → 3.6.1.85.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +27 -0
- data/Gemfile +2 -7
- data/README.md +1 -1
- data/lib/new_relic/agent/agent.rb +3 -2
- data/lib/new_relic/agent/autostart.rb +56 -0
- data/lib/new_relic/agent/browser_monitoring.rb +19 -14
- data/lib/new_relic/agent/configuration/defaults.rb +12 -2
- data/lib/new_relic/agent/configuration/environment_source.rb +4 -1
- data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +19 -10
- data/lib/new_relic/agent/error_collector.rb +5 -4
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +204 -0
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +88 -0
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +84 -0
- data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +3 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +104 -87
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +91 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +4 -4
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +20 -20
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +3 -25
- data/lib/new_relic/agent/instrumentation/rails4/action_view.rb +2 -115
- data/lib/new_relic/agent/instrumentation/rails4/active_record.rb +2 -82
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +3 -4
- data/lib/new_relic/agent/method_tracer.rb +93 -56
- data/lib/new_relic/agent/null_logger.rb +6 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +9 -4
- data/lib/new_relic/agent/sql_sampler.rb +10 -6
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +19 -3
- data/lib/new_relic/agent/stats_engine/transactions.rb +53 -34
- data/lib/new_relic/agent/system_info.rb +54 -0
- data/lib/new_relic/agent/thread.rb +2 -2
- data/lib/new_relic/agent/transaction/pop.rb +52 -0
- data/lib/new_relic/agent/transaction.rb +388 -0
- data/lib/new_relic/agent/transaction_info.rb +5 -13
- data/lib/new_relic/agent/transaction_sample_builder.rb +13 -20
- data/lib/new_relic/agent/transaction_sampler.rb +13 -15
- data/lib/new_relic/agent/uri_util.rb +35 -0
- data/lib/new_relic/agent.rb +54 -11
- data/lib/new_relic/build.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +0 -1
- data/lib/new_relic/control/frameworks/rails3.rb +2 -0
- data/lib/new_relic/control/frameworks/rails4.rb +0 -4
- data/lib/new_relic/control/instance_methods.rb +5 -19
- data/lib/new_relic/control/server_methods.rb +2 -0
- data/lib/new_relic/environment_report.rb +4 -34
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -6
- data/lib/new_relic/metric_spec.rb +2 -2
- data/lib/new_relic/rack/error_collector.rb +6 -4
- data/lib/new_relic/transaction_sample.rb +7 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/newrelic_rpm.rb +2 -2
- data/newrelic.yml +20 -20
- data/test/config/test_control.rb +2 -2
- data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +0 -2
- data/test/multiverse/suites/agent_only/logging_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -3
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +2 -0
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +96 -0
- data/test/multiverse/suites/agent_only/testing_app.rb +1 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +17 -29
- data/test/multiverse/suites/rails/queue_time_test.rb +8 -2
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +8 -0
- data/test/new_relic/agent/agent/connect_test.rb +2 -1
- data/test/new_relic/agent/agent/start_test.rb +0 -10
- data/test/new_relic/agent/agent_logger_test.rb +15 -0
- data/test/new_relic/agent/agent_test_controller.rb +6 -2
- data/test/new_relic/agent/agent_test_controller_test.rb +20 -69
- data/test/new_relic/agent/autostart_test.rb +67 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +60 -38
- data/test/new_relic/agent/configuration/environment_source_test.rb +19 -17
- data/test/new_relic/agent/cross_app_monitor_test.rb +8 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +0 -5
- data/test/new_relic/agent/error_collector_test.rb +8 -9
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +228 -0
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +18 -34
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +5 -5
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +8 -9
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +24 -38
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +126 -178
- data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +135 -151
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +153 -81
- data/test/new_relic/agent/method_tracer_test.rb +42 -33
- data/test/new_relic/agent/mock_scope_listener.rb +4 -4
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -2
- data/test/new_relic/agent/rpm_agent_test.rb +86 -89
- data/test/new_relic/agent/sql_sampler_test.rb +18 -19
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +5 -8
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +20 -8
- data/test/new_relic/agent/stats_engine/samplers_test.rb +31 -14
- data/test/new_relic/agent/stats_engine_test.rb +53 -60
- data/test/new_relic/agent/thread_test.rb +7 -7
- data/test/new_relic/agent/transaction/pop_test.rb +96 -0
- data/test/new_relic/agent/transaction_info_test.rb +6 -17
- data/test/new_relic/agent/transaction_sample_builder_test.rb +10 -18
- data/test/new_relic/agent/transaction_sampler_test.rb +80 -75
- data/test/new_relic/agent/{instrumentation/metric_frame_test.rb → transaction_test.rb} +76 -42
- data/test/new_relic/agent/uri_util_test.rb +75 -0
- data/test/new_relic/agent_test.rb +115 -9
- data/test/test_helper.rb +138 -9
- data.tar.gz.sig +0 -0
- metadata +37 -74
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +0 -84
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -353
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +0 -175
- data/test/test_contexts.rb +0 -34
@@ -15,6 +15,7 @@ module NewRelic
|
|
15
15
|
|
16
16
|
# Module defining methods stubbed out when the agent is disabled
|
17
17
|
module Shim #:nodoc:
|
18
|
+
def notice_transaction(*args); end
|
18
19
|
def notice_first_scope_push(*args); end
|
19
20
|
def notice_push_scope(*args); end
|
20
21
|
def notice_pop_scope(*args); end
|
@@ -94,12 +95,14 @@ module NewRelic
|
|
94
95
|
#
|
95
96
|
# Note that in developer mode, this captures a stacktrace for
|
96
97
|
# the beginning of each segment, which can be fairly slow
|
97
|
-
def notice_push_scope(
|
98
|
+
def notice_push_scope(time=Time.now)
|
98
99
|
return unless builder
|
99
100
|
|
100
|
-
builder.trace_entry(
|
101
|
+
segment = builder.trace_entry(time.to_f)
|
101
102
|
|
102
103
|
capture_segment_trace if Agent.config[:developer_mode]
|
104
|
+
|
105
|
+
return segment
|
103
106
|
end
|
104
107
|
|
105
108
|
# in developer mode, capture the stack trace with the segment.
|
@@ -120,12 +123,6 @@ module NewRelic
|
|
120
123
|
end
|
121
124
|
end
|
122
125
|
|
123
|
-
# Rename the latest scope's segment in the builder to +new_name+.
|
124
|
-
def rename_scope_segment( new_name )
|
125
|
-
return unless builder
|
126
|
-
builder.rename_current_segment( new_name )
|
127
|
-
end
|
128
|
-
|
129
126
|
# Defaults to zero, otherwise delegated to the transaction
|
130
127
|
# sample builder
|
131
128
|
def scope_depth
|
@@ -149,18 +146,19 @@ module NewRelic
|
|
149
146
|
#
|
150
147
|
# It sets various instance variables to the finished sample,
|
151
148
|
# depending on which settings are active. See `store_sample`
|
152
|
-
def notice_scope_empty(time=Time.now)
|
149
|
+
def notice_scope_empty(txn, time=Time.now, gc_time=nil)
|
153
150
|
last_builder = builder
|
151
|
+
last_builder.set_transaction_name(txn.name) if enabled? && last_builder
|
152
|
+
|
154
153
|
return unless last_builder
|
155
154
|
|
156
|
-
last_builder.finish_trace(time.to_f)
|
155
|
+
last_builder.finish_trace(time.to_f, txn.custom_parameters)
|
157
156
|
clear_builder
|
158
157
|
return if last_builder.ignored?
|
159
158
|
|
160
159
|
@samples_lock.synchronize do
|
161
|
-
# NB this instance variable may be used elsewhere, it's not
|
162
|
-
# just a side effect
|
163
160
|
@last_sample = last_builder.sample
|
161
|
+
@last_sample.set_custom_param(:gc_time, gc_time) if gc_time
|
164
162
|
store_sample(@last_sample)
|
165
163
|
end
|
166
164
|
end
|
@@ -234,10 +232,10 @@ module NewRelic
|
|
234
232
|
end
|
235
233
|
end
|
236
234
|
|
237
|
-
# Delegates to the builder to store the
|
235
|
+
# Delegates to the builder to store the uri, and
|
238
236
|
# parameters if the sampler is active
|
239
|
-
def notice_transaction(
|
240
|
-
builder.set_transaction_info(
|
237
|
+
def notice_transaction(uri=nil, params={})
|
238
|
+
builder.set_transaction_info(uri, params) if enabled? && builder
|
241
239
|
end
|
242
240
|
|
243
241
|
# Tells the builder to ignore a transaction, if we are currently
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# encoding: utf-8
|
3
|
+
# This file is distributed under New Relic's license terms.
|
4
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
5
|
+
|
6
|
+
# This module includes utilities for manipulating URIs, particularly from the
|
7
|
+
# context of Net::HTTP requests. We don't always have direct access to the full
|
8
|
+
# URI from our instrumentation points in Net::HTTP, and we want to filter out
|
9
|
+
# some URI parts before saving URIs from instrumented calls - logic for that
|
10
|
+
# lives here.
|
11
|
+
|
12
|
+
module NewRelic
|
13
|
+
module Agent
|
14
|
+
module URIUtil
|
15
|
+
def self.uri_from_connection_and_request(http, request)
|
16
|
+
parsed = case request.path
|
17
|
+
when /^https?:\/\//
|
18
|
+
URI(request.path)
|
19
|
+
else
|
20
|
+
scheme = http.use_ssl? ? 'https' : 'http'
|
21
|
+
URI("#{scheme}://#{http.address}:#{http.port}#{request.path}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.filtered_uri_for(http, request)
|
26
|
+
parsed = uri_from_connection_and_request(http, request)
|
27
|
+
parsed.user = nil
|
28
|
+
parsed.password = nil
|
29
|
+
parsed.query = nil
|
30
|
+
parsed.fragment = nil
|
31
|
+
parsed.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/new_relic/agent.rb
CHANGED
@@ -64,7 +64,7 @@ module NewRelic
|
|
64
64
|
module Agent
|
65
65
|
extend self
|
66
66
|
extend Forwardable
|
67
|
-
|
67
|
+
|
68
68
|
require 'new_relic/version'
|
69
69
|
require 'new_relic/local_environment'
|
70
70
|
require 'new_relic/metrics'
|
@@ -98,6 +98,8 @@ module NewRelic
|
|
98
98
|
require 'new_relic/agent/transaction_info'
|
99
99
|
require 'new_relic/agent/configuration'
|
100
100
|
require 'new_relic/agent/rules_engine'
|
101
|
+
require 'new_relic/agent/uri_util'
|
102
|
+
require 'new_relic/agent/system_info'
|
101
103
|
|
102
104
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
103
105
|
|
@@ -341,7 +343,7 @@ module NewRelic
|
|
341
343
|
# any. Only affects the transaction started on this thread once
|
342
344
|
# it has started and before it has completed.
|
343
345
|
def abort_transaction!
|
344
|
-
|
346
|
+
Transaction.abort_transaction!
|
345
347
|
end
|
346
348
|
|
347
349
|
# Yield to the block without collecting any metrics or traces in
|
@@ -361,13 +363,13 @@ module NewRelic
|
|
361
363
|
untraced = Thread.current[:newrelic_untraced]
|
362
364
|
untraced.nil? || untraced.last != false
|
363
365
|
end
|
364
|
-
|
366
|
+
|
365
367
|
# helper method to check the thread local to determine whether the
|
366
368
|
# transaction in progress is traced or not
|
367
369
|
def is_transaction_traced?
|
368
370
|
Thread::current[:record_tt] != false
|
369
371
|
end
|
370
|
-
|
372
|
+
|
371
373
|
# helper method to check the thread local to determine whether sql
|
372
374
|
# is being recorded or not
|
373
375
|
def is_sql_recorded?
|
@@ -402,16 +404,16 @@ module NewRelic
|
|
402
404
|
# Anything left over is treated as custom params.
|
403
405
|
#
|
404
406
|
def notice_error(exception, options={})
|
405
|
-
|
407
|
+
Transaction.notice_error(exception, options)
|
406
408
|
end
|
407
409
|
|
408
410
|
# Add parameters to the current transaction trace (and traced error if any)
|
409
411
|
# on the call stack.
|
410
412
|
#
|
411
413
|
def add_custom_parameters(params)
|
412
|
-
|
414
|
+
Transaction.add_custom_parameters(params)
|
413
415
|
end
|
414
|
-
|
416
|
+
|
415
417
|
# Set attributes about the user making this request. These attributes will be automatically
|
416
418
|
# appended to any Transaction Trace or Error that is collected. These attributes
|
417
419
|
# will also be collected for RUM requests.
|
@@ -422,7 +424,48 @@ module NewRelic
|
|
422
424
|
# * <tt>:product</tt> => product name or level
|
423
425
|
#
|
424
426
|
def set_user_attributes(attributes)
|
425
|
-
|
427
|
+
Transaction.set_user_attributes(attributes)
|
428
|
+
end
|
429
|
+
|
430
|
+
# Set the name of the current running transaction. The agent will
|
431
|
+
# apply a reasonable default based on framework routing, but in
|
432
|
+
# cases where this is insufficient, this can be used to manually
|
433
|
+
# control the name of the transaction.
|
434
|
+
# The category of transaction can be specified via the +:category+ option:
|
435
|
+
#
|
436
|
+
# * <tt>:category => :controller</tt> indicates that this is a
|
437
|
+
# controller action and will appear with all the other actions.
|
438
|
+
# * <tt>:category => :task</tt> indicates that this is a
|
439
|
+
# background task and will show up in New Relic with other background
|
440
|
+
# tasks instead of in the controllers list
|
441
|
+
# * <tt>:category => :rack</tt> if you are instrumenting a rack
|
442
|
+
# middleware call. The <tt>:name</tt> is optional, useful if you
|
443
|
+
# have more than one potential transaction in the #call.
|
444
|
+
# * <tt>:category => :uri</tt> indicates that this is a
|
445
|
+
# web transaction whose name is a normalized URI, where 'normalized'
|
446
|
+
# means the URI does not have any elements with data in them such
|
447
|
+
# as in many REST URIs.
|
448
|
+
#
|
449
|
+
# The default category is the same as the running transaction.
|
450
|
+
#
|
451
|
+
# @api public
|
452
|
+
def set_transaction_name(name, options={})
|
453
|
+
if Transaction.current
|
454
|
+
namer = Instrumentation::ControllerInstrumentation::TransactionNamer.new(self)
|
455
|
+
Transaction.current.type = options[:category] if options[:category]
|
456
|
+
Transaction.current.name = "#{namer.category_name(options[:category])}/#{name}"
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
# Get the name of the current running transaction. This is useful if you
|
461
|
+
# want to modify the default name.
|
462
|
+
#
|
463
|
+
# @api public
|
464
|
+
def get_transaction_name
|
465
|
+
if Transaction.current
|
466
|
+
namer = Instrumentation::ControllerInstrumentation::TransactionNamer.new(self)
|
467
|
+
Transaction.current.name.sub(Regexp.new("\\A#{Regexp.escape(namer.category_name)}/"), '')
|
468
|
+
end
|
426
469
|
end
|
427
470
|
|
428
471
|
# The #add_request_parameters method is aliased to #add_custom_parameters
|
@@ -438,8 +481,8 @@ module NewRelic
|
|
438
481
|
# * <tt>method</tt> is the name of the finder method or other
|
439
482
|
# method to identify the operation with.
|
440
483
|
def with_database_metric_name(model, method, &block)
|
441
|
-
if
|
442
|
-
|
484
|
+
if txn = Transaction.current
|
485
|
+
txn.with_database_metric_name(model, method, &block)
|
443
486
|
else
|
444
487
|
yield
|
445
488
|
end
|
@@ -486,7 +529,7 @@ module NewRelic
|
|
486
529
|
def browser_timing_footer
|
487
530
|
agent.browser_timing_footer
|
488
531
|
end
|
489
|
-
|
532
|
+
|
490
533
|
def_delegator :'NewRelic::Agent::PipeChannelManager', :register_report_channel
|
491
534
|
end
|
492
535
|
end
|
data/lib/new_relic/build.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
# GITSHA:
|
2
|
-
module NewRelic; module VERSION; BUILD='
|
1
|
+
# GITSHA: bbab5a90983473b31328da7b2339ea57a0a548f6
|
2
|
+
module NewRelic; module VERSION; BUILD='85.beta'; end; end
|
@@ -59,7 +59,6 @@ module NewRelic
|
|
59
59
|
# is running, if it thinks it's a rake task, or if the agent_enabled is false.
|
60
60
|
::NewRelic::Agent.logger.info("New Relic Agent not running.")
|
61
61
|
else
|
62
|
-
::NewRelic::Agent.logger.info("Starting the New Relic Agent.")
|
63
62
|
install_developer_mode(rails_config) if Agent.config[:developer_mode]
|
64
63
|
install_browser_monitoring(rails_config)
|
65
64
|
install_agent_hooks(rails_config)
|
@@ -49,7 +49,11 @@ module NewRelic
|
|
49
49
|
# init_config({}) which is called one or more times.
|
50
50
|
#
|
51
51
|
def init_plugin(options={})
|
52
|
-
|
52
|
+
env = options[:env] || self.env
|
53
|
+
Agent.logger.info("Starting the New Relic agent in #{env.inspect} environment.")
|
54
|
+
Agent.logger.info("To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the #{env.inspect} section of your newrelic.yml.")
|
55
|
+
|
56
|
+
yaml = Agent::Configuration::YamlSource.new(@config_file_path, env)
|
53
57
|
Agent.config.replace_or_add_config(yaml, 1)
|
54
58
|
|
55
59
|
Agent.config.replace_or_add_config(Agent::Configuration::ManualSource.new(options), 1)
|
@@ -114,24 +118,6 @@ module NewRelic
|
|
114
118
|
|
115
119
|
protected
|
116
120
|
|
117
|
-
# Append framework specific environment information for uploading to
|
118
|
-
# the server for change detection. Override in subclasses
|
119
|
-
def append_environment_info; end
|
120
|
-
|
121
|
-
# Asks bundler to tell us which gemspecs are loaded in the
|
122
|
-
# current process
|
123
|
-
def bundler_gem_list
|
124
|
-
if defined?(Bundler) && Bundler.instance_eval do @load end
|
125
|
-
Bundler.load.specs.map do |spec|
|
126
|
-
version = (spec.respond_to?(:version) && spec.version)
|
127
|
-
spec.name + (version ? "(#{version})" : "")
|
128
|
-
end
|
129
|
-
else
|
130
|
-
[]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
121
|
def initialize(local_env, config_file_override=nil)
|
136
122
|
@local_env = local_env
|
137
123
|
@instrumentation_files = []
|
@@ -53,6 +53,8 @@ module NewRelic
|
|
53
53
|
# here we leave it as a host name since the cert verification
|
54
54
|
# needs it in host form
|
55
55
|
return host if Agent.config[:ssl] && Agent.config[:verify_certificate]
|
56
|
+
# We won't talk directly to the host, so no need to resolve if proxy configured
|
57
|
+
return host if Agent.config[:proxy_host]
|
56
58
|
return nil if host.nil? || host.downcase == "localhost"
|
57
59
|
ip = resolve_ip_address(host)
|
58
60
|
|
@@ -64,40 +64,10 @@ module NewRelic
|
|
64
64
|
report_on('Ruby patchlevel'){ RUBY_PATCHLEVEL.to_s }
|
65
65
|
report_on('JRuby version') { JRUBY_VERSION }
|
66
66
|
report_on('Java VM version') { ENV_JAVA['java.vm.version']}
|
67
|
-
report_on
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
loop do
|
72
|
-
begin
|
73
|
-
cpuinfo << f.read_nonblock(4096).strip
|
74
|
-
rescue EOFError
|
75
|
-
break
|
76
|
-
rescue Errno::EWOULDBLOCK, Errno::EAGAIN
|
77
|
-
cpuinfo = ''
|
78
|
-
break # don't select file handle, just give up
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
processors = cpuinfo.split("\n").select {|line| line =~ /^processor\s*:/ }.size
|
83
|
-
|
84
|
-
if processors == 0
|
85
|
-
processors = nil # assume there is at least one processor
|
86
|
-
::NewRelic::Agent.logger.warn("Cannot determine the number of processors in #{proc_file}")
|
87
|
-
end
|
88
|
-
processors
|
89
|
-
end
|
90
|
-
report_on 'Arch' do
|
91
|
-
arch = `uname -p`
|
92
|
-
arch = ENV['PROCESSOR_ARCHITECTURE'] if arch == ''
|
93
|
-
arch
|
94
|
-
end
|
95
|
-
report_on('OS version'){ `uname -v` }
|
96
|
-
report_on('OS') do
|
97
|
-
os = `uname -s`
|
98
|
-
os = ENV['OS'] if os == ''
|
99
|
-
os
|
100
|
-
end
|
67
|
+
report_on('Processors') { SystemInfo.processor_count }
|
68
|
+
report_on('Arch') { SystemInfo.processor_arch }
|
69
|
+
report_on('OS version') { SystemInfo.os_version }
|
70
|
+
report_on('OS') { SystemInfo.ruby_os_identifier }
|
101
71
|
report_on 'Database adapter' do
|
102
72
|
ActiveRecord::Base.configurations[NewRelic::Control.instance.env]['adapter']
|
103
73
|
end
|
@@ -25,9 +25,6 @@ module NewRelic
|
|
25
25
|
|
26
26
|
# used to distinguish instances of a dispatcher from each other, may be nil
|
27
27
|
attr_writer :dispatcher_instance_id
|
28
|
-
# The number of cpus, if detected, or nil - many platforms do not
|
29
|
-
# support this :(
|
30
|
-
attr_reader :processors
|
31
28
|
|
32
29
|
def initialize
|
33
30
|
# Extend self with any any submodules of LocalEnvironment. These can override
|
@@ -38,9 +35,6 @@ module NewRelic
|
|
38
35
|
end
|
39
36
|
|
40
37
|
discover_dispatcher
|
41
|
-
@gems = Set.new
|
42
|
-
@plugins = Set.new
|
43
|
-
@config = Hash.new
|
44
38
|
end
|
45
39
|
|
46
40
|
|
@@ -15,9 +15,9 @@ class NewRelic::MetricSpec
|
|
15
15
|
# jruby) for sending responses to ruby agents from the java collector.
|
16
16
|
#
|
17
17
|
def initialize(metric_name = '', metric_scope = nil)
|
18
|
-
self.name = (metric_name || '') && metric_name[LENGTH_RANGE]
|
18
|
+
self.name = (metric_name || '') && metric_name.to_s[LENGTH_RANGE]
|
19
19
|
if metric_scope
|
20
|
-
self.scope = metric_scope && metric_scope[LENGTH_RANGE]
|
20
|
+
self.scope = metric_scope && metric_scope.to_s[LENGTH_RANGE]
|
21
21
|
else
|
22
22
|
self.scope = ''
|
23
23
|
end
|
@@ -23,10 +23,12 @@ module NewRelic::Rack
|
|
23
23
|
{'error' => warning}
|
24
24
|
end
|
25
25
|
|
26
|
-
NewRelic::Agent.
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
transaction_name = NewRelic::Agent::TransactionInfo.get.transaction.name
|
27
|
+
NewRelic::Agent::Transaction.notice_error(exception,
|
28
|
+
:uri => request.path,
|
29
|
+
:referer => request.referer,
|
30
|
+
:metric => transaction_name,
|
31
|
+
:request_params => params)
|
30
32
|
end
|
31
33
|
raise exception
|
32
34
|
end
|
@@ -62,6 +62,11 @@ module NewRelic
|
|
62
62
|
JSON.dump(self.to_array)
|
63
63
|
end
|
64
64
|
|
65
|
+
def set_custom_param(name, value)
|
66
|
+
@params[:custom_params] ||= {}
|
67
|
+
@params[:custom_params][name] = value
|
68
|
+
end
|
69
|
+
|
65
70
|
include NewRelic::Coerce
|
66
71
|
|
67
72
|
def to_array
|
@@ -91,7 +96,8 @@ module NewRelic
|
|
91
96
|
@root_segment.path_string
|
92
97
|
end
|
93
98
|
|
94
|
-
|
99
|
+
# relative_timestamp is seconds since the start of the transaction
|
100
|
+
def create_segment(relative_timestamp, metric_name=nil, segment_id = nil)
|
95
101
|
raise TypeError.new("Frozen Transaction Sample") if frozen?
|
96
102
|
@params[:segment_count] += 1
|
97
103
|
@segment_count += 1
|
data/lib/new_relic/version.rb
CHANGED
data/lib/newrelic_rpm.rb
CHANGED
@@ -32,7 +32,7 @@ if defined?(Merb) && defined?(Merb::BootLoader)
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
elsif defined? Rails
|
35
|
-
if Rails.
|
35
|
+
if Rails::VERSION::MAJOR.to_i >= 3
|
36
36
|
module NewRelic
|
37
37
|
class Railtie < Rails::Railtie
|
38
38
|
|
@@ -42,7 +42,7 @@ elsif defined? Rails
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
else
|
45
|
-
# After
|
45
|
+
# After version 2.0 of Rails we can access the configuration directly.
|
46
46
|
# We need it to add dev mode routes after initialization finished.
|
47
47
|
config = nil
|
48
48
|
config = Rails.configuration if Rails.respond_to?(:configuration)
|
data/newrelic.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# This file configures the New Relic
|
3
|
-
#
|
4
|
-
# information, visit www.newrelic.com.
|
2
|
+
# This file configures the New Relic Agent. New Relic monitors
|
3
|
+
# Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead.
|
4
|
+
# For more information, visit www.newrelic.com.
|
5
5
|
#
|
6
6
|
# Generated <%= Time.now.strftime('%B %d, %Y') %>, for version <%= NewRelic::VERSION::STRING %>
|
7
7
|
#
|
@@ -17,11 +17,11 @@ common: &default_settings
|
|
17
17
|
# New Relic service.
|
18
18
|
license_key: '<%= license_key %>'
|
19
19
|
|
20
|
-
# Agent Enabled (Rails Only)
|
20
|
+
# Agent Enabled (Ruby/Rails Only)
|
21
21
|
# Use this setting to force the agent to run or not run.
|
22
22
|
# Default is 'auto' which means the agent will install and run only
|
23
23
|
# if a valid dispatcher such as Mongrel is running. This prevents
|
24
|
-
# it from running with Rake or the console.
|
24
|
+
# it from running with Rake or the console. Set to false to
|
25
25
|
# completely turn the agent off regardless of the other settings.
|
26
26
|
# Valid values are true, false and auto.
|
27
27
|
#
|
@@ -47,7 +47,7 @@ common: &default_settings
|
|
47
47
|
# When "true", the agent collects performance data about your
|
48
48
|
# application and reports this data to the New Relic service at
|
49
49
|
# newrelic.com. This global switch is normally overridden for each
|
50
|
-
# environment below (formerly called 'enabled')
|
50
|
+
# environment below. (formerly called 'enabled')
|
51
51
|
monitor_mode: true
|
52
52
|
|
53
53
|
# Developer mode should be off in every environment but
|
@@ -85,7 +85,7 @@ common: &default_settings
|
|
85
85
|
# into web pages. Set this attribute to false to turn off this behavior.
|
86
86
|
auto_instrument: true
|
87
87
|
|
88
|
-
# Proxy settings for connecting to the
|
88
|
+
# Proxy settings for connecting to the New Relic server.
|
89
89
|
#
|
90
90
|
# If a proxy is used, the host setting is required. Other settings
|
91
91
|
# are optional. Default port is 8080.
|
@@ -108,11 +108,11 @@ common: &default_settings
|
|
108
108
|
# Rails: the RoR filter_parameter_logging excludes parameters
|
109
109
|
# Java: create a config setting called "ignored_params" and set it to
|
110
110
|
# a comma separated list of HTTP parameter names.
|
111
|
-
# ex: ignored_params: credit_card, ssn, password
|
111
|
+
# ex: ignored_params: credit_card, ssn, password
|
112
112
|
capture_params: false
|
113
113
|
|
114
114
|
# Transaction tracer captures deep information about slow
|
115
|
-
# transactions and sends this to the service once a
|
115
|
+
# transactions and sends this to the New Relic service once a
|
116
116
|
# minute. Included in the transaction is the exact call sequence of
|
117
117
|
# the transactions including any SQL statements issued.
|
118
118
|
transaction_tracer:
|
@@ -125,9 +125,9 @@ common: &default_settings
|
|
125
125
|
# Threshold in seconds for when to collect a transaction
|
126
126
|
# trace. When the response time of a controller action exceeds
|
127
127
|
# this threshold, a transaction trace will be recorded and sent to
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
128
|
+
# New Relic. Valid values are any float value, or (default) "apdex_f",
|
129
|
+
# which will use the threshold for an dissatisfying Apdex
|
130
|
+
# controller action - four times the Apdex T value.
|
131
131
|
transaction_threshold: apdex_f
|
132
132
|
|
133
133
|
# When transaction tracer is on, SQL statements can optionally be
|
@@ -138,7 +138,7 @@ common: &default_settings
|
|
138
138
|
|
139
139
|
# Threshold in seconds for when to collect stack trace for a SQL
|
140
140
|
# call. In other words, when SQL statements exceed this threshold,
|
141
|
-
# then capture and send the current stack trace. This is
|
141
|
+
# then capture and send to New Relic the current stack trace. This is
|
142
142
|
# helpful for pinpointing where long SQL calls originate from.
|
143
143
|
stack_trace_threshold: 0.500
|
144
144
|
|
@@ -147,12 +147,12 @@ common: &default_settings
|
|
147
147
|
# set to false when using other adapters.
|
148
148
|
# explain_enabled: true
|
149
149
|
|
150
|
-
# Threshold for query execution time below which query plans will
|
150
|
+
# Threshold for query execution time below which query plans will
|
151
151
|
# not be captured. Relevant only when `explain_enabled` is true.
|
152
152
|
# explain_threshold: 0.5
|
153
153
|
|
154
154
|
# Error collector captures information about uncaught exceptions and
|
155
|
-
# sends them to
|
155
|
+
# sends them to New Relic for viewing
|
156
156
|
error_collector:
|
157
157
|
|
158
158
|
# Error collector is enabled by default. Set this to false to turn
|
@@ -166,9 +166,9 @@ common: &default_settings
|
|
166
166
|
capture_source: true
|
167
167
|
|
168
168
|
# To stop specific errors from reporting to New Relic, set this property
|
169
|
-
# to comma
|
169
|
+
# to comma-separated values. Default is to ignore routing errors,
|
170
170
|
# which are how 404's get triggered.
|
171
|
-
ignore_errors: ActionController::RoutingError
|
171
|
+
ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
|
172
172
|
|
173
173
|
# If you're interested in capturing memcache keys as though they
|
174
174
|
# were SQL uncomment this flag. Note that this does increase
|
@@ -178,10 +178,10 @@ common: &default_settings
|
|
178
178
|
|
179
179
|
# Application Environments
|
180
180
|
# ------------------------------------------
|
181
|
-
# Environment
|
182
|
-
# For Rails applications, RAILS_ENV is used to determine the environment
|
181
|
+
# Environment-specific settings are in this section.
|
182
|
+
# For Rails applications, RAILS_ENV is used to determine the environment.
|
183
183
|
# For Java applications, pass -Dnewrelic.environment <environment> to set
|
184
|
-
# the environment
|
184
|
+
# the environment.
|
185
185
|
|
186
186
|
# NOTE if your application has other named environments, you should
|
187
187
|
# provide newrelic configuration settings for these environments here.
|
data/test/config/test_control.rb
CHANGED
@@ -6,8 +6,8 @@ require 'new_relic/control/frameworks/rails'
|
|
6
6
|
require 'new_relic/control/frameworks/rails3'
|
7
7
|
require 'new_relic/control/frameworks/rails4'
|
8
8
|
|
9
|
-
if defined?(::Rails)
|
10
|
-
parent_class = case ::Rails.
|
9
|
+
if defined?(::Rails)
|
10
|
+
parent_class = case ::Rails::VERSION::MAJOR.to_i
|
11
11
|
when 4
|
12
12
|
NewRelic::Control::Frameworks::Rails4
|
13
13
|
when 3
|
@@ -91,7 +91,7 @@ class AuditLogTest < Test::Unit::TestCase
|
|
91
91
|
agent.sql_sampler.notice_sql("select * from test",
|
92
92
|
"Database/test/select",
|
93
93
|
nil, 1.5)
|
94
|
-
agent.sql_sampler.notice_scope_empty
|
94
|
+
agent.sql_sampler.notice_scope_empty('txn')
|
95
95
|
agent.send(:harvest_and_send_slowest_sql)
|
96
96
|
end
|
97
97
|
$collector.agent_data.each do |req|
|
@@ -52,9 +52,7 @@ class CrossProcessTest < Test::Unit::TestCase
|
|
52
52
|
def test_cross_app_writes_out_information
|
53
53
|
get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
54
54
|
assert_not_nil last_response.headers["X-NewRelic-App-Data"]
|
55
|
-
|
56
55
|
metric = NewRelic::Agent.instance.stats_engine.lookup_stats('ClientApplication/1#234/all')
|
57
56
|
assert_equal 1, metric.call_count
|
58
57
|
end
|
59
58
|
end
|
60
|
-
|