Skip to content

Commit

Permalink
fix: [#468] mising request ID when not provided by client
Browse files Browse the repository at this point in the history
When the client does not provide a request ID it generates one and it's
also inclueded in the logs. This commtis fixes the missing request id
in the logs for this case.

Output without this patch:

```
curl -i localhost:3001/v1/about/license

2024-02-12T18:34:30.331362304+00:00 [API][INFO] request; method=GET uri=/v1/about/license request_id=
2024-02-12T18:34:30.331575353+00:00 [API][INFO] response; latency=0 status=200 OK request_id=
```
  • Loading branch information
josecelano committed Feb 12, 2024
1 parent a206737 commit 2eaeba8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/web/api/server/v1/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ pub fn router(app_data: Arc<AppData>) -> Router {
router
.layer(DefaultBodyLimit::max(10_485_760))
.layer(CompressionLayer::new())
.layer(PropagateHeaderLayer::new(HeaderName::from_static("x-request-id")))
.layer(SetRequestIdLayer::x_request_id(RequestIdGenerator))
.layer(PropagateHeaderLayer::new(HeaderName::from_static("x-request-id")))
.layer(
TraceLayer::new_for_http()
.make_span_with(DefaultMakeSpan::new().level(Level::INFO))
Expand Down Expand Up @@ -89,6 +89,7 @@ pub fn router(app_data: Arc<AppData>) -> Router {
tracing::Level::INFO, "response", latency = %latency_ms, status = %status_code, request_id = %request_id);
}),
)
.layer(SetRequestIdLayer::x_request_id(RequestIdGenerator))
}

/// Endpoint for container health check.
Expand Down

0 comments on commit 2eaeba8

Please sign in to comment.