-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override default response failed
error response in logs from TraceLayer
in tower-http
#1146
Labels
Enhancement / Feature Request
Something New
Comments
response failed
error response from TraceLayer
in tower-http
response failed
error response in logs from TraceLayer
in tower-http
This was referenced Dec 23, 2024
josecelano
added a commit
to josecelano/torrust-tracker
that referenced
this issue
Dec 23, 2024
From: ``` 2024-12-23T15:54:25.842837Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` To: ``` 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` The target has been changed: ``` 2024-12-23T15:54:25.842837Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` It was changed to: - Easily identify the origin of the error in our code. - Allow to insert more fields in the future, for example, to write assertions about logs. 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms
josecelano
added a commit
to josecelano/torrust-tracker
that referenced
this issue
Dec 23, 2024
From: ``` 2024-12-23T15:54:25.842837Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` To: ``` 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` The target has been changed: ``` 2024-12-23T15:54:25.842837Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` It was changed to: - Easily identify the origin of the error in our code. - Allow to insert more fields in the future, for example, to write assertions about logs.
josecelano
added a commit
that referenced
this issue
Dec 23, 2024
9ac676c feat: [#1146] override tower-http tracing error (Jose Celano) Pull request description: This overrides the default log errors when a 500 response is sent to the client. From: ``` 2024-12-23T15:54:25.842837Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` To: ``` 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` The target has been changed: ``` 2024-12-23T15:54:25.842837Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms 2024-12-23T16:06:53.553023Z ERROR API: response failed classification=Status code: 500 Internal Server Error latency=0 ms ``` It was changed to: - Easily identify the origin of the error in our code. - Allow for the inserting of more fields in the future, for example, to write assertions about logs. ACKs for top commit: josecelano: ACK 9ac676c Tree-SHA512: 4e2eb9057ea15bf28f2a5ab6a8d8becc072520d428fe6718ea2275a7ccd028e21d9907fb7d9626b8beba80ccfd72a60c040bdae902c1ec4b41fa31a8e8014974
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relates to: #1069
I'm working on issue #1069
We have some errors in the logs automatically added by the TraceLayer we use in Axum. Errors loke like this:
As I explained on the other issue the error comes from using the TraceLayer in the router definition:
TraceLayer
uses a default "on failure" function that prints that error when the response is a 500 response.We have the possibility to override the error message calling the
on_failure
on the router TraceLayer builder:I would do it because:
The text was updated successfully, but these errors were encountered: