Module: Contrast::Agent::Reporting::ResponseHandlerUtils

Includes:
NgResponseExtractor, ResponseExtractor
Included in:
ReporterClient, ResponseHandler
Defined in:
lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb

Overview

This module holds utilities required by the reporting service response handler

Constant Summary collapse

ERROR_CODES =
{
    message_not_sent: '400',
    access_forbidden: '401',
    access_forbidden_no_action: '403',
    application_do_not_exist: '404',
    unprocessable_entity: '422',
    too_many_requests: '429'
}.cs__freeze
APP_NON_EXISTENT_MSG =
'Application does not exist! Either it has not been created or has ' \
'been deleted or archived. ' \
'Disabling permanently.'
SUSPEND_MSG =
'Reporter is temporarily suspended.'
UNSUCCESSFULLY_RECEIVED_MSG =
'The Reporter was unable to send message.'
FORBIDDEN_MSG =
'Access was forbidden for current Report because the request authentication ' \
'information was not provided'
FORBIDDEN_NO_ACTION_MSG =
'Report access was forbidden because the supplied credentials failed ' \
'to authenticate the Agent'
UNPROCESSABLE_ENTITY_MSG =
'Reporter received Unprocessable Entity response. Disabling permanently.'
RETRY_AFTER_MSG =
'There are too many requests of this type being sent by this Agent. ' \
"#{ SUSPEND_MSG }".cs__freeze

Instance Method Summary collapse

Instance Method Details

#last_application_modifiedString

String format of the app last modified Header:<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT

Returns:



52
53
54
# File 'lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb', line 52

def last_application_modified
  @_last_application_modified
end

#last_response_codeObject



38
39
40
# File 'lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb', line 38

def last_response_code
  @_last_response_code ||= ''
end

#last_server_modifiedString

String format of the server last modified Header:<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT

Returns:



45
46
47
# File 'lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb', line 45

def last_server_modified
  @_last_server_modified
end

#stop_reporting(message, info_hash) ⇒ Object

Cease reporting about this application

Parameters:

  • message (String)

    Message to log

  • info_hash (Hash)

    information about the context to log.



60
61
62
63
64
# File 'lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb', line 60

def stop_reporting message, info_hash
  Contrast::Agent.reporter&.stop!
  log_error_msg(message, info_hash)
  ::Contrast::AGENT.disable!
end