-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
688 additions
and
84 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# frozen_string_literal: true | ||
|
||
module Burials | ||
## | ||
# Monitor functions for Rails logging and StatsD | ||
# | ||
class Monitor | ||
CLAIM_STATS_KEY = 'api.burial_claim' | ||
|
||
## | ||
# log GET 404 from controller | ||
# @see BurialClaimsController | ||
# | ||
# @param confirmation_number [UUID] saved_claim guid | ||
# @param current_user [User] | ||
# @param e [ActiveRecord::RecordNotFound] | ||
# | ||
def track_show404(confirmation_number, current_user, e) | ||
Rails.logger.error('21P-530EZ submission not found', | ||
{ confirmation_number:, user_uuid: current_user&.uuid, message: e&.message }) | ||
end | ||
|
||
## | ||
# log GET 500 from controller | ||
# @see BurialClaimsController | ||
# | ||
# @param confirmation_number [UUID] saved_claim guid | ||
# @param current_user [User] | ||
# @param e [Error] | ||
# | ||
def track_show_error(confirmation_number, current_user, e) | ||
Rails.logger.error('21P-530EZ fetching submission failed', | ||
{ confirmation_number:, user_uuid: current_user&.uuid, message: e&.message }) | ||
end | ||
|
||
## | ||
# log POST processing started | ||
# @see BurialClaimsController | ||
# | ||
# @param claim [Pension::SavedClaim] | ||
# @param current_user [User] | ||
# | ||
def track_create_attempt(claim, current_user) | ||
StatsD.increment("#{CLAIM_STATS_KEY}.attempt") | ||
Rails.logger.info('21P-530EZ submission to Sidekiq begun', | ||
{ confirmation_number: claim&.confirmation_number, user_uuid: current_user&.uuid }) | ||
end | ||
|
||
## | ||
# log POST processing failure | ||
# @see BurialClaimsController | ||
# | ||
# @param in_progress_form [InProgressForm] | ||
# @param claim [SavedClaim::Burial] | ||
# @param current_user [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-530EZ 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 }) | ||
end | ||
|
||
## | ||
# log POST processing success | ||
# @see BurialClaimsController | ||
# | ||
# @param in_progress_form [InProgressForm] | ||
# @param claim [SavedClaim::Burial] | ||
# @param current_user [User] | ||
# | ||
def track_create_success(in_progress_form, claim, current_user) | ||
StatsD.increment("#{CLAIM_STATS_KEY}.success") | ||
if claim.form_start_date | ||
claim_duration = claim.created_at - claim.form_start_date | ||
tags = ["form_id:#{claim.form_id}"] | ||
StatsD.measure('saved_claim.time-to-file', claim_duration, tags:) | ||
end | ||
context = { | ||
confirmation_number: claim&.confirmation_number, | ||
user_uuid: current_user&.uuid, | ||
in_progress_form_id: in_progress_form&.id | ||
} | ||
Rails.logger.info('21P-530EZ submission to Sidekiq success', context) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.