Skip to content

Override tower-http tracing errors - #1151

Merged
josecelano merged 1 commit into
torrust:developfrom
josecelano:1146-override-default-response-failed-error-response-in-logs-from-tracelayer-in-tower-http
Dec 23, 2024
Merged

josecelano merged 1 commit into
torrust:developfrom
josecelano:1146-override-default-response-failed-error-response-in-logs-from-tracelayer-in-tower-http

Conversation

@josecelano

@josecelano josecelano commented Dec 23, 2024 •

Copy link
Copy Markdown
Member

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.

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
josecelano force-pushed the 1146-override-default-response-failed-error-response-in-logs-from-tracelayer-in-tower-http branch from cd9adb6 to 9ac676c Compare December 23, 2024 16:13
@josecelano

Copy link
Copy Markdown
Member Author

ACK 9ac676c

@codecov

codecov Bot commented Dec 23, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 45.71429% with 19 lines in your changes missing coverage. Please review.

Project coverage is 76.02%. Comparing base (90f6a01) to head (9ac676c).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
src/servers/health_check_api/server.rs 12.50% 7 Missing ⚠️
src/servers/http/v1/routes.rs 12.50% 7 Missing ⚠️
src/servers/logging.rs 63.63% 4 Missing ⚠️
src/servers/apis/routes.rs 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1151      +/-   ##
===========================================
- Coverage    76.13%   76.02%   -0.11%     
===========================================
  Files          173      174       +1     
  Lines        11551    11583      +32     
  Branches     11551    11583      +32     
===========================================
+ Hits          8794     8806      +12     
- Misses        2590     2608      +18     
- Partials       167      169       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@josecelano
josecelano merged commit 0f40030 into torrust:develop Dec 23, 2024

This branch was previously deployed

1 inactive deployment
coverage — 9ac676c7 Deployed Dec 23, 2024 by josecelano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Override default response failed error response in logs from TraceLayer in tower-http

1 participant