Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new datadog metric to track ITFs initiated excluding retries #21166

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/v0/in_progress_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def update

if Flipper.enabled?(:intent_to_file_lighthouse_enabled, @current_user) && form.id_previously_changed? &&
Lighthouse::CreateIntentToFileJob::ITF_FORMS.include?(form.form_id)
BenefitsClaims::IntentToFile::Monitor.new.track_create_itf_initiated(form.form_id, form.created_at,
@current_user.uuid, form.id)
Lighthouse::CreateIntentToFileJob.perform_async(form.id, @current_user.icn,
@current_user.participant_id)
end
Expand Down
13 changes: 13 additions & 0 deletions lib/lighthouse/benefits_claims/intent_to_file/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ def initialize
super('pension-itf')
end

# This metric does not include retries from failed attempts
def track_create_itf_initiated(itf_type, form_start_date, user_account_uuid, form_id)
StatsD.increment("#{STATSD_KEY_PREFIX}.#{itf_type}.initiated")
context = {
itf_type:,
form_start_date:,
user_account_uuid:
}
Rails.logger.info("Lighthouse::CreateIntentToFileJob create #{itf_type} ITF initiated for form ##{form_id}",
context)
end

# This metric includes retries from failed attempts
def track_create_itf_begun(itf_type, form_start_date, user_account_uuid)
StatsD.increment("#{STATSD_KEY_PREFIX}.#{itf_type}.begun")
context = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
let(:current_user) { create(:user) }
let(:monitor_error) { create(:monitor_error) }

describe '#track_create_itf_initiated' do
it 'logs a create ITF initiated' do
log = "Lighthouse::CreateIntentToFileJob create pension ITF initiated for form ##{ipf.id}"
payload = {
itf_type: 'pension',
form_start_date: ipf.created_at,
user_account_uuid: current_user.user_account_uuid
}
expect(StatsD).to receive(:increment).with("#{itf_stats_key}.pension.initiated")
expect(Rails.logger).to receive(:info).with(log, payload)

monitor.track_create_itf_initiated('pension', ipf.created_at, current_user.user_account_uuid, ipf.id)
end
end

describe '#track_create_itf_begun' do
it 'logs a create ITF begun' do
log = 'Lighthouse::CreateIntentToFileJob create pension ITF begun'
Expand Down
Loading