Class: IncomeAndAssets::Claims::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/income_and_assets/claims/monitor.rb

Constant Summary collapse

CLAIM_STATS_KEY =

statsd key for api

'api.income_and_assets'

Instance Method Summary collapse

Instance Method Details

#track_create_attempt(claim, user_account_uuid) ⇒ Object

log POST processing started

Parameters:

See Also:

  • IncomeAndAssetsClaimsController


53
54
55
56
57
58
59
60
# File 'lib/income_and_assets/claims/monitor.rb', line 53

def track_create_attempt(claim, )
  StatsD.increment("#{CLAIM_STATS_KEY}.attempt")
  context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid:
  }
  Rails.logger.info('21P-0969 claim creation begun', context)
end

#track_create_error(in_progress_form_id, claim, user_account_uuid, e = nil) ⇒ Object

log POST processing failure

Parameters:

See Also:

  • IncomeAndAssetsClaimsController


71
72
73
74
75
76
77
78
79
80
81
# File 'lib/income_and_assets/claims/monitor.rb', line 71

def track_create_error(in_progress_form_id, claim, , e = nil)
  StatsD.increment("#{CLAIM_STATS_KEY}.failure")
  context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid:,
    in_progress_form_id:,
    errors: claim&.errors&.errors,
    message: e&.message
  }
  Rails.logger.error('21P-0969 claim creation failed', context)
end

#track_create_success(in_progress_form_id, claim, user_account_uuid) ⇒ Object

log POST processing success

Parameters:

See Also:

  • IncomeAndAssetsClaimsController


91
92
93
94
95
96
97
98
99
100
# File 'lib/income_and_assets/claims/monitor.rb', line 91

def track_create_success(in_progress_form_id, claim, )
  StatsD.increment("#{CLAIM_STATS_KEY}.success")
  if claim.form_start_date
    StatsD.measure('saved_claim.time-to-file', claim.created_at - claim.form_start_date,
                   tags: ["form_id:#{claim.form_id}"])
  end
  Rails.logger.info('21P-0969 claim creation success',
                    { confirmation_number: claim&.confirmation_number, user_account_uuid:,
                      in_progress_form_id: })
end

#track_show404(confirmation_number, user_account_uuid, e) ⇒ Object

log GET 404 from controller

Parameters:

  • confirmation_number (UUID)

    saved_claim guid

  • current_user (User)
  • e (ActiveRecord::RecordNotFound)

See Also:

  • IncomeAndAssetsClaimsController


20
21
22
23
24
25
26
27
# File 'lib/income_and_assets/claims/monitor.rb', line 20

def track_show404(confirmation_number, , e)
  context = {
    confirmation_number:,
    user_account_uuid:,
    message: e&.message
  }
  Rails.logger.error('21P-0969 claim not found', context)
end

#track_show_error(confirmation_number, user_account_uuid, e) ⇒ Object

log GET 500 from controller

Parameters:

  • confirmation_number (UUID)

    saved_claim guid

  • current_user (User)
  • e (Error)

See Also:

  • IncomeAndAssetsClaimsController


37
38
39
40
41
42
43
44
# File 'lib/income_and_assets/claims/monitor.rb', line 37

def track_show_error(confirmation_number, , e)
  context = {
    confirmation_number:,
    user_account_uuid:,
    message: e&.message
  }
  Rails.logger.error('21P-0969 fetching claim failed', context)
end