newrelic_rpm 3.5.4.35.beta → 3.5.5.38
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +42 -0
- data/GUIDELINES_FOR_CONTRIBUTING.md +3 -0
- data/Rakefile +8 -0
- data/bin/mongrel_rpm +1 -1
- data/init.rb +1 -8
- data/lib/new_relic/agent.rb +11 -13
- data/lib/new_relic/agent/agent.rb +89 -110
- data/lib/new_relic/agent/agent_logger.rb +165 -0
- data/lib/new_relic/agent/audit_logger.rb +72 -0
- data/lib/new_relic/agent/beacon_configuration.rb +4 -4
- data/lib/new_relic/agent/browser_monitoring.rb +13 -7
- data/lib/new_relic/agent/busy_calculator.rb +2 -2
- data/lib/new_relic/agent/configuration.rb +25 -0
- data/lib/new_relic/agent/configuration/defaults.rb +45 -8
- data/lib/new_relic/agent/configuration/environment_source.rb +8 -15
- data/lib/new_relic/agent/configuration/manager.rb +22 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +10 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +4 -2
- data/lib/new_relic/agent/cross_process_monitoring.rb +43 -0
- data/lib/new_relic/agent/database.rb +2 -4
- data/lib/new_relic/agent/error_collector.rb +4 -9
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +1 -1
- data/lib/new_relic/agent/instrumentation/authlogic.rb +1 -1
- data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +41 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +7 -7
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +4 -4
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +3 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +2 -2
- data/lib/new_relic/agent/method_tracer.rb +6 -8
- data/lib/new_relic/agent/new_relic_service.rb +94 -106
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -1
- data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -6
- data/lib/new_relic/agent/sql_sampler.rb +3 -18
- data/lib/new_relic/agent/stats_engine.rb +0 -5
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +3 -3
- data/lib/new_relic/agent/stats_engine/samplers.rb +2 -4
- data/lib/new_relic/agent/thread.rb +8 -3
- data/lib/new_relic/agent/thread_profiler.rb +38 -27
- data/lib/new_relic/agent/transaction_info.rb +1 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +2 -3
- data/lib/new_relic/agent/transaction_sampler.rb +3 -7
- data/lib/new_relic/agent/worker_loop.rb +3 -11
- data/lib/new_relic/control.rb +0 -2
- data/lib/new_relic/control/class_methods.rb +8 -2
- data/lib/new_relic/control/frameworks/merb.rb +0 -6
- data/lib/new_relic/control/frameworks/rails.rb +8 -29
- data/lib/new_relic/control/frameworks/rails3.rb +8 -20
- data/lib/new_relic/control/frameworks/rails4.rb +23 -0
- data/lib/new_relic/control/frameworks/ruby.rb +1 -22
- data/lib/new_relic/control/instance_methods.rb +12 -34
- data/lib/new_relic/control/instrumentation.rb +7 -12
- data/lib/new_relic/control/server_methods.rb +5 -8
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/local_environment.rb +30 -64
- data/lib/new_relic/metric_data.rb +1 -1
- data/lib/new_relic/metric_spec.rb +1 -1
- data/lib/new_relic/noticed_error.rb +1 -1
- data/lib/new_relic/rack/browser_monitoring.rb +5 -5
- data/lib/new_relic/stats.rb +9 -7
- data/lib/new_relic/transaction_sample.rb +2 -7
- data/lib/new_relic/version.rb +1 -1
- data/lib/newrelic_rpm.rb +1 -1
- data/newrelic_rpm.gemspec.erb +15 -17
- data/test/config/newrelic.yml +1 -1
- data/test/config/test_control.rb +18 -18
- data/test/fixtures/gemspec_no_build.rb +0 -2
- data/test/fixtures/gemspec_with_build.rb +0 -2
- data/test/fixtures/gemspec_with_build_and_stage.rb +0 -2
- data/test/multiverse/README.md +3 -8
- data/test/multiverse/suites/agent_only/Envfile +1 -0
- data/test/multiverse/suites/agent_only/audit_log_test.rb +99 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/config_file_loading/Envfile +7 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +106 -0
- data/test/multiverse/suites/logging/Envfile +4 -0
- data/test/multiverse/suites/logging/config/newrelic.yml +22 -0
- data/test/multiverse/suites/logging/logging_test.rb +143 -0
- data/test/multiverse/suites/no_load/config/newrelic.yml +1 -2
- data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +0 -13
- data/test/new_relic/agent/agent/connect_test.rb +30 -92
- data/test/new_relic/agent/agent/start_test.rb +4 -84
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +8 -43
- data/test/new_relic/agent/agent_logger_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +10 -9
- data/test/new_relic/agent/audit_logger_test.rb +105 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +2 -1
- data/test/new_relic/agent/busy_calculator_test.rb +7 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +25 -20
- data/test/new_relic/agent/configuration/manager_test.rb +59 -4
- data/test/new_relic/agent/configuration/yaml_source_test.rb +20 -1
- data/test/new_relic/agent/cross_process_monitoring_test.rb +77 -0
- data/test/new_relic/agent/database_test.rb +0 -11
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -3
- data/test/new_relic/agent/error_collector_test.rb +11 -7
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +39 -19
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +39 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -6
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +3 -15
- data/test/new_relic/agent/new_relic_service_test.rb +48 -8
- data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -1
- data/test/new_relic/agent/sql_sampler_test.rb +1 -1
- data/test/new_relic/agent/thread_profiler_test.rb +46 -45
- data/test/new_relic/agent/thread_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -1
- data/test/new_relic/agent/worker_loop_test.rb +4 -9
- data/test/new_relic/agent_test.rb +6 -9
- data/test/new_relic/control/class_methods_test.rb +0 -18
- data/test/new_relic/control_test.rb +6 -9
- data/test/new_relic/dispatcher_test.rb +54 -0
- data/test/new_relic/fake_collector.rb +15 -14
- data/test/new_relic/fake_service.rb +4 -1
- data/test/new_relic/fakes_sending_data.rb +30 -0
- data/test/new_relic/framework_test.rb +53 -0
- data/test/new_relic/local_environment_test.rb +5 -2
- data/test/new_relic/rack/browser_monitoring_test.rb +2 -1
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/stats_test.rb +10 -0
- data/test/new_relic/transaction_sample_test.rb +2 -2
- data/test/script/ci.sh +1 -1
- data/test/test_helper.rb +23 -0
- data/ui/views/newrelic/file/images/arrow-close.png +0 -0
- data/ui/views/newrelic/file/images/arrow-open.png +0 -0
- data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
- data/ui/views/newrelic/file/images/file_icon.png +0 -0
- data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
- metadata +47 -41
- data/InstallationNotes.md +0 -15
- data/lib/new_relic/control/logging_methods.rb +0 -125
- data/test/multiverse/Rakefile +0 -17
- data/test/multiverse/suites/rum_auto_instrumentation/problem_response.html +0 -422
- data/test/new_relic/control/logging_methods_test.rb +0 -211
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
module Agent
|
5
|
+
class AgentLogger
|
6
|
+
|
7
|
+
def initialize(config, root = "", override_logger=nil)
|
8
|
+
create_log(config, root, override_logger)
|
9
|
+
set_log_level!(config)
|
10
|
+
set_log_format!
|
11
|
+
|
12
|
+
gather_startup_logs
|
13
|
+
end
|
14
|
+
|
15
|
+
def fatal(*msgs)
|
16
|
+
@log.fatal(format_messages(msgs))
|
17
|
+
end
|
18
|
+
|
19
|
+
def error(*msgs)
|
20
|
+
@log.error(format_messages(msgs))
|
21
|
+
end
|
22
|
+
|
23
|
+
def warn(*msgs)
|
24
|
+
@log.warn(format_messages(msgs))
|
25
|
+
end
|
26
|
+
|
27
|
+
def info(*msgs)
|
28
|
+
@log.info(format_messages(msgs))
|
29
|
+
end
|
30
|
+
|
31
|
+
def debug(*msgs)
|
32
|
+
@log.debug(format_messages(msgs))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Allows for passing exceptions in explicitly, which format with backtrace
|
36
|
+
def format_messages(msgs)
|
37
|
+
msgs.map do |msg|
|
38
|
+
if msg.respond_to?(:backtrace)
|
39
|
+
"#{msg.class}: #{msg}\n\t#{(msg.backtrace || []).join("\n\t")}"
|
40
|
+
else
|
41
|
+
msg
|
42
|
+
end
|
43
|
+
end.join("\n")
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_log(config, root, override_logger)
|
47
|
+
if !override_logger.nil?
|
48
|
+
@log = override_logger
|
49
|
+
elsif config[:agent_enabled] == false
|
50
|
+
create_null_logger
|
51
|
+
else
|
52
|
+
if wants_stdout(config)
|
53
|
+
@log = ::Logger.new(STDOUT)
|
54
|
+
else
|
55
|
+
create_log_to_file(config, root)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_log_to_file(config, root)
|
61
|
+
path = find_or_create_file_path(config[:log_file_path], root)
|
62
|
+
if path.nil?
|
63
|
+
@log = ::Logger.new(STDOUT)
|
64
|
+
warn("Error creating log directory #{config[:log_file_path]}, using standard out for logging.")
|
65
|
+
else
|
66
|
+
file_path = "#{path}/#{config[:log_file_name]}"
|
67
|
+
begin
|
68
|
+
@log = ::Logger.new(file_path)
|
69
|
+
rescue => e
|
70
|
+
@log = ::Logger.new(STDOUT)
|
71
|
+
warn("Failed creating logger for file #{file_path}, using standard out for logging.", e)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_null_logger
|
77
|
+
null_path = ["/dev/null", "NUL"].detect{|f| File.exists?(f)}
|
78
|
+
@log = ::Logger.new(null_path)
|
79
|
+
end
|
80
|
+
|
81
|
+
def wants_stdout(config)
|
82
|
+
config[:log_file_path].upcase == "STDOUT"
|
83
|
+
end
|
84
|
+
|
85
|
+
def find_or_create_file_path(path_setting, root)
|
86
|
+
for abs_path in [ File.expand_path(path_setting),
|
87
|
+
File.expand_path(File.join(root, path_setting)) ] do
|
88
|
+
if File.directory?(abs_path) || (Dir.mkdir(abs_path) rescue nil)
|
89
|
+
return abs_path[%r{^(.*?)/?$}]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def set_log_level!(config)
|
96
|
+
@log.level = AgentLogger.log_level_for(config.fetch(:log_level))
|
97
|
+
end
|
98
|
+
|
99
|
+
LOG_LEVELS = {
|
100
|
+
"debug" => Logger::DEBUG,
|
101
|
+
"info" => Logger::INFO,
|
102
|
+
"warn" => Logger::WARN,
|
103
|
+
"error" => Logger::ERROR,
|
104
|
+
"fatal" => Logger::FATAL,
|
105
|
+
}
|
106
|
+
|
107
|
+
def self.log_level_for(level)
|
108
|
+
LOG_LEVELS.fetch(level.to_s.downcase, Logger::INFO)
|
109
|
+
end
|
110
|
+
|
111
|
+
def set_log_format!
|
112
|
+
def @log.format_message(severity, timestamp, progname, msg)
|
113
|
+
prefix = @logdev.dev == STDOUT ? '** [NewRelic]' : ''
|
114
|
+
prefix + "[#{timestamp.strftime("%m/%d/%y %H:%M:%S %z")} #{Socket.gethostname} (#{$$})] #{severity} : #{msg}\n"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def gather_startup_logs
|
119
|
+
StartupLogger.instance.dump(self)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# BBase class for startup logging and testing in multiverse
|
124
|
+
class MemoryLogger
|
125
|
+
def initialize
|
126
|
+
@messages = []
|
127
|
+
end
|
128
|
+
|
129
|
+
attr_accessor :messages, :level
|
130
|
+
|
131
|
+
def fatal(*msgs)
|
132
|
+
messages << [:fatal, msgs]
|
133
|
+
end
|
134
|
+
|
135
|
+
def error(*msgs)
|
136
|
+
messages << [:error, msgs]
|
137
|
+
end
|
138
|
+
|
139
|
+
def warn(*msgs)
|
140
|
+
messages << [:warn, msgs]
|
141
|
+
end
|
142
|
+
|
143
|
+
def info(*msgs)
|
144
|
+
messages << [:info, msgs]
|
145
|
+
end
|
146
|
+
|
147
|
+
def debug(*msgs)
|
148
|
+
messages << [:debug, msgs]
|
149
|
+
end
|
150
|
+
|
151
|
+
def dump(logger)
|
152
|
+
messages.each do |msg|
|
153
|
+
logger.send(msg[0], msg[1])
|
154
|
+
end
|
155
|
+
messages.clear
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# In an effort to not lose messages during startup, we trap them in memory
|
160
|
+
# The real logger will then dump its contents out when it arrives.
|
161
|
+
class StartupLogger < MemoryLogger
|
162
|
+
include Singleton
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module NewRelic
|
5
|
+
module Agent
|
6
|
+
class AuditLogger
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
@enabled = @config[:'audit_log.enabled']
|
10
|
+
@encoder = NewRelic::Agent::NewRelicService::Encoders::Identity
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_writer :enabled
|
14
|
+
|
15
|
+
def enabled?
|
16
|
+
@enabled
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup?
|
20
|
+
!@log.nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
def log_request(uri, data, marshaller)
|
24
|
+
if enabled?
|
25
|
+
setup_logger unless setup?
|
26
|
+
request_body = if marshaller.class.human_readable?
|
27
|
+
marshaller.dump(data, :encoder => @encoder)
|
28
|
+
else
|
29
|
+
marshaller.prepare(data, :encoder => @encoder).inspect
|
30
|
+
end
|
31
|
+
@log.info("REQUEST: #{uri}")
|
32
|
+
@log.info("REQUEST BODY: #{request_body}")
|
33
|
+
end
|
34
|
+
rescue SystemCallError => e
|
35
|
+
::NewRelic::Agent.logger.warn("Failed writing to audit log: #{e}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_logger
|
39
|
+
path = ensure_log_path
|
40
|
+
@log = ::Logger.new(path || "/dev/null")
|
41
|
+
@log.formatter = log_formatter
|
42
|
+
::NewRelic::Agent.logger.info("Audit log enabled at '#{path}'") if path
|
43
|
+
end
|
44
|
+
|
45
|
+
def ensure_log_path
|
46
|
+
path = File.expand_path(@config[:'audit_log.path'])
|
47
|
+
log_dir = File.dirname(path)
|
48
|
+
|
49
|
+
begin
|
50
|
+
FileUtils.mkdir_p(log_dir)
|
51
|
+
FileUtils.touch(path)
|
52
|
+
rescue SystemCallError => e
|
53
|
+
msg = "Audit log disabled, failed opening log at '#{path}': #{e}"
|
54
|
+
::NewRelic::Agent.logger.warn(msg)
|
55
|
+
path = nil
|
56
|
+
end
|
57
|
+
|
58
|
+
path
|
59
|
+
end
|
60
|
+
|
61
|
+
def log_formatter
|
62
|
+
if @formatter.nil?
|
63
|
+
@formatter = Logger::Formatter.new
|
64
|
+
def @formatter.call(severity, time, progname, msg)
|
65
|
+
"[#{time} #{Socket.gethostname} (#{$$})] : #{msg}\n"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
@formatter
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -25,18 +25,18 @@ module NewRelic
|
|
25
25
|
# of configuration values from the server
|
26
26
|
def initialize
|
27
27
|
@browser_timing_header = build_browser_timing_header
|
28
|
-
NewRelic::
|
28
|
+
::NewRelic::Agent.logger.debug("Browser timing header: #{@browser_timing_header.inspect}")
|
29
29
|
@browser_timing_static_footer = build_load_file_js
|
30
|
-
NewRelic::
|
30
|
+
::NewRelic::Agent.logger.debug("Browser timing static footer: #{@browser_timing_static_footer.inspect}")
|
31
31
|
if Agent.config[:'rum.jsonp']
|
32
|
-
NewRelic::
|
32
|
+
::NewRelic::Agent.logger.debug("Real User Monitoring is using JSONP protocol")
|
33
33
|
@finish_command = 'nrfj'
|
34
34
|
else
|
35
35
|
@finish_command = 'nrf2'
|
36
36
|
end
|
37
37
|
|
38
38
|
if !Agent.config[:'rum.enabled']
|
39
|
-
NewRelic::
|
39
|
+
::NewRelic::Agent.logger.debug("Real User Monitoring is disabled for this agent. Edit your configuration to change this.")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -93,6 +93,12 @@ module NewRelic
|
|
93
93
|
NewRelic::Agent::TransactionInfo.get.start_time
|
94
94
|
end
|
95
95
|
|
96
|
+
def self.timings
|
97
|
+
NewRelic::Agent::Instrumentation::BrowserMonitoringTimings.new(
|
98
|
+
current_metric_frame.queue_time,
|
99
|
+
NewRelic::Agent::TransactionInfo.get)
|
100
|
+
end
|
101
|
+
|
96
102
|
def insert_mobile_response_header(request, response)
|
97
103
|
if mobile_header_found_in?(request) &&
|
98
104
|
NewRelic::Agent.instance.beacon_configuration
|
@@ -122,23 +128,23 @@ module NewRelic
|
|
122
128
|
# reason if they shouldn't.
|
123
129
|
def insert_js?
|
124
130
|
if NewRelic::Agent.instance.beacon_configuration.nil?
|
125
|
-
NewRelic::Agent.logger.debug "Beacon configuration is nil. Skipping browser instrumentation."
|
131
|
+
::NewRelic::Agent.logger.debug "Beacon configuration is nil. Skipping browser instrumentation."
|
126
132
|
false
|
127
133
|
elsif ! NewRelic::Agent.instance.beacon_configuration.enabled?
|
128
|
-
NewRelic::Agent.logger.debug "Beacon configuration is disabled. Skipping browser instrumentation."
|
129
|
-
NewRelic::Agent.logger.debug NewRelic::Agent.instance.beacon_configuration.inspect
|
134
|
+
::NewRelic::Agent.logger.debug "Beacon configuration is disabled. Skipping browser instrumentation."
|
135
|
+
::NewRelic::Agent.logger.debug NewRelic::Agent.instance.beacon_configuration.inspect
|
130
136
|
false
|
131
137
|
elsif Agent.config[:browser_key].nil? || Agent.config[:browser_key].empty?
|
132
|
-
NewRelic::Agent.logger.debug "Browser key is not set. Skipping browser instrumentation."
|
138
|
+
::NewRelic::Agent.logger.debug "Browser key is not set. Skipping browser instrumentation."
|
133
139
|
false
|
134
140
|
elsif ! NewRelic::Agent.is_transaction_traced?
|
135
|
-
NewRelic::Agent.logger.debug "Transaction is not traced. Skipping browser instrumentation."
|
141
|
+
::NewRelic::Agent.logger.debug "Transaction is not traced. Skipping browser instrumentation."
|
136
142
|
false
|
137
143
|
elsif ! NewRelic::Agent.is_execution_traced?
|
138
|
-
NewRelic::Agent.logger.debug "Execution is not traced. Skipping browser instrumentation."
|
144
|
+
::NewRelic::Agent.logger.debug "Execution is not traced. Skipping browser instrumentation."
|
139
145
|
false
|
140
146
|
elsif NewRelic::Agent::TransactionInfo.get.ignore_end_user?
|
141
|
-
NewRelic::Agent.logger.debug "Ignore end user for this transaction is set. Skipping browser instrumentation."
|
147
|
+
::NewRelic::Agent.logger.debug "Ignore end user for this transaction is set. Skipping browser instrumentation."
|
142
148
|
false
|
143
149
|
else
|
144
150
|
true
|
@@ -37,7 +37,7 @@ module NewRelic
|
|
37
37
|
return if callers > 0
|
38
38
|
@lock.synchronize do
|
39
39
|
if @entrypoint_stack.empty?
|
40
|
-
NewRelic::Agent.logger.
|
40
|
+
::NewRelic::Agent.logger.warn("Stack underflow tracking dispatcher entry and exit!\n #{caller.join(" \n")}")
|
41
41
|
else
|
42
42
|
@accumulator += (end_time - @entrypoint_stack.pop).to_f
|
43
43
|
end
|
@@ -85,7 +85,7 @@ module NewRelic
|
|
85
85
|
|
86
86
|
busy = busy / time_window
|
87
87
|
|
88
|
-
instance_busy_stats.record_data_point busy
|
88
|
+
instance_busy_stats.record_data_point busy if Agent.config[:report_instance_busy]
|
89
89
|
@harvest_start = t0
|
90
90
|
end
|
91
91
|
|
@@ -1,5 +1,26 @@
|
|
1
1
|
require 'new_relic/agent/configuration/manager'
|
2
2
|
|
3
|
+
# The agent's configuration is accessed through a configuration object exposed
|
4
|
+
# by ::NewRelic::Agent.config. It provides a hash like interface to the
|
5
|
+
# agent's settings.
|
6
|
+
#
|
7
|
+
# For example:
|
8
|
+
# ::NewRelic::Agent.config[:'transaction_tracer.enabled']
|
9
|
+
# determines whether transaction tracing is enabled. String and symbol keys
|
10
|
+
# are treated indifferently and nested keys are collapsed and concatenated with
|
11
|
+
# a dot (i.e. {:a => {:b => 'c'} becomes { 'a.b' => 'c'}).
|
12
|
+
#
|
13
|
+
# The agent reads configuration from a variety of sources. These sources are
|
14
|
+
# modeled as a set of layers. The top layer has the highest priority. If the
|
15
|
+
# top layer does not contain the requested setting the config object will search
|
16
|
+
# through the subsequent layers returning the first value it finds.
|
17
|
+
#
|
18
|
+
# Configuration layers include EnvironmentSource (which reads settings from
|
19
|
+
# ENV), ServerSource (which reads Server Side Config from New Relic's servers),
|
20
|
+
# YamlSource (which reads from newrelic.yml), ManualSource (which reads
|
21
|
+
# arguments passed to NewRelic::Agent.manual_start or potentially other
|
22
|
+
# methods), and Defaults (which contains default settings).
|
23
|
+
#
|
3
24
|
module NewRelic
|
4
25
|
module Agent
|
5
26
|
module Configuration
|
@@ -28,6 +49,10 @@ module NewRelic
|
|
28
49
|
"#<#{self.class.name}:#{object_id} #{super}>"
|
29
50
|
end
|
30
51
|
|
52
|
+
def to_hash
|
53
|
+
{}.replace(self)
|
54
|
+
end
|
55
|
+
|
31
56
|
protected
|
32
57
|
# turns {'a' => {'b' => 'c'}} into {'a.b' => 'c'}
|
33
58
|
def dot_flattened(nested_hash, names=[], result={})
|
@@ -2,17 +2,47 @@ module NewRelic
|
|
2
2
|
module Agent
|
3
3
|
module Configuration
|
4
4
|
DEFAULTS = {
|
5
|
-
:config_path =>
|
6
|
-
|
5
|
+
:config_path => Proc.new {
|
6
|
+
# Check a sequence of file locations for newrelic.yml
|
7
|
+
files = []
|
8
|
+
files << File.join("config","newrelic.yml")
|
9
|
+
files << File.join("newrelic.yml")
|
10
|
+
if ENV["HOME"]
|
11
|
+
files << File.join(ENV["HOME"], ".newrelic", "newrelic.yml")
|
12
|
+
files << File.join(ENV["HOME"], "newrelic.yml")
|
13
|
+
end
|
14
|
+
files.detect do |file|
|
15
|
+
File.expand_path(file) if File.exists? file
|
16
|
+
end
|
17
|
+
},
|
7
18
|
:app_name => Proc.new { NewRelic::Control.instance.env },
|
8
|
-
:dispatcher => Proc.new { NewRelic::Control.instance.local_env.
|
9
|
-
|
19
|
+
:dispatcher => Proc.new { NewRelic::Control.instance.local_env.discovered_dispatcher },
|
20
|
+
:framework => Proc.new do
|
21
|
+
case
|
22
|
+
when defined?(::NewRelic::TEST) then :test
|
23
|
+
when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
|
24
|
+
when defined?(::Rails)
|
25
|
+
case Rails::VERSION::MAJOR
|
26
|
+
when 0..2
|
27
|
+
:rails
|
28
|
+
when 3
|
29
|
+
:rails3
|
30
|
+
when 4
|
31
|
+
:rails4
|
32
|
+
else
|
33
|
+
Agent.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}"
|
34
|
+
end
|
35
|
+
when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
|
36
|
+
when defined?(::NewRelic::IA) then :external
|
37
|
+
else :ruby
|
38
|
+
end
|
39
|
+
end,
|
10
40
|
:enabled => true,
|
11
41
|
:monitor_mode => Proc.new { self[:enabled] },
|
12
42
|
:agent_enabled => Proc.new do
|
13
43
|
self[:enabled] &&
|
14
44
|
(self[:developer_mode] || self[:monitor_mode] || self[:monitor_daemons]) &&
|
15
|
-
!!NewRelic::
|
45
|
+
!!NewRelic::Agent.config[:dispatcher]
|
16
46
|
end,
|
17
47
|
:developer_mode => Proc.new { self[:developer] },
|
18
48
|
:developer => false,
|
@@ -36,11 +66,17 @@ module NewRelic
|
|
36
66
|
:start_channel_listener => false,
|
37
67
|
:data_report_period => 60,
|
38
68
|
:keep_retrying => true,
|
69
|
+
:report_instance_busy => true,
|
39
70
|
|
40
71
|
:log_file_name => 'newrelic_agent.log',
|
41
72
|
:log_file_path => 'log/',
|
42
73
|
:log_level => 'info',
|
43
74
|
|
75
|
+
:'audit_log.enabled' => false,
|
76
|
+
:'audit_log.path' => Proc.new {
|
77
|
+
File.join(self[:log_file_path], 'newrelic_audit.log')
|
78
|
+
},
|
79
|
+
|
44
80
|
:disable_samplers => false,
|
45
81
|
:disable_resque => false,
|
46
82
|
:disable_dj => false,
|
@@ -79,10 +115,11 @@ module NewRelic
|
|
79
115
|
:'rum.load_episodes_file' => true,
|
80
116
|
:'browser_monitoring.auto_instrument' => Proc.new { self[:'rum.enabled'] },
|
81
117
|
|
82
|
-
:'
|
83
|
-
|
118
|
+
:'cross_process.enabled' => true,
|
119
|
+
|
120
|
+
:'thread_profiler.enabled' => Proc.new { NewRelic::Agent::ThreadProfiler.is_supported? },
|
84
121
|
|
85
|
-
:marshaller => Proc.new { NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported? ?
|
122
|
+
:marshaller => Proc.new { NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported? ? 'json' : 'pruby' }
|
86
123
|
}.freeze
|
87
124
|
end
|
88
125
|
end
|