From 247296ac3c311a91ee49719a62746906e1d91aaf Mon Sep 17 00:00:00 2001 From: Dan Lim Date: Fri, 6 Sep 2024 12:19:04 -0500 Subject: [PATCH] re-add custom datadog metrics logging --- .../lighthouse/create_intent_to_file_job.rb | 10 ++++- .../benefits_claims/intent_to_file/monitor.rb | 40 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/app/sidekiq/lighthouse/create_intent_to_file_job.rb b/app/sidekiq/lighthouse/create_intent_to_file_job.rb index 46f28f46cdd..b17fe8be709 100644 --- a/app/sidekiq/lighthouse/create_intent_to_file_job.rb +++ b/app/sidekiq/lighthouse/create_intent_to_file_job.rb @@ -69,7 +69,15 @@ def perform(in_progress_form_id, veteran_icn, participant_id) service.create_intent_to_file(itf_type, '') itf_log_monitor.track_create_itf_success(itf_type, form.created_at.to_s, form.user_account_id) rescue MissingICNError, MissingParticipantIDError, InvalidITFTypeError, FormNotFoundError => e - itf_log_monitor.track_create_itf_failure(itf_type, form.created_at.to_s, form.user_account_id, e) + if veteran_icn.blank? + itf_log_monitor.track_missing_user_icn(form, e) + elsif participant_id.blank? + itf_log_monitor.track_missing_user_pid(form, e) + elsif form.blank? + itf_log_monitor.track_missing_form(form, e) + elsif itf_type.blank? + itf_log_monitor.track_invalid_itf_type(form, e) + end rescue => e itf_log_monitor.track_create_itf_failure(itf_type, form.created_at.to_s, form.user_account_id, e) raise e diff --git a/lib/lighthouse/benefits_claims/intent_to_file/monitor.rb b/lib/lighthouse/benefits_claims/intent_to_file/monitor.rb index 217e83ed25a..b3f6d9c3b9d 100644 --- a/lib/lighthouse/benefits_claims/intent_to_file/monitor.rb +++ b/lib/lighthouse/benefits_claims/intent_to_file/monitor.rb @@ -46,6 +46,46 @@ def track_create_itf_exhaustion(itf_type, form, error) } Rails.logger.error("Lighthouse::CreateIntentToFileJob create #{itf_type} ITF exhausted", context) end + + def track_missing_user_icn(form, error) + StatsD.increment('user.icn.blank') + context = { + error: error.message, + in_progress_form_id: form.id, + user_account_uuid: form.user_account_id + } + Rails.logger.info('V0 InProgressFormsController async ITF user.icn is blank', context) + end + + def track_missing_user_pid(form, error) + StatsD.increment('user.participant_id.blank') + context = { + error: error.message, + in_progress_form_id: form.id, + user_account_uuid: form.user_account_id + } + Rails.logger.info('V0 InProgressFormsController async ITF user.participant_id is blank', context) + end + + def track_missing_form(form, error) + StatsD.increment('form.missing') + context = { + error: error.message, + in_progress_form_id: form.id, + user_account_uuid: form.user_account_id + } + Rails.logger.info('V0 InProgressFormsController async ITF form is missing', context) + end + + def track_invalid_itf_type(form, error) + StatsD.increment('itf.type.invalid') + context = { + error: error.message, + in_progress_form_id: form.id, + user_account_uuid: form.user_account_id + } + Rails.logger.info('V0 InProgressFormsController async ITF invalid ITF type', context) + end end end end