Skip to content

Commit 2eaeba8

Browse files
committed
fix: [#468] mising request ID when not provided by client
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= ```
1 parent a206737 commit 2eaeba8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/web/api/server/v1/routes.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ pub fn router(app_data: Arc<AppData>) -> Router {
5757
router
5858
.layer(DefaultBodyLimit::max(10_485_760))
5959
.layer(CompressionLayer::new())
60-
.layer(PropagateHeaderLayer::new(HeaderName::from_static("x-request-id")))
6160
.layer(SetRequestIdLayer::x_request_id(RequestIdGenerator))
61+
.layer(PropagateHeaderLayer::new(HeaderName::from_static("x-request-id")))
6262
.layer(
6363
TraceLayer::new_for_http()
6464
.make_span_with(DefaultMakeSpan::new().level(Level::INFO))
@@ -89,6 +89,7 @@ pub fn router(app_data: Arc<AppData>) -> Router {
8989
tracing::Level::INFO, "response", latency = %latency_ms, status = %status_code, request_id = %request_id);
9090
}),
9191
)
92+
.layer(SetRequestIdLayer::x_request_id(RequestIdGenerator))
9293
}
9394

9495
/// Endpoint for container health check.

0 commit comments

Comments
 (0)