Class: NewRelic::Agent::Connect::ResponseHandler
- Inherits:
-
Object
- Object
- NewRelic::Agent::Connect::ResponseHandler
- Defined in:
- lib/new_relic/agent/connect/response_handler.rb
Instance Method Summary collapse
- #add_security_policy_config(security_policies) ⇒ Object
- #add_server_side_config(config_data) ⇒ Object
-
#configure_agent(config_data) ⇒ Object
Takes a hash of configuration data returned from the server and uses it to set local variables and to initialize various parts of the agent that are configured separately.
-
#initialize(agent, config) ⇒ ResponseHandler
constructor
A new instance of ResponseHandler.
Constructor Details
#initialize(agent, config) ⇒ ResponseHandler
Returns a new instance of ResponseHandler.
9 10 11 12 |
# File 'lib/new_relic/agent/connect/response_handler.rb', line 9 def initialize(agent, config) @agent = agent @config = config end |
Instance Method Details
#add_security_policy_config(security_policies) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/new_relic/agent/connect/response_handler.rb', line 48 def add_security_policy_config(security_policies) ::NewRelic::Agent.logger.info('Installing security policies') security_policy_source = NewRelic::Agent::Configuration::SecurityPolicySource.new(security_policies) @config.replace_or_add_config(security_policy_source) # drop data collected before applying security policies @agent.drop_buffered_data end |
#add_server_side_config(config_data) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/new_relic/agent/connect/response_handler.rb', line 38 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, @config) @config.replace_or_add_config(server_config) end |
#configure_agent(config_data) ⇒ Object
Takes a hash of configuration data returned from the server and uses it to set local variables and to initialize various parts of the agent that are configured separately.
Can accommodate most arbitrary data - anything extra is ignored unless we say to do something with it here.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/new_relic/agent/connect/response_handler.rb', line 21 def configure_agent(config_data) return if config_data.nil? @agent.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 @agent.transaction_rules = RulesEngine.create_transaction_rules(config_data) @agent.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(:initial_configuration_complete) callback instead! end |