From c7cc0a965a3f0799f2ef0c37e38a2e1b49b7a165 Mon Sep 17 00:00:00 2001 From: mikefinneran <110622959+mikefinneran@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:38:57 -0400 Subject: [PATCH] APPEALS-26109: Metric Service Sentry Updates (#19316) Co-authored-by: kshiflett88 Co-authored-by: Chris-Martine --- app/controllers/help_controller.rb | 2 +- app/controllers/intakes_controller.rb | 2 +- app/jobs/update_appellant_representation_job.rb | 1 - app/models/metric.rb | 2 +- app/services/metrics_service.rb | 17 ++++++++++++++++- app/views/certifications/v2.html.erb | 2 +- app/views/decision_reviews/index.html.erb | 2 +- .../dispatch/establish_claims/index.html.erb | 2 +- app/views/hearings/index.html.erb | 2 +- app/views/inbox/index.html.erb | 2 +- app/views/intake_manager/index.html.erb | 2 +- app/views/queue/index.html.erb | 2 +- app/views/reader/appeal/index.html.erb | 14 +++++++------- app/views/test/users/index.html.erb | 2 +- .../update_appellant_representation_job_spec.rb | 2 +- 15 files changed, 35 insertions(+), 21 deletions(-) diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index bcd4b1f84d8..b03af1f4e3d 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -6,7 +6,7 @@ class HelpController < ApplicationController def feature_toggle_ui_hash(user = current_user) { programOfficeTeamManagement: FeatureToggle.enabled?(:program_office_team_management, user: user), - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } end diff --git a/app/controllers/intakes_controller.rb b/app/controllers/intakes_controller.rb index d1831b82fbf..4bb2df9afea 100644 --- a/app/controllers/intakes_controller.rb +++ b/app/controllers/intakes_controller.rb @@ -153,7 +153,7 @@ def feature_toggle_ui_hash updatedAppealForm: FeatureToggle.enabled?(:updated_appeal_form, user: current_user), hlrScUnrecognizedClaimants: FeatureToggle.enabled?(:hlr_sc_unrecognized_claimants, user: current_user), vhaClaimReviewEstablishment: FeatureToggle.enabled?(:vha_claim_review_establishment, user: current_user), - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } end diff --git a/app/jobs/update_appellant_representation_job.rb b/app/jobs/update_appellant_representation_job.rb index 081741c104b..36ee5b65857 100644 --- a/app/jobs/update_appellant_representation_job.rb +++ b/app/jobs/update_appellant_representation_job.rb @@ -7,7 +7,6 @@ class UpdateAppellantRepresentationJob < CaseflowJob include ActionView::Helpers::DateHelper queue_with_priority :low_priority application_attr :queue - APP_NAME = "caseflow_job" METRIC_GROUP_NAME = UpdateAppellantRepresentationJob.name.underscore TOTAL_NUMBER_OF_APPEALS_TO_UPDATE = 1000 diff --git a/app/models/metric.rb b/app/models/metric.rb index 9022b493b6e..f28623bb62e 100644 --- a/app/models/metric.rb +++ b/app/models/metric.rb @@ -77,7 +77,7 @@ def css_id def self.default_object(klass, params, user) { uuid: params[:uuid], - user: user, + user: user || User.new(full_name: "Stand in user for testing", css_id: SecureRandom.uuid, station_id: 'Metrics'), metric_name: params[:name] || METRIC_TYPES[:log], metric_class: klass&.try(:name) || klass&.class.name || self.name, metric_group: params[:group] || METRIC_GROUPS[:service], diff --git a/app/services/metrics_service.rb b/app/services/metrics_service.rb index cf00098a244..ee36efb98aa 100644 --- a/app/services/metrics_service.rb +++ b/app/services/metrics_service.rb @@ -64,7 +64,22 @@ def self.record(description, service: nil, name: "unknown", caller: nil) increment_datadog_counter("request_error", service, name, app) if service - metric_params[:type] = Metric::METRIC_TYPES[:error] + metric_params = { + name: "Stand in object if metrics_service.record fails", + message: "Variables not initialized before failure", + type: Metric::METRIC_TYPES[:error], + product: "", + attrs: { + service: "", + endpoint: "" + }, + sent_to: [[Metric::LOG_SYSTEMS[:rails_console]]], + sent_to_info: "", + start: 'Time not recorded', + end: 'Time not recorded', + duration: 'Time not recorded' + } + store_record_metric(uuid, metric_params, caller) # Re-raise the same error. We don't want to interfere at all in normal error handling. diff --git a/app/views/certifications/v2.html.erb b/app/views/certifications/v2.html.erb index 86abe688bf7..8634f07ea5d 100644 --- a/app/views/certifications/v2.html.erb +++ b/app/views/certifications/v2.html.erb @@ -6,7 +6,7 @@ buildDate: build_date, vacolsId: @certification.vacols_id, featureToggles: { - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } }) %> <% end %> diff --git a/app/views/decision_reviews/index.html.erb b/app/views/decision_reviews/index.html.erb index 53d2e9ef2ae..e377f8dce05 100644 --- a/app/views/decision_reviews/index.html.erb +++ b/app/views/decision_reviews/index.html.erb @@ -11,7 +11,7 @@ businessLineUrl: business_line.url, featureToggles: { decisionReviewQueueSsnColumn: FeatureToggle.enabled?(:decision_review_queue_ssn_column, user: current_user), - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) }, baseTasksUrl: business_line.tasks_url, taskFilterDetails: task_filter_details diff --git a/app/views/dispatch/establish_claims/index.html.erb b/app/views/dispatch/establish_claims/index.html.erb index 1084ca8126e..3c8c256783a 100644 --- a/app/views/dispatch/establish_claims/index.html.erb +++ b/app/views/dispatch/establish_claims/index.html.erb @@ -10,7 +10,7 @@ userQuota: user_quota && user_quota.to_hash, currentUserHistoricalTasks: current_user_historical_tasks.map(&:to_hash), featureToggles: { - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } }) %> <% end %> diff --git a/app/views/hearings/index.html.erb b/app/views/hearings/index.html.erb index a86792326ac..55241926043 100644 --- a/app/views/hearings/index.html.erb +++ b/app/views/hearings/index.html.erb @@ -31,7 +31,7 @@ userIsBoardAttorney: current_user.attorney?, userIsHearingAdmin: current_user.in_hearing_admin_team?, featureToggles: { - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } }) %> <% end %> diff --git a/app/views/inbox/index.html.erb b/app/views/inbox/index.html.erb index 0e551431277..dba5d4f67ae 100644 --- a/app/views/inbox/index.html.erb +++ b/app/views/inbox/index.html.erb @@ -10,7 +10,7 @@ pagination: pagination }, featureToggles: { - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } }) %> <% end %> diff --git a/app/views/intake_manager/index.html.erb b/app/views/intake_manager/index.html.erb index bb52177d28b..9659d728be5 100644 --- a/app/views/intake_manager/index.html.erb +++ b/app/views/intake_manager/index.html.erb @@ -6,7 +6,7 @@ feedbackUrl: feedback_url, buildDate: build_date featureToggles: { - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } }) %> <% end %> diff --git a/app/views/queue/index.html.erb b/app/views/queue/index.html.erb index 7e96ef7f0d1..5fa1ce56ec4 100644 --- a/app/views/queue/index.html.erb +++ b/app/views/queue/index.html.erb @@ -53,7 +53,7 @@ cavc_remand_granted_substitute_appellant: FeatureToggle.enabled?(:cavc_remand_granted_substitute_appellant, user: current_user), cavc_dashboard_workflow: FeatureToggle.enabled?(:cavc_dashboard_workflow, user: current_user), cc_appeal_workflow: FeatureToggle.enabled?(:cc_appeal_workflow, user: current_user), - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user), + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user), cc_vacatur_visibility: FeatureToggle.enabled?(:cc_vacatur_visibility, user: current_user) } }) %> diff --git a/app/views/reader/appeal/index.html.erb b/app/views/reader/appeal/index.html.erb index b640ad9a70c..f0689983c98 100644 --- a/app/views/reader/appeal/index.html.erb +++ b/app/views/reader/appeal/index.html.erb @@ -12,13 +12,13 @@ windowSlider: FeatureToggle.enabled?(:window_slider, user: current_user), readerSelectorsMemoized: FeatureToggle.enabled?(:bulk_upload_documents, user: current_user), readerGetDocumentLogging: FeatureToggle.enabled?(:reader_get_document_logging, user: current_user), - metricsLogRestError: FeatureToggle.enabled_metric?(:metrics_log_rest_error, user: current_user), - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user), - metricsLoadScreen: FeatureToggle.enabled_metric?(:metrics_load_screen, user: current_user), - metricsRecordPDFJSGetDocument: FeatureToggle.enabled_metric?(:metrics_get_pdfjs_doc, user: current_user), - metricsReaderRenderText: FeatureToggle.enabled_metric?(:metrics_reader_render_text, user: current_user), - metricsLogRestSuccess: FeatureToggle.enabled_metric?(:metrics_log_rest_success, user: current_user), - metricsPdfStorePages: FeatureToggle.enabled_metric?(:metrics_pdf_store_pages, user: current_user) + metricsLogRestError: FeatureToggle.enabled?(:metrics_log_rest_error, user: current_user), + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user), + metricsLoadScreen: FeatureToggle.enabled?(:metrics_load_screen, user: current_user), + metricsRecordPDFJSGetDocument: FeatureToggle.enabled?(:metrics_get_pdfjs_doc, user: current_user), + metricsReaderRenderText: FeatureToggle.enabled?(:metrics_reader_render_text, user: current_user), + metricsLogRestSuccess: FeatureToggle.enabled?(:metrics_log_rest_success, user: current_user), + metricsPdfStorePages: FeatureToggle.enabled?(:metrics_pdf_store_pages, user: current_user) }, buildDate: build_date }) %> diff --git a/app/views/test/users/index.html.erb b/app/views/test/users/index.html.erb index 0ac3fbdee9c..3bb0dff6ff5 100644 --- a/app/views/test/users/index.html.erb +++ b/app/views/test/users/index.html.erb @@ -17,7 +17,7 @@ epTypes: ep_types, featureToggles: { interfaceVersion2: FeatureToggle.enabled?(:interface_version_2, user: current_user), - metricsBrowserError: FeatureToggle.enabled_metric?(:metrics_browser_error, user: current_user) + metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user) } }) %> <% end %> diff --git a/spec/jobs/update_appellant_representation_job_spec.rb b/spec/jobs/update_appellant_representation_job_spec.rb index 107e2975451..5bfe84c9db4 100644 --- a/spec/jobs/update_appellant_representation_job_spec.rb +++ b/spec/jobs/update_appellant_representation_job_spec.rb @@ -43,7 +43,7 @@ ) expect(DataDogService).to receive(:emit_gauge).with( app_name: "queue_job", - attrs: { endpoint: "AppellantNotification.appeal_mapper", service: "queue_job" }, + attrs: { endpoint: "AppellantNotification.appeal_mapper", service: "queue_job", uuid: anything }, metric_group: "service", metric_name: "request_latency", metric_value: anything