-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed ZSF monitoring and updated specs
- Loading branch information
Showing
6 changed files
with
61 additions
and
51 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,36 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'zero_silent_failures/monitor' | ||
require 'logging/monitor' | ||
|
||
module ClaimDocuments | ||
## | ||
# Monitor functions for Rails logging and StatsD | ||
# @todo abstract, split logging for controller and sidekiq | ||
# | ||
class Monitor < ::ZeroSilentFailures::Monitor | ||
class Monitor < ::Logging::Monitor | ||
# statsd key for document uploads | ||
DOCUMENT_STATS_KEY = 'api.document_upload' | ||
|
||
def track_document_upload_attempt(form_id, current_user) | ||
StatsD.increment("#{DOCUMENT_STATS_KEY}.attempt", tags: ["form_id: #{form_id}"]) | ||
Rails.logger.info("Creating PersistentAttachment FormID=#{form_id}", | ||
{ user_account_uuid: current_user&.user_account_uuid, | ||
statsd: "#{DOCUMENT_STATS_KEY}.attempt" }) | ||
additional_context = { | ||
user_account_uuid: current_user&.user_account_uuid, | ||
statsd: "#{DOCUMENT_STATS_KEY}.attempt", | ||
tags: ["form_id:#{form_id}"] | ||
} | ||
track_request('info', "Creating PersistentAttachment FormID=#{form_id}", "#{DOCUMENT_STATS_KEY}.attempt", | ||
**additional_context) | ||
end | ||
|
||
def track_document_upload_success(form_id, attachment_id, current_user) | ||
StatsD.increment("#{DOCUMENT_STATS_KEY}.success", tags: ["form_id: #{form_id}"]) | ||
Rails.logger.info("Success creating PersistentAttachment FormID=#{form_id} AttachmentID=#{attachment_id}", | ||
{ attachment_id:, user_account_uuid: current_user&.user_account_uuid, | ||
statsd: "#{DOCUMENT_STATS_KEY}.success" }) | ||
additional_context = { | ||
attachment_id:, | ||
user_account_uuid: current_user&.user_account_uuid, | ||
tags: ["form_id:#{form_id}"], | ||
statsd: "#{DOCUMENT_STATS_KEY}.success" | ||
} | ||
track_request('info', "Success creating PersistentAttachment FormID=#{form_id} AttachmentID=#{attachment_id}", | ||
"#{DOCUMENT_STATS_KEY}.success", **additional_context) | ||
end | ||
|
||
def track_document_upload_failed(form_id, attachment_id, current_user, e) | ||
StatsD.increment("#{DOCUMENT_STATS_KEY}.failure", tags: ["form_id: #{form_id}"]) | ||
log_silent_failure({ form_id: form_id, attachment_id: attachment_id }, current_user&.user_account_uuid) | ||
Rails.logger.error("Error creating PersistentAttachment FormID=#{form_id} AttachmentID=#{attachment_id} #{e}", | ||
{ attachment_id:, user_account_uuid: current_user&.user_account_uuid, | ||
statsd: "#{DOCUMENT_STATS_KEY}.failure", message: e&.message }) | ||
additional_context = { | ||
attachment_id:, | ||
user_account_uuid: current_user&.user_account_uuid, | ||
tags: ["form_id:#{form_id}"], | ||
statsd: "#{DOCUMENT_STATS_KEY}.failure", | ||
message: e&.message | ||
} | ||
track_request('error', "Error creating PersistentAttachment FormID=#{form_id} AttachmentID=#{attachment_id} #{e}", | ||
"#{DOCUMENT_STATS_KEY}.failure", **additional_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
Binary file not shown.
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