diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f65d82..ef159b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,12 @@ - (Dan) Updates ruby version to 2.7.8 and alpine version to 3.16 [GH-143](https://github.com/epimorphics/standard-reports-ui/issues/143) -## 1.5.4 - 2024-09 +## 1.5.4 - 2024-10 +- (Jon) Wrapped the Internal Error Instrumentation in an `unless` block to + ensure the application does not report internal errors to the Prometheus + metrics when the error is a 404 or 422 thereby reducing the noise in the Slack + alerts channel - (Jon) Updated the application exceptions controller to instrument the `ActiveSupport::Notifications` for internal errors [GH-139](https://github.com/epimorphics/standard-reports-ui/issues/139) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 31e9aca..5776c10 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,8 +27,10 @@ def log_request_result # or attempt to render a generic error page if no specific error page exists unless Rails.application.config.consider_all_requests_local rescue_from StandardError do |e| - # Instrument ActiveSupport::Notifications for internal errors: - ActiveSupport::Notifications.instrument('internal_error.application', exception: e) + # Instrument ActiveSupport::Notifications for internal errors but only for non-404 errors: + unless e.is_a?(ActionController::RoutingError) || e.is_a?(ActionView::MissingTemplate) + ActiveSupport::Notifications.instrument('internal_error.application', exception: e) + end # Trigger the appropriate error handling method based on the exception case e.class when ActionController::RoutingError, ActionView::MissingTemplate @@ -104,7 +106,7 @@ def detailed_request_log(duration) body: request.body.gets&.gsub("\n", '\n'), method: request.method, status: response.status, - message: Rack::Utils::HTTP_STATUS_CODES[response.status] + message: response.message || Rack::Utils::HTTP_STATUS_CODES[response.status] } case response.status