diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb
index <HASH>..<HASH> 100644
--- a/actionpack/lib/action_controller/metal/instrumentation.rb
+++ b/actionpack/lib/action_controller/metal/instrumentation.rb
@@ -35,6 +35,9 @@ module ActionController
         payload[:response] = response
         payload[:status]   = response.status
         result
+      rescue => error
+        payload[:status] = ActionDispatch::ExceptionWrapper.status_code_for_exception(error.class.name)
+        raise
       ensure
         append_info_to_payload(payload)
       end
Fix instrumenting internal server errors

In case of an exception we never reach setting the status in the
payload so it is unset afterward.

Let's catch the exception and set status based on the exception class name.
Then re-raise it.

This is basically the equivalent of what happens in

ActionController::LogSubscriber.process_action