Skip to content

Commit

Permalink
95932: Update Pensions monitor (#19287)
Browse files Browse the repository at this point in the history
  • Loading branch information
balexandr authored Nov 6, 2024
1 parent dd1c690 commit 1a2969a
Show file tree
Hide file tree
Showing 2 changed files with 325 additions and 144 deletions.
258 changes: 163 additions & 95 deletions modules/pensions/lib/pensions/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ def initialize
# @param e [ActiveRecord::RecordNotFound]
#
def track_show404(confirmation_number, current_user, e)
Rails.logger.error('21P-527EZ submission not found',
{ confirmation_number:, user_uuid: current_user&.uuid, message: e&.message })
additional_context = {
confirmation_number:,
user_account_uuid: current_user&.user_account_uuid,
message: e&.message,
tags: {
form_id: '21P-527EZ'
}
}
track_request('error', '21P-527EZ submission not found', CLAIM_STATS_KEY, additional_context,
call_location: caller_locations.first)
end

##
Expand All @@ -40,8 +48,16 @@ def track_show404(confirmation_number, current_user, e)
# @param e [Error]
#
def track_show_error(confirmation_number, current_user, e)
Rails.logger.error('21P-527EZ fetching submission failed',
{ confirmation_number:, user_uuid: current_user&.uuid, message: e&.message })
additional_context = {
confirmation_number:,
user_account_uuid: current_user&.user_account_uuid,
message: e&.message,
tags: {
form_id: '21P-527EZ'
}
}
track_request('error', '21P-527EZ fetching submission failed', CLAIM_STATS_KEY, additional_context,
call_location: caller_locations.first)
end

##
Expand All @@ -52,10 +68,15 @@ def track_show_error(confirmation_number, current_user, e)
# @param current_user [User]
#
def track_create_attempt(claim, current_user)
StatsD.increment("#{CLAIM_STATS_KEY}.attempt")
Rails.logger.info('21P-527EZ submission to Sidekiq begun',
{ confirmation_number: claim&.confirmation_number, user_uuid: current_user&.uuid,
statsd: "#{CLAIM_STATS_KEY}.attempt" })
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid: current_user&.user_account_uuid,
tags: {
form_id: '21P-527EZ'
}
}
track_request('info', '21P-527EZ submission to Sidekiq begun', "#{CLAIM_STATS_KEY}.attempt", additional_context,
call_location: caller_locations.first)
end

##
Expand All @@ -68,11 +89,17 @@ def track_create_attempt(claim, current_user)
# @param e [Error]
#
def track_create_validation_error(in_progress_form, claim, current_user)
StatsD.increment("#{CLAIM_STATS_KEY}.validation_error")
Rails.logger.error('21P-527EZ submission validation error',
{ confirmation_number: claim&.confirmation_number, user_uuid: current_user&.uuid,
in_progress_form_id: in_progress_form&.id, errors: claim&.errors&.errors,
statsd: "#{CLAIM_STATS_KEY}.validation_error" })
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid: current_user&.user_account_uuid,
in_progress_form_id: in_progress_form&.id,
errors: claim&.errors&.errors,
tags: {
form_id: '21P-527EZ'
}
}
track_request('error', '21P-527EZ submission validation error', "#{CLAIM_STATS_KEY}.validation_error",
additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -85,11 +112,18 @@ def track_create_validation_error(in_progress_form, claim, current_user)
# @param e [Error]
#
def track_create_error(in_progress_form, claim, current_user, e = nil)
StatsD.increment("#{CLAIM_STATS_KEY}.failure")
Rails.logger.error('21P-527EZ submission to Sidekiq failed',
{ confirmation_number: claim&.confirmation_number, user_uuid: current_user&.uuid,
in_progress_form_id: in_progress_form&.id, errors: claim&.errors&.errors,
message: e&.message, statsd: "#{CLAIM_STATS_KEY}.failure" })
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid: current_user&.user_account_uuid,
in_progress_form_id: in_progress_form&.id,
errors: claim&.errors&.errors,
message: e&.message,
tags: {
form_id: '21P-527EZ'
}
}
track_request('error', '21P-527EZ submission to Sidekiq failed', "#{CLAIM_STATS_KEY}.failure", additional_context,
call_location: caller_locations.first)
end

##
Expand All @@ -101,14 +135,16 @@ def track_create_error(in_progress_form, claim, current_user, e = nil)
# @param current_user [User]
#
def track_create_success(in_progress_form, claim, current_user)
StatsD.increment("#{CLAIM_STATS_KEY}.success")
context = {
additional_context = {
confirmation_number: claim&.confirmation_number,
user_uuid: current_user&.uuid,
user_account_uuid: current_user&.user_account_uuid,
in_progress_form_id: in_progress_form&.id,
statsd: "#{CLAIM_STATS_KEY}.success"
tags: {
form_id: '21P-527EZ'
}
}
Rails.logger.info('21P-527EZ submission to Sidekiq success', context)
track_request('info', '21P-527EZ submission to Sidekiq success', "#{CLAIM_STATS_KEY}.success",
additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -120,11 +156,17 @@ def track_create_success(in_progress_form, claim, current_user)
# @param e [Error]
#
def track_process_attachment_error(in_progress_form, claim, current_user)
StatsD.increment("#{CLAIM_STATS_KEY}.process_attachment_error")
Rails.logger.error('21P-527EZ process attachment error',
{ confirmation_number: claim&.confirmation_number, user_uuid: current_user&.uuid,
in_progress_form_id: in_progress_form&.id, errors: claim&.errors&.errors,
statsd: "#{CLAIM_STATS_KEY}.process_attachment_error" })
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid: current_user&.user_account_uuid,
in_progress_form_id: in_progress_form&.id,
errors: claim&.errors&.errors,
tags: {
form_id: '21P-527EZ'
}
}
track_request('error', '21P-527EZ process attachment error', "#{CLAIM_STATS_KEY}.process_attachment_error",
additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -133,17 +175,20 @@ def track_process_attachment_error(in_progress_form, claim, current_user)
#
# @param claim [Pension::SavedClaim]
# @param lighthouse_service [BenefitsIntake::Service]
# @param user_uuid [UUID]
# @param user_account_uuid [UUID]
#
def track_submission_begun(claim, lighthouse_service, user_uuid)
StatsD.increment("#{SUBMISSION_STATS_KEY}.begun")
Rails.logger.info('Lighthouse::PensionBenefitIntakeJob submission to LH begun',
{
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
confirmation_number: claim&.confirmation_number,
user_uuid:
})
def track_submission_begun(claim, lighthouse_service, user_account_uuid)
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid:,
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
tags: {
form_id: '21P-527EZ'
}
}
track_request('info', 'Lighthouse::PensionBenefitIntakeJob submission to LH begun',
"#{SUBMISSION_STATS_KEY}.begun", additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -152,19 +197,23 @@ def track_submission_begun(claim, lighthouse_service, user_uuid)
#
# @param claim [Pension::SavedClaim]
# @param lighthouse_service [BenefitsIntake::Service]
# @param user_uuid [UUID]
# @param user_account_uuid [UUID]
# @param upload [Hash] lighthouse upload data
#
def track_submission_attempted(claim, lighthouse_service, user_uuid, upload)
StatsD.increment("#{SUBMISSION_STATS_KEY}.attempt")
Rails.logger.info('Lighthouse::PensionBenefitIntakeJob submission to LH attempted', {
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
confirmation_number: claim&.confirmation_number,
user_uuid:,
file: upload[:file],
attachments: upload[:attachments]
})
def track_submission_attempted(claim, lighthouse_service, user_account_uuid, upload)
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid:,
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
file: upload[:file],
attachments: upload[:attachments],
tags: {
form_id: '21P-527EZ'
}
}
track_request('info', 'Lighthouse::PensionBenefitIntakeJob submission to LH attempted',
"#{SUBMISSION_STATS_KEY}.attempt", additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -173,16 +222,20 @@ def track_submission_attempted(claim, lighthouse_service, user_uuid, upload)
#
# @param claim [Pension::SavedClaim]
# @param lighthouse_service [BenefitsIntake::Service]
# @param user_uuid [UUID]
# @param user_account_uuid [UUID]
#
def track_submission_success(claim, lighthouse_service, user_uuid)
StatsD.increment("#{SUBMISSION_STATS_KEY}.success")
Rails.logger.info('Lighthouse::PensionBenefitIntakeJob submission to LH succeeded', {
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
confirmation_number: claim&.confirmation_number,
user_uuid:
})
def track_submission_success(claim, lighthouse_service, user_account_uuid)
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid:,
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
tags: {
form_id: '21P-527EZ'
}
}
track_request('info', 'Lighthouse::PensionBenefitIntakeJob submission to LH succeeded',
"#{SUBMISSION_STATS_KEY}.success", additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -191,18 +244,22 @@ def track_submission_success(claim, lighthouse_service, user_uuid)
#
# @param claim [Pension::SavedClaim]
# @param lighthouse_service [BenefitsIntake::Service]
# @param user_uuid [UUID]
# @param user_account_uuid [UUID]
# @param e [Error]
#
def track_submission_retry(claim, lighthouse_service, user_uuid, e)
StatsD.increment("#{SUBMISSION_STATS_KEY}.failure")
Rails.logger.warn('Lighthouse::PensionBenefitIntakeJob submission to LH failed, retrying', {
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
confirmation_number: claim&.confirmation_number,
user_uuid:,
message: e&.message
})
def track_submission_retry(claim, lighthouse_service, user_account_uuid, e)
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid:,
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
message: e&.message,
tags: {
form_id: '21P-527EZ'
}
}
track_request('warn', 'Lighthouse::PensionBenefitIntakeJob submission to LH failed, retrying',
"#{SUBMISSION_STATS_KEY}.failure", additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -215,16 +272,18 @@ def track_submission_retry(claim, lighthouse_service, user_uuid, e)
def track_submission_exhaustion(msg, claim = nil)
user_account_uuid = msg['args'].length <= 1 ? nil : msg['args'][1]
additional_context = {
form_id: claim&.form_id,
claim_id: msg['args'].first,
confirmation_number: claim&.confirmation_number,
message: msg
user_account_uuid: user_account_uuid,
claim_id: msg['args'].first,
form_id: claim&.form_id,
message: msg,
tags: {
form_id: '21P-527EZ'
}
}
log_silent_failure(additional_context, user_account_uuid, call_location: caller_locations.first)

StatsD.increment("#{SUBMISSION_STATS_KEY}.exhausted")
Rails.logger.error('Lighthouse::PensionBenefitIntakeJob submission to LH exhausted!',
user_uuid: user_account_uuid, **additional_context)
track_request('error', 'Lighthouse::PensionBenefitIntakeJob submission to LH exhausted!',
"#{SUBMISSION_STATS_KEY}.exhausted", additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -233,17 +292,23 @@ def track_submission_exhaustion(msg, claim = nil)
#
# @param claim [Pension::SavedClaim]
# @param lighthouse_service [LighthouseService]
# @param user_uuid [String]
# @param user_account_uuid [String]
# @param e [Exception]
#
def track_send_confirmation_email_failure(claim, lighthouse_service, user_uuid, e)
Rails.logger.warn('Lighthouse::PensionBenefitIntakeJob send_confirmation_email failed', {
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
confirmation_number: claim&.confirmation_number,
user_uuid:,
message: e&.message
})
def track_send_confirmation_email_failure(claim, lighthouse_service, user_account_uuid, e)
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid:,
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
message: e&.message,
tags: {
form_id: '21P-527EZ'
}
}

track_request('warn', 'Lighthouse::PensionBenefitIntakeJob send_confirmation_email failed', CLAIM_STATS_KEY,
additional_context, call_location: caller_locations.first)
end

##
Expand All @@ -252,19 +317,22 @@ def track_send_confirmation_email_failure(claim, lighthouse_service, user_uuid,
#
# @param claim [Pension::SavedClaim]
# @param lighthouse_service [BenefitsIntake::Service]
# @param user_uuid [UUID]
# @param user_account_uuid [UUID]
# @param e [Error]
#
def track_file_cleanup_error(claim, lighthouse_service, user_uuid, e)
StatsD.increment("#{SUBMISSION_STATS_KEY}.cleanup_failed")
Rails.logger.error('Lighthouse::PensionBenefitIntakeJob cleanup failed',
{
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
confirmation_number: claim&.confirmation_number,
user_uuid:,
error: e&.message
})
def track_file_cleanup_error(claim, lighthouse_service, user_account_uuid, e)
additional_context = {
confirmation_number: claim&.confirmation_number,
user_account_uuid:,
claim_id: claim&.id,
benefits_intake_uuid: lighthouse_service&.uuid,
error: e&.message,
tags: {
form_id: '21P-527EZ'
}
}
track_request('error', 'Lighthouse::PensionBenefitIntakeJob cleanup failed',
"#{SUBMISSION_STATS_KEY}.cleanup_failed", additional_context, call_location: caller_locations.first)
end
end
end
Loading

0 comments on commit 1a2969a

Please sign in to comment.