class NewRelic::Control::SecurityInterface

Constants

DISABLED
ENABLED
SUPPORTABILITY_PREFIX_SECURITY
SUPPORTABILITY_PREFIX_SECURITY_AGENT

Attributes

wait[RW]

Public Instance Methods

agent_started?() click to toggle source
# File lib/new_relic/control/security_interface.rb, line 19
def agent_started?
  (@agent_started ||= false) == true
end
init_agent() click to toggle source
# File lib/new_relic/control/security_interface.rb, line 27
def init_agent
  return if agent_started? || waiting?

  record_supportability_metrics

  if Agent.config[:'security.agent.enabled'] && !Agent.config[:high_security]
    Agent.logger.info('Invoking New Relic security module')
    require 'newrelic_security'

    @agent_started = true
  else
    Agent.logger.info('New Relic Security is completely disabled by one of the user-provided configurations: `security.agent.enabled` or `high_security`. Not loading security capabilities.')
    Agent.logger.info("high_security = #{Agent.config[:high_security]}")
    Agent.logger.info("security.agent.enabled = #{Agent.config[:'security.agent.enabled']}")
  end
rescue LoadError
  Agent.logger.info('New Relic security agent not found - skipping')
rescue StandardError => exception
  Agent.logger.error("Exception in New Relic security module loading: #{exception} #{exception.backtrace}")
end
record_supportability_metrics() click to toggle source
# File lib/new_relic/control/security_interface.rb, line 48
def record_supportability_metrics
  Agent.config[:'security.agent.enabled'] ? security_agent_metric(ENABLED) : security_agent_metric(DISABLED)
end
security_agent_metric(setting) click to toggle source
# File lib/new_relic/control/security_interface.rb, line 52
def security_agent_metric(setting)
  NewRelic::Agent.record_metric_once(SUPPORTABILITY_PREFIX_SECURITY_AGENT + setting)
end
waiting?() click to toggle source
# File lib/new_relic/control/security_interface.rb, line 23
def waiting?
  (@wait ||= false) == true
end