use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class TracedResponseHandler method handleResponse.
@Override
public T handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
T handled = wrappedHandler.handleResponse(response);
Subsegment currentSubsegment = AWSXRay.getCurrentSubsegment();
if (null != currentSubsegment) {
TracedResponseHandler.addResponseInformation(currentSubsegment, response);
}
return handled;
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class TracedHttpClientTest method normalPropagation.
@Test
public void normalPropagation() throws Exception {
stubFor(any(anyUrl()).willReturn(ok()));
TraceID traceID = TraceID.fromString("1-67891233-abcdef012345678912345678");
Segment segment = AWSXRay.beginSegment("test", traceID, null);
client.execute(new HttpGet(server.baseUrl())).close();
AWSXRay.endSegment();
Subsegment subsegment = segment.getSubsegments().get(0);
verify(getRequestedFor(urlPathEqualTo("/")).withHeader(TraceHeader.HEADER_KEY, equalTo("Root=1-67891233-abcdef012345678912345678;Parent=" + subsegment.getId() + ";Sampled=1")));
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class DefaultHttpClient method execute.
@Override
public CloseableHttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
Subsegment subsegment = getRecorder().beginSubsegment(target.getHostName());
try {
TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(target, request));
CloseableHttpResponse response = super.execute(target, request, context);
TracedResponseHandler.addResponseInformation(subsegment, response);
return response;
} catch (Exception e) {
subsegment.addException(e);
throw e;
} finally {
getRecorder().endSubsegment();
}
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class DefaultHttpClient method execute.
@Override
public CloseableHttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException {
Subsegment subsegment = getRecorder().beginSubsegment(target.getHostName());
try {
TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(target, request));
CloseableHttpResponse response = super.execute(target, request);
TracedResponseHandler.addResponseInformation(subsegment, response);
return response;
} catch (Exception e) {
subsegment.addException(e);
throw e;
} finally {
getRecorder().endSubsegment();
}
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class DefaultHttpClient method execute.
@Override
public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException {
Subsegment subsegment = getRecorder().beginSubsegment(TracedHttpClient.determineTarget(request).getHostName());
try {
TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(request));
CloseableHttpResponse response = super.execute(request, context);
TracedResponseHandler.addResponseInformation(subsegment, response);
return response;
} catch (Exception e) {
subsegment.addException(e);
throw e;
} finally {
getRecorder().endSubsegment();
}
}
Aggregations