lib/new_relic/agent/agent.rb in newrelic_rpm-3.6.0.74.beta vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.6.0.78

- old
+ new

@@ -13,10 +13,11 @@ require 'new_relic/agent/configuration/manager' require 'new_relic/agent/database' require 'new_relic/agent/thread_profiler' require 'new_relic/agent/event_listener' require 'new_relic/agent/cross_app_monitor' +require 'new_relic/environment_report' module NewRelic module Agent # The Agent is a singleton that is instantiated when the plugin is @@ -42,11 +43,10 @@ @connect_state = :pending @connect_attempts = 0 @last_harvest_time = Time.now @obfuscator = lambda {|sql| NewRelic::Agent::Database.default_sql_obfuscator(sql) } - @forked = false # FIXME: temporary work around for RUBY-839 if Agent.config[:monitor_mode] @service = NewRelic::Agent::NewRelicService.new end @@ -181,11 +181,10 @@ # had not connected. # * <tt>:keep_retrying => false</tt> if we try to initiate a new # connection, this tells me to only try it once so this method returns # quickly if there is some kind of latency with the server. def after_fork(options={}) - @forked = true Agent.config.apply_config(NewRelic::Agent::Configuration::ManualSource.new(options), 1) if channel_id = options[:report_to_channel] @service = NewRelic::Agent::PipeService.new(channel_id) if connected? @@ -211,14 +210,10 @@ # I'm pretty sure we're not also forking new instances. start_worker_thread(options) @stats_engine.start_sampler_thread end - def forked? - @forked - end - # True if we have initialized and completed 'start' def started? @started end @@ -693,11 +688,11 @@ end # Checks whether we should send environment info, and if so, # returns the snapshot from the local environment def environment_for_connect - Agent.config[:send_environment_info] ? Control.instance.local_env.snapshot : [] + Agent.config[:send_environment_info] ? Array(EnvironmentReport.new) : [] end # Initializes the hash of settings that we send to the # server. Returns a literal hash containing the options def connect_settings @@ -743,11 +738,11 @@ if config_data['agent_config'] ::NewRelic::Agent.logger.debug "Using config from server" end ::NewRelic::Agent.logger.debug "Server provided config: #{config_data.inspect}" - server_config = NewRelic::Agent::Configuration::ServerSource.new(config_data) + server_config = NewRelic::Agent::Configuration::ServerSource.new(config_data, Agent.config) Agent.config.apply_config(server_config, 1) log_connection!(config_data) if @service add_rules_to_engine(config_data['transaction_name_rules'], NewRelic::Agent.instance.transaction_rules) @@ -1028,10 +1023,10 @@ ::NewRelic::Agent.logger.debug "retrying transmit_data after #{e}" retry end raise e ensure - NewRelic::Agent::Database.close_connections unless forked? + NewRelic::Agent::Database.close_connections duration = (Time.now - now).to_f @stats_engine.record_metrics('Supportability/Harvest', duration) end # This method contacts the server to send remaining data and