Class: Burials::Monitor

Inherits:
ZeroSilentFailures::Monitor show all
Defined in:
lib/burials/monitor.rb

Overview

Monitor functions for Rails logging and StatsD

Constant Summary collapse

CLAIM_STATS_KEY =

statsd key for api

'api.burial_claim'
SUBMISSION_STATS_KEY =

statsd key for sidekiq

'worker.lighthouse.submit_benefits_intake_claim'

Instance Attribute Summary collapse

Attributes inherited from Logging::Monitor

#service

Instance Method Summary collapse

Methods inherited from ZeroSilentFailures::Monitor

#log_silent_failure, #log_silent_failure_avoided

Methods inherited from Logging::Monitor

#parse_caller, #track_request

Constructor Details

#initializeMonitor

Returns a new instance of Monitor.



19
20
21
22
23
# File 'lib/burials/monitor.rb', line 19

def initialize
  super('burial-application')

  @tags = ['form_id:21P-530EZ']
end

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



17
18
19
# File 'lib/burials/monitor.rb', line 17

def tags
  @tags
end

Instance Method Details

#track_create_attempt(claim, current_user) ⇒ Object

log POST processing started

Parameters:

See Also:

  • BurialClaimsController


70
71
72
73
74
75
76
77
78
# File 'lib/burials/monitor.rb', line 70

def track_create_attempt(claim, current_user)
  additional_context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid: current_user&.,
    tags:
  }
  track_request('info', '21P-530EZ submission to Sidekiq begun', "#{CLAIM_STATS_KEY}.attempt",
                call_location: caller_locations.first, **additional_context)
end

#track_create_error(in_progress_form, claim, current_user, e = nil) ⇒ Object

log POST processing failure

Parameters:

See Also:

  • BurialClaimsController


110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/burials/monitor.rb', line 110

def track_create_error(in_progress_form, claim, current_user, e = nil)
  additional_context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid: current_user&.,
    in_progress_form_id: in_progress_form&.id,
    errors: claim&.errors&.errors,
    message: e&.message,
    tags:
  }
  track_request('error', '21P-530EZ submission to Sidekiq failed', "#{CLAIM_STATS_KEY}.failure",
                call_location: caller_locations.first, **additional_context)
end

#track_create_success(in_progress_form, claim, current_user) ⇒ Object

log POST processing success

Parameters:

See Also:

  • BurialClaimsController


131
132
133
134
135
136
137
138
139
140
141
# File 'lib/burials/monitor.rb', line 131

def track_create_success(in_progress_form, claim, current_user)
  additional_context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid: current_user&.,
    in_progress_form_id: in_progress_form&.id,
    errors: claim&.errors&.errors,
    tags:
  }
  track_request('info', '21P-530EZ submission to Sidekiq success', "#{CLAIM_STATS_KEY}.success",
                call_location: caller_locations.first, **additional_context)
end

#track_create_validation_error(in_progress_form, claim, current_user) ⇒ Object

log POST claim save validation error

Parameters:

See Also:

  • BurialClaimsController


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/burials/monitor.rb', line 89

def track_create_validation_error(in_progress_form, claim, current_user)
  additional_context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid: current_user&.,
    in_progress_form_id: in_progress_form&.id,
    errors: claim&.errors&.errors,
    tags:
  }
  track_request('error', '21P-530EZ submission validation error', "#{CLAIM_STATS_KEY}.validation_error",
                call_location: caller_locations.first, **additional_context)
end

#track_process_attachment_error(in_progress_form, claim, current_user) ⇒ Object

log process_attachments! error

Parameters:

See Also:

  • BurialClaimsController


151
152
153
154
155
156
157
158
159
160
161
# File 'lib/burials/monitor.rb', line 151

def track_process_attachment_error(in_progress_form, claim, current_user)
  additional_context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid: current_user&.,
    in_progress_form_id: in_progress_form&.id,
    errors: claim&.errors&.errors,
    tags:
  }
  track_request('error', '21P-530EZ process attachment error', "#{CLAIM_STATS_KEY}.process_attachment_error",
                call_location: caller_locations.first, **additional_context)
end

#track_show404(confirmation_number, current_user, e) ⇒ Object

log GET 404 from controller

Parameters:

  • confirmation_number (UUID)

    saved_claim guid

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

See Also:

  • BurialClaimsController


33
34
35
36
37
38
39
40
41
42
# File 'lib/burials/monitor.rb', line 33

def track_show404(confirmation_number, current_user, e)
  additional_context = {
    confirmation_number:,
    user_account_uuid: current_user&.,
    message: e&.message,
    tags:
  }
  track_request('error', '21P-530EZ submission not found', CLAIM_STATS_KEY,
                call_location: caller_locations.first, **additional_context)
end

#track_show_error(confirmation_number, current_user, e) ⇒ Object

log GET 500 from controller

Parameters:

  • confirmation_number (UUID)

    saved_claim guid

  • current_user (User)
  • e (Error)

See Also:

  • BurialClaimsController


52
53
54
55
56
57
58
59
60
61
# File 'lib/burials/monitor.rb', line 52

def track_show_error(confirmation_number, current_user, e)
  additional_context = {
    confirmation_number:,
    user_account_uuid: current_user&.,
    message: e&.message,
    tags:
  }
  track_request('error', '21P-530EZ fetching submission failed', CLAIM_STATS_KEY,
                call_location: caller_locations.first, **additional_context)
end

#track_submission_exhaustion(msg, claim = nil) ⇒ Object

log Sidkiq job exhaustion, complete failure after all retries

Parameters:

  • msg (Hash)

    sidekiq exhaustion response

  • claim (SavedClaim::Burial) (defaults to: nil)

See Also:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/burials/monitor.rb', line 170

def track_submission_exhaustion(msg, claim = nil)
   = msg['args'].length <= 1 ? nil : msg['args'][1]
  additional_context = {
    confirmation_number: claim&.confirmation_number,
    user_account_uuid: ,
    form_id: claim&.form_id,
    claim_id: msg['args'].first,
    message: msg,
    tags:
  }
  call_location = caller_locations.first

  if claim
    Burials::NotificationEmail.new(claim.id).deliver(:error)
    log_silent_failure_avoided(additional_context, , call_location:)
  else
    log_silent_failure(additional_context, , call_location:)
  end

  track_request('error', 'Lighthouse::SubmitBenefitsIntakeClaim Burial 21P-530EZ submission to LH exhausted!',
                "#{SUBMISSION_STATS_KEY}.exhausted", call_location:, **additional_context)
end