Skip to content

Commit 2f0b819

Browse files
committed
Use pre-remap URL in slow log output
The slow log was printing the post-remap (origin-facing) URL which is less useful for debugging since it does not show what the client actually requested. Use t_state.unmapped_url (the pre-remap URL) instead, with a fallback to client_request URL if unmapped_url is not available.
1 parent 16951f2 commit 2f0b819

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/proxy/http/HttpSM.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7773,12 +7773,21 @@ HttpSM::update_stats()
77737773

77747774
// print slow requests if the threshold is set (> 0) and if we are over the time threshold
77757775
if (t_state.txn_conf->slow_log_threshold != 0 && ink_hrtime_from_msec(t_state.txn_conf->slow_log_threshold) < total_time) {
7776+
// Use the unmapped (pre-remap) URL so the slow log shows the incoming client URL.
7777+
// unmapped_url may not be valid if the transaction ended before reaching the remap
7778+
// stage (e.g. client timeout during header read, malformed request). In that case
7779+
// fall back to client_request URL which hasn't been remapped yet either.
77767780
char url_string[256] = "";
7777-
int offset = 0;
7778-
int skip = 0;
7779-
7780-
t_state.hdr_info.client_request.url_print(url_string, sizeof(url_string) - 1, &offset, &skip);
7781-
url_string[offset] = 0; // NULL terminate the string
7781+
int url_length = 0;
7782+
if (t_state.unmapped_url.valid()) {
7783+
t_state.unmapped_url.string_get_buf(url_string, sizeof(url_string) - 1, &url_length);
7784+
} else {
7785+
int offset = 0;
7786+
int skip = 0;
7787+
t_state.hdr_info.client_request.url_print(url_string, sizeof(url_string) - 1, &offset, &skip);
7788+
url_length = offset;
7789+
}
7790+
url_string[url_length] = 0; // NULL terminate the string
77827791

77837792
// unique id
77847793
char unique_id_string[128] = "";

0 commit comments

Comments
 (0)