You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
97233f5 fix: missing logs for HTTP requests (Jose Celano)
Pull request description:
Relates to:
- #1150
- #1152
Some log lines (tracing spans) were missing. In addition to that, we were using new spans to log requests and responses instead of using the span provided by the `TraceLayer`. That enables you to join all the log events related to the same request.
This fix is needed to continue with this issue: #1150
Because it allows the use of a "request-id" header to identify logs.
We can write log assertions by matching lines with the `request-id` used in the request.
For example, if you make this request:
```console
curl -H "x-request-id: YOUR_REQUEST_ID" http://0.0.0.0:1212/api/v1/stats?token=InvalidToken
```
This is the new output (which was missing before this change):
```output
2024-12-23T17:53:06.530704Z INFO request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: request method=GET uri=/api/v1/stats?token=InvalidToken request_id=YOUR_REQUEST_ID
2024-12-23T17:53:06.530777Z ERROR request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: response latency_ms=0 status_code=500 Internal Server Error request_id=YOUR_REQUEST_ID
2024-12-23T17:53:06.530785Z ERROR request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: response failed failure_classification=Status code: 500 Internal Server Error latency=0 ms
```
As you can see, now we have the "request_id=YOUR_REQUEST_ID" field, which can be used to identify the test that made the request and write a log assertion for that concrete expected line.
ACKs for top commit:
josecelano:
ACK 97233f5
Tree-SHA512: 075a3cdeafa735d4a263c942b34594049adc9d42ed5e8a1bef043ffea394bfdae7cf109928f1311d4589f40804c72ebe71c66d6ec5380f5ce472ba9ba5304ad5
0 commit comments