lib/new_relic/agent/agent.rb in newrelic_rpm-5.1.0.344 vs lib/new_relic/agent/agent.rb in newrelic_rpm-5.2.0.345
- old
+ new
@@ -6,11 +6,10 @@
require 'net/https'
require 'net/http'
require 'logger'
require 'zlib'
require 'stringio'
-require 'new_relic/agent/sampled_buffer'
require 'new_relic/agent/autostart'
require 'new_relic/agent/harvester'
require 'new_relic/agent/hostname'
require 'new_relic/agent/new_relic_service'
require 'new_relic/agent/pipe_service'
@@ -19,11 +18,10 @@
require 'new_relic/agent/commands/agent_command_router'
require 'new_relic/agent/event_listener'
require 'new_relic/agent/cross_app_monitor'
require 'new_relic/agent/distributed_trace_monitor'
require 'new_relic/agent/synthetics_monitor'
-require 'new_relic/agent/synthetics_event_buffer'
require 'new_relic/agent/transaction_event_recorder'
require 'new_relic/agent/custom_event_aggregator'
require 'new_relic/agent/sampler_collection'
require 'new_relic/agent/javascript_instrumentor'
require 'new_relic/agent/vm/monotonic_gc_profiler'
@@ -181,11 +179,12 @@
end
return if !needs_restart ||
!Agent.config[:agent_enabled] ||
!Agent.config[:monitor_mode] ||
- disconnected?
+ disconnected? ||
+ !control.security_settings_valid?
::NewRelic::Agent.logger.debug "Starting the worker thread in #{Process.pid} (parent #{Process.ppid}) after forking."
channel_id = options[:report_to_channel]
install_pipe_service(channel_id) if channel_id
@@ -842,23 +841,38 @@
def finish_setup(config_data)
return if config_data == nil
@service.agent_id = config_data['agent_run_id']
+ security_policies = config_data.delete('security_policies')
+
+ add_server_side_config(config_data)
+ add_security_policy_config(security_policies) if security_policies
+
+ log_connection!(config_data)
+ @transaction_rules = RulesEngine.create_transaction_rules(config_data)
+ @stats_engine.metric_rules = RulesEngine.create_metric_rules(config_data)
+
+ # If you're adding something else here to respond to the server-side config,
+ # use Agent.instance.events.subscribe(:finished_configuring) callback instead!
+ end
+
+ def add_server_side_config(config_data)
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, Agent.config)
Agent.config.replace_or_add_config(server_config)
- log_connection!(config_data)
+ end
- @transaction_rules = RulesEngine.create_transaction_rules(config_data)
- @stats_engine.metric_rules = RulesEngine.create_metric_rules(config_data)
-
- # If you're adding something else here to respond to the server-side config,
- # use Agent.instance.events.subscribe(:finished_configuring) callback instead!
+ def add_security_policy_config(security_policies)
+ ::NewRelic::Agent.logger.info 'Installing security policies'
+ security_policy_source = NewRelic::Agent::Configuration::SecurityPolicySource.new(security_policies)
+ Agent.config.replace_or_add_config(security_policy_source)
+ # drop data collected before applying security policies
+ drop_buffered_data
end
class WaitOnConnectTimeout < StandardError
end