Skip to content

Commit a43103f

Browse files
committed
Improved network client logging to include request id
1 parent f18e66a commit a43103f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/networking/NetworkClientImpl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class NetworkClientImpl implements NetworkClient {
8282
final static private String CONTENT_CRC32C = "Content-CRC32C";
8383
final static private int MAX_CONNECTION_PER_ROUTE = 50;
8484
final static private int MAX_CONNECTION_TOTAL = 100;
85+
final static private String REQUEST_ID_HEADER = "x-amz-request-id";
8586

8687
final private ConnectionDetails connectionDetails;
8788

@@ -187,13 +188,21 @@ public WebResponse getResponse(final Ds3Request request) throws IOException {
187188
int redirectCount = 0;
188189
do {
189190
final CloseableHttpResponse response = requestExecutor.execute();
191+
String requestId = "Unknown";
192+
if (response.containsHeader(REQUEST_ID_HEADER)) {
193+
requestId = response.getFirstHeader(REQUEST_ID_HEADER).getValue();
194+
}
190195
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_TEMPORARY_REDIRECT) {
191196
redirectCount++;
197+
LOG.info("Performing retry - attempt: {} for request #{}",
198+
redirectCount,
199+
requestId);
192200
response.close();
193-
LOG.info("Performing retry - attempt: {}", redirectCount);
194201
}
195202
else {
196-
LOG.info("Got response from server");
203+
LOG.info("Server responded with {} for request #{}",
204+
response.getStatusLine().getStatusCode(),
205+
requestId);
197206
return new WebResponseImpl(response);
198207
}
199208
} while (redirectCount < this.connectionDetails.getRetries());

0 commit comments

Comments
 (0)