You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fluss.apache.org by ab...@apache.org on 2026/08/28 18:42:09 UTC
(fluss) branch main updated: [gateway] Include concrete path in REST access logs (#4142)
This is an automated email from the ASF dual-hosted git repository.
fresh-borzoni pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluss.git
The following commit(s) were added to refs/heads/main by this push:
new 26db5b7da [gateway] Include concrete path in REST access logs (#4142)
26db5b7da is described below
commit 26db5b7dae77b1abbb48c401b361a425ee90161d
Author: Junbo Wang <be...@gmail.com>
AuthorDate: Sat Aug 29 02:42:04 2026 +0800
[gateway] Include concrete path in REST access logs (#4142)
Keep the bounded route template for metrics while adding the URI path to completed request log entries.
---
fluss-gateway/src/protocol/rest/mod.rs | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/fluss-gateway/src/protocol/rest/mod.rs b/fluss-gateway/src/protocol/rest/mod.rs
index 71719ce2e..e8e953c8d 100644
--- a/fluss-gateway/src/protocol/rest/mod.rs
+++ b/fluss-gateway/src/protocol/rest/mod.rs
@@ -547,6 +547,8 @@ async fn catch_panic(request: Request, next: Next) -> Response {
/// Logs and counts one completed request.
///
+/// Metrics use the bounded matched `route`; only the access log includes the concrete `path`.
+///
/// The `cluster` label stays bounded: a route without a `{cluster}` segment reports `none`, and a
/// segment that names no configured cluster reports `unknown`, so a caller-supplied value can never
/// become a label value.
@@ -558,14 +560,14 @@ fn request_log(
Box::pin(async move {
let started = Instant::now();
let method = request.method().clone();
+ let path = request.uri().path().to_string();
let route = request
.extensions()
.get::<MatchedPath>()
.map(MatchedPath::as_str)
.unwrap_or("<unmatched>")
.to_string();
- let cluster =
- cluster_label(backend.as_deref(), &route, request.uri().path()).to_string();
+ let cluster = cluster_label(backend.as_deref(), &route, &path).to_string();
let request_id = request_id(&request);
let response = next.run(request).await;
let elapsed = started.elapsed();
@@ -579,7 +581,14 @@ fn request_log(
);
log::info!(
"{}",
- format_request_log(&method, &route, &request_id, status, elapsed.as_millis())
+ format_request_log(
+ &method,
+ &route,
+ &path,
+ &request_id,
+ status,
+ elapsed.as_millis(),
+ )
);
response
})
@@ -604,12 +613,13 @@ fn cluster_label<'a>(backend: Option<&dyn FlussBackend>, route: &str, path: &'a
fn format_request_log(
method: &Method,
route: &str,
+ path: &str,
request_id: &RequestId,
status: StatusCode,
elapsed_ms: u128,
) -> String {
format!(
- "method={method} route={route} request_id={} status={} elapsed_ms={elapsed_ms}",
+ "method={method} route={route} path={path} request_id={} status={} elapsed_ms={elapsed_ms}",
request_id.as_str(),
status.as_u16()
)
@@ -1136,17 +1146,18 @@ mod tests {
}
#[test]
- fn request_log_contains_protocol_context() {
+ fn request_log_contains_route_and_path_context() {
let message = format_request_log(
&Method::POST,
"/v1/clusters/{cluster}/databases",
+ "/v1/clusters/default/databases",
&RequestId(Arc::from("request-7")),
StatusCode::CREATED,
23,
);
assert_eq!(
message,
- "method=POST route=/v1/clusters/{cluster}/databases request_id=request-7 status=201 elapsed_ms=23"
+ "method=POST route=/v1/clusters/{cluster}/databases path=/v1/clusters/default/databases request_id=request-7 status=201 elapsed_ms=23"
);
}
}