Skip to content

Commit

Permalink
updates and reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle committed Dec 30, 2024
1 parent d4f0857 commit 0aef510
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion lib/new_relic/agent/agent_helpers/startup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def already_started?
def start
return unless agent_should_start?

# early agent
log_startup
check_config_and_start_agent
log_version_and_pid
Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic/agent/configuration/default_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2189,14 +2189,14 @@ def self.notify
},
# Agent Control
:'agent_control.fleet_id' => {
:default => 'j2e4a6n0v1', # TODO: set default to nil before release
:default => nil,
:public => true,
:type => String,
:allowed_from_server => false,
:description => 'This assigns a fleet id to the language agent. This id is generated by agent control. If this setting is present, it indicates the agent is running in a super agent/fleet environment and health file(s) will be generated.'
},
:'agent_control.health.delivery_location' => {
:default => 'health/', # TODO: set default to EMPTY_STRING before release
:default => NewRelic::Agent::EMPTY_STR,
:public => true,
:type => String,
:allowed_from_server => false,
Expand Down
10 changes: 5 additions & 5 deletions lib/new_relic/agent/health_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def initialize
FORCED_DISCONNECT = {healthy: false, last_error: 'NR-APM-003', message: 'Forced disconnect received from New Relic (HTTP status code 410)'}
HTTP_ERROR = {healthy: false, last_error: 'NR-APM-004', message: 'HTTP error response code [%s] recevied from New Relic while sending data type [%s]'}
MISSING_APP_NAME = {healthy: false, last_error: 'NR-APM-005', message: 'Missing application name in agent configuration'}
# we don't raise an error when this happens at this time
APP_NAME_EXCEEDED = {healthy: false, last_error: 'NR-APM-006', message: 'The maximum number of configured app names (3) exceeded'}
# we don't raise an error when this happens at this time
PROXY_CONFIG_ERROR = {healthy: false, last_error: 'NR-APM-007', message: 'HTTP Proxy configuration error; response code [%s]'}
# we don't raise an error when this happens
# APP_NAME_EXCEEDED = {healthy: false, last_error: 'NR-APM-006', message: 'The maximum number of configured app names (3) exceeded'}
# we don't raise an error when this happens
# PROXY_CONFIG_ERROR = {healthy: false, last_error: 'NR-APM-007', message: 'HTTP Proxy configuration error; response code [%s]'}
AGENT_DISABLED = {healthy: false, last_error: 'NR-APM-008', message: 'Agent is disabled via configuration'}
FAILED_TO_CONNECT = {healthy: false, last_error: 'NR-APM-009', message: 'Failed to connect to New Relic data collector'}
FAILED_TO_PARSE_CONFIG = {healthy: false, last_error: 'NR-APM-010', message: 'Agent config file is not able to be parsed'}
Expand All @@ -48,7 +48,7 @@ def update_message(options)

def create_and_run_health_check_loop
return NewRelic::Agent.logger.debug('agent_control.fleet_id not found, skipping health checks') unless @fleet_id
return NewRelic::Agent.logger.debug('agent_control.health.file_destination not found, skipping health checks') unless @delivery_location
return NewRelic::Agent.logger.debug('agent_control.health.file_destination not found, skipping health checks') unless @delivery_location.empty?
return NewRelic::Agent.logger.debug('agent_control.health.frequency zero or less, skipping health checks') unless @frequency > 0

NewRelic::Agent.record_metric('Supportability/AgentControl/Health/enabled', 1)
Expand Down
10 changes: 6 additions & 4 deletions lib/new_relic/agent/new_relic_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ def relay_request(request, opts)
attempts += 1
response = attempt_request(request, opts)
rescue *CONNECTION_ERRORS => e
# TODO: HTTP CONNECTION ERRORS
# Seems that proxy errors would bubble up here
close_shared_connection
if attempts < MAX_ATTEMPTS
::NewRelic::Agent.logger.debug("Retrying request to #{opts[:collector]}#{filtered_uri(opts[:uri])} after #{e}")
Expand Down Expand Up @@ -641,9 +639,13 @@ def check_post_size(post_string, endpoint)
def send_request(opts)
request = prep_request(opts)
response = relay_request(request, opts)
return response if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPAccepted)

handle_error_response(response, opts[:endpoint])
if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPAccepted)
NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::HEALTHY)
response
else
handle_error_response(response, opts[:endpoint])
end
end

def log_response(response)
Expand Down
1 change: 0 additions & 1 deletion lib/new_relic/control/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def init_plugin(options = {})

init_config(options)
NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
# start_health_loop
init_instrumentation
init_security_agent
end
Expand Down
2 changes: 1 addition & 1 deletion test/new_relic/dependency_detection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def test_already_executed_items_are_not_executed_again
unexecuted.expect :executed, false
unexecuted.expect :dependencies_satisfied?, true
unexecuted.expect :disabled_configured?, false
unexecuted.expect :execute, -> { true }
unexecuted.expect :execute, -> { execution_took_place = true }
executed = Minitest::Mock.new
executed.expect :executed, true
unexecuted.expect :disabled_configured?, false
Expand Down

0 comments on commit 0aef510

Please sign in to comment.