-
Notifications
You must be signed in to change notification settings - Fork 916
Log request ID and extended request ID with the requestId logger and … #2929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"category": "AWS SDK for Java v2", | ||
"contributor": "", | ||
"type": "bugfix", | ||
"description": "Log request ID and extended request ID with the request logger and requestId logger. See [#2876](https://github.com/aws/aws-sdk-java-v2/issues/2876)" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,14 @@ | |
|
||
package software.amazon.awssdk.core.internal.http; | ||
|
||
import static software.amazon.awssdk.core.SdkStandardLogger.logRequestId; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.core.Response; | ||
import software.amazon.awssdk.core.SdkStandardLogger; | ||
import software.amazon.awssdk.core.exception.RetryableException; | ||
import software.amazon.awssdk.core.exception.SdkClientException; | ||
import software.amazon.awssdk.core.exception.SdkException; | ||
|
@@ -68,6 +69,8 @@ private Response<OutputT> handleResponse(SdkHttpFullResponse httpResponse, | |
ExecutionAttributes executionAttributes) | ||
throws IOException, InterruptedException { | ||
|
||
logRequestId(httpResponse); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason to have picked this response handler to do the logging? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we log the response status code currently, so I just included the request ID here |
||
|
||
if (httpResponse.isSuccessful()) { | ||
OutputT response = handleSuccessResponse(httpResponse, executionAttributes); | ||
return Response.<OutputT>builder().httpResponse(httpResponse) | ||
|
@@ -93,7 +96,6 @@ private Response<OutputT> handleResponse(SdkHttpFullResponse httpResponse, | |
private OutputT handleSuccessResponse(SdkHttpFullResponse httpResponse, ExecutionAttributes executionAttributes) | ||
throws IOException, InterruptedException { | ||
try { | ||
SdkStandardLogger.REQUEST_LOGGER.debug(() -> "Received successful response: " + httpResponse.statusCode()); | ||
return successResponseHandler.handle(httpResponse, executionAttributes); | ||
} catch (IOException | InterruptedException | RetryableException e) { | ||
throw e; | ||
|
@@ -121,7 +123,6 @@ private SdkException handleErrorResponse(SdkHttpFullResponse httpResponse, | |
try { | ||
SdkException exception = errorResponseHandler.handle(httpResponse, executionAttributes); | ||
exception.fillInStackTrace(); | ||
SdkStandardLogger.REQUEST_LOGGER.debug(() -> "Received error response: " + exception); | ||
return exception; | ||
} catch (InterruptedException | IOException e) { | ||
throw e; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not handled by the combined response handler below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it seems AwsXmlPredicatedResponseHandler is used by s3, and combined response handler is used by all other services. (I just learned it yesterday)