feat(http): improve error logging with client IP#7503
feat(http): improve error logging with client IP#7503maximk777 wants to merge 4 commits intoGreptimeTeam:mainfrom
Conversation
8a1b081 to
cffbbc3
Compare
|
I think we add a new function here, add a unittest for it would be better |
- Add logging to ErrorResponse::from_error_message() - Add middleware to log HTTP errors with client IP Closes GreptimeTeam#7328 Signed-off-by: maximk777 <maximkirienkov777@gmail.com>
cffbbc3 to
5a86ec8
Compare
|
Done! Added unit tests for the middleware. |
evenyag
left a comment
There was a problem hiding this comment.
I have also found one place missing the error log:
greptimedb/src/servers/src/http/result/prometheus_resp.rs
Lines 67 to 76 in 9343da7
Could you also add it for the PrometheusJsonResponse?
Restore rich Debug logging in from_error(), add URI/method/matched path to client IP middleware, and only log when client address is available. Signed-off-by: evenyag <realevenyag@gmail.com>
…ging Signed-off-by: evenyag <realevenyag@gmail.com> # Conflicts: # src/servers/src/http.rs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44166133cf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| authorize::check_http_auth, | ||
| )) | ||
| .layer(middleware::from_fn(hints::extract_hints)) | ||
| .layer(middleware::from_fn(client_ip::log_error_with_client_ip)) |
There was a problem hiding this comment.
Move client-IP error logger ahead of auth short-circuit
Placing log_error_with_client_ip after the auth middleware means any response that authorize::check_http_auth returns directly (for example 401/403 from missing or invalid credentials) never reaches this logger, so those error responses are not logged with client address. This is a behavior gap for real traffic where auth rejects requests, and it contradicts the intended “log 4xx/5xx with client IP” coverage.
Useful? React with 👍 / 👎.
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
Closes #7328
What's changed and what's your intention?
This PR improves HTTP error logging as requested in #7328.
Limitations:
PR Checklist
Please convert it to a draft if some of the following conditions are not met.