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();
}
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testBeginSubsegmentWhenMissingContext.
@Test
public void testBeginSubsegmentWhenMissingContext() {
AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withContextMissingStrategy(new IgnoreErrorContextMissingStrategy()).build();
Subsegment subsegment = recorder.beginSubsegment("hello");
assertThat(subsegment).isNotNull();
assertThat(subsegment.getNamespace()).isEmpty();
// No-op
subsegment.setNamespace("foo");
assertThat(subsegment.getNamespace()).isEmpty();
assertThat(subsegment.shouldPropagate()).isFalse();
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class EntityTest method testInProgressSubsegment.
@Test
public void testInProgressSubsegment() throws JSONException {
Segment parent = AWSXRay.beginSegment("test");
Subsegment subsegment = AWSXRay.beginSubsegment("test");
subsegment.setStartTime(1.0);
String expected = expectedInProgressSubsegment(parent.getTraceId(), parent.getId(), subsegment.getId(), subsegment.getStartTime()).toString();
JSONAssert.assertEquals(expected, subsegment.streamSerialize(), JSONCompareMode.NON_EXTENSIBLE);
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class EntityTest method testSegmentWithSubsegment.
@Test
public void testSegmentWithSubsegment() throws JSONException {
TraceID traceId = new TraceID();
Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", traceId);
Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
segment.addSubsegment(subsegment);
segment.setStartTime(1.0);
subsegment.setStartTime(1.0);
subsegment.end();
segment.end();
String expected = expectedCompletedSegmentWithSubsegment(traceId, segment.getId(), subsegment.getId(), 1.0, subsegment.getEndTime(), segment.getEndTime()).toString();
JSONAssert.assertEquals(expected, segment.serialize(), JSONCompareMode.NON_EXTENSIBLE);
}
use of com.amazonaws.xray.entities.Subsegment in project aws-xray-sdk-java by aws.
the class EntityTest method testManuallySetEntityEndTime.
@Test
public void testManuallySetEntityEndTime() {
Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", new TraceID());
Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
segment.addSubsegment(subsegment);
double endTime = 20.0d;
segment.setStartTime(1.0);
subsegment.setStartTime(1.0);
segment.setEndTime(endTime);
subsegment.setEndTime(endTime);
subsegment.end();
segment.end();
Assert.assertEquals(endTime, segment.getEndTime(), 0);
Assert.assertEquals(endTime, subsegment.getEndTime(), 0);
}
Aggregations