Repository navigation
feat: additional logging in the write path to capture db and ip - #26616
Merged
Merged
Conversation
praveen-influx
force-pushed
the
pk/additional-logging-write-path
branch
5 times, most recently
from
July 18, 2025 09:34
f20027c to
83c88d7
Compare
praveen-influx
force-pushed
the
pk/additional-logging-write-path
branch
from
July 18, 2025 10:00
83c88d7 to
8c194db
Compare
praveen-influx
marked this pull request as ready for review
July 18, 2025 10:00
praveen-influx
commented
Jul 18, 2025
| Err(error) => { | ||
| error!(%error, %method, path = uri.path(), ?content_length, "Error while handling request"); | ||
| let ip = client_ip.as_deref().unwrap_or(UNKNOWN_VAL); | ||
| match db.as_ref() { |
Contributor
Author
There was a problem hiding this comment.
I did start with a single error log line with database=unknown when db cannot be extracted from the query param, but realized that probably is going to be confusing for other requests that aren't db specific or db is in the body. So, ended up with 2 separate log lines (with / without database)
hiltontj
approved these changes
Jul 18, 2025
hiltontj
left a comment
Contributor
There was a problem hiding this comment.
Had one non-blocking comment.
Comment on lines
+2443
to
+2460
| // Extract client IP - should get socket address since no headers | ||
| let client_ip = req | ||
| .headers() | ||
| .get("x-forwarded-for") | ||
| .and_then(|h| h.to_str().ok()) | ||
| .and_then(|s| s.split(',').next()) | ||
| .map(|s| s.trim().to_string()) | ||
| .or_else(|| { | ||
| req.headers() | ||
| .get("x-real-ip") | ||
| .and_then(|h| h.to_str().ok()) | ||
| .map(|s| s.to_string()) | ||
| }) | ||
| .or_else(|| { | ||
| req.extensions() | ||
| .get::<std::net::SocketAddr>() | ||
| .map(|addr| addr.ip().to_string()) | ||
| }); |
Contributor
There was a problem hiding this comment.
Should this use the extract_client_ip function above? The code looks very similar.
Comment on lines
+2480
to
+2497
| // Extract client IP - should prefer header over socket | ||
| let client_ip = req | ||
| .headers() | ||
| .get("x-forwarded-for") | ||
| .and_then(|h| h.to_str().ok()) | ||
| .and_then(|s| s.split(',').next()) | ||
| .map(|s| s.trim().to_string()) | ||
| .or_else(|| { | ||
| req.headers() | ||
| .get("x-real-ip") | ||
| .and_then(|h| h.to_str().ok()) | ||
| .map(|s| s.to_string()) | ||
| }) | ||
| .or_else(|| { | ||
| req.extensions() | ||
| .get::<std::net::SocketAddr>() | ||
| .map(|addr| addr.ip().to_string()) | ||
| }); |
Contributor
There was a problem hiding this comment.
Same as previous comment.
hiltontj
approved these changes
Jul 18, 2025
mgattozzi
pushed a commit
that referenced
this pull request
Sep 8, 2025
port of: github.com//pull/26616
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: https://github.com/influxdata/influxdb_pro/issues/519
After this commit the log message on failed write looks like below,
The IP address is fetched from,
x-forwarded-forheader if available,x-real-ipif that is available,TlsStream(when running over TLS) orAddrStream(on non-TLS)This PR extends
TestServerto capture logs conditionally that can be used for assertions in the logs