Search in sources :

Example 6 with Subsegment

use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.

the class AbstractXRayInterceptor method processXRayTrace.

protected Object processXRayTrace(ProceedingJoinPoint pjp) throws Throwable {
    try {
        Subsegment subsegment = AWSXRay.beginSubsegment(pjp.getSignature().getName());
        subsegment.setMetadata(generateMetadata(pjp, subsegment));
        return XRayInterceptorUtils.conditionalProceed(pjp);
    } catch (Exception e) {
        AWSXRay.getCurrentSegment().addException(e);
        throw e;
    } finally {
        logger.trace("Ending Subsegment");
        AWSXRay.endSubsegment();
    }
}
Also used : Subsegment(com.amazonaws.xray.entities.Subsegment) SegmentNotFoundException(com.amazonaws.xray.exceptions.SegmentNotFoundException)

Example 7 with Subsegment

use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.

the class TracedHttpClient method execute.

@Override
public <T> T execute(final HttpUriRequest request, final ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException {
    Subsegment subsegment = recorder.beginSubsegment(determineTarget(request).getHostName());
    return wrapHttpSupplier(subsegment, () -> {
        if (null != subsegment) {
            TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(request));
        }
        TracedResponseHandler<? extends T> wrappedHandler = new TracedResponseHandler<>(responseHandler);
        T response = wrappedClient.execute(request, wrappedHandler);
        return response;
    });
}
Also used : Subsegment(com.amazonaws.xray.entities.Subsegment)

Example 8 with Subsegment

use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.

the class TracedHttpClient method execute.

@Override
public <T> T execute(final HttpHost target, final HttpRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException {
    Subsegment subsegment = recorder.beginSubsegment(target.getHostName());
    return wrapHttpSupplier(subsegment, () -> {
        if (null != subsegment) {
            TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(target, request));
        }
        TracedResponseHandler<? extends T> wrappedHandler = new TracedResponseHandler<>(responseHandler);
        T response = wrappedClient.execute(target, request, wrappedHandler, context);
        return response;
    });
}
Also used : Subsegment(com.amazonaws.xray.entities.Subsegment)

Example 9 with Subsegment

use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.

the class TracedHttpClient method execute.

@Override
public <T> T execute(final HttpUriRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException {
    Subsegment subsegment = recorder.beginSubsegment(determineTarget(request).getHostName());
    return wrapHttpSupplier(subsegment, () -> {
        if (null != subsegment) {
            TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(request));
        }
        TracedResponseHandler<? extends T> wrappedHandler = new TracedResponseHandler<>(responseHandler);
        T response = wrappedClient.execute(request, wrappedHandler, context);
        return response;
    });
}
Also used : Subsegment(com.amazonaws.xray.entities.Subsegment)

Example 10 with Subsegment

use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.

the class TracedHttpClient method execute.

@Override
public <T> T execute(final HttpHost target, final HttpRequest request, final ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException {
    Subsegment subsegment = recorder.beginSubsegment(target.getHostName());
    return wrapHttpSupplier(subsegment, () -> {
        if (null != subsegment) {
            TracedHttpClient.addRequestInformation(subsegment, request, TracedHttpClient.getUrl(target, request));
        }
        TracedResponseHandler<? extends T> wrappedHandler = new TracedResponseHandler<>(responseHandler);
        T response = wrappedClient.execute(target, request, wrappedHandler);
        return response;
    });
}
Also used : Subsegment(com.amazonaws.xray.entities.Subsegment)

Aggregations

Subsegment (com.amazonaws.xray.entities.Subsegment)27 Segment (com.amazonaws.xray.entities.Segment)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 Test (org.junit.Test)7 TraceHeader (com.amazonaws.xray.entities.TraceHeader)4 Emitter (com.amazonaws.xray.emitters.Emitter)3 UDPEmitter (com.amazonaws.xray.emitters.UDPEmitter)3 Entity (com.amazonaws.xray.entities.Entity)3 FacadeSegment (com.amazonaws.xray.entities.FacadeSegment)3 SubsegmentImpl (com.amazonaws.xray.entities.SubsegmentImpl)3 TraceID (com.amazonaws.xray.entities.TraceID)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 SegmentImpl (com.amazonaws.xray.entities.SegmentImpl)1 SegmentNotFoundException (com.amazonaws.xray.exceptions.SegmentNotFoundException)1 SubsegmentNotFoundException (com.amazonaws.xray.exceptions.SubsegmentNotFoundException)1 Around (org.aspectj.lang.annotation.Around)1