Skip to content

Commit 1966806

Browse files
committed
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
1 parent 738ca35 commit 1966806

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

actionpack/lib/action_controller/metal/instrumentation.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def process_action(*)
3535
payload[:response] = response
3636
payload[:status] = response.status
3737
result
38+
rescue => error
39+
payload[:status] = ActionDispatch::ExceptionWrapper.status_code_for_exception(error.class.name)
40+
raise
3841
ensure
3942
append_info_to_payload(payload)
4043
end

0 commit comments

Comments
 (0)