Skip to content

Commit

Permalink
Merge branch 'prod' into preprod
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanadrianmarc authored Dec 9, 2024
2 parents 4cf0103 + 9a71e68 commit 8da0b06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8da0b06

Please sign in to comment.