use of com.amazonaws.xray.strategy.IgnoreErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class TracingStatementTest method testCaptureRuntimeExceptionWithoutSegment.
@Test
public void testCaptureRuntimeExceptionWithoutSegment() throws Exception {
ContextMissingStrategy oldStrategy = AWSXRay.getGlobalRecorder().getContextMissingStrategy();
AWSXRay.getGlobalRecorder().setContextMissingStrategy(new IgnoreErrorContextMissingStrategy());
try {
RuntimeException exception = new RuntimeException("foo");
when(delegate.execute(SQL)).thenThrow(exception);
try {
statement.execute(SQL);
fail("Expected exception is not thrown");
} catch (RuntimeException th) {
assertEquals(exception, th);
}
} finally {
AWSXRay.getGlobalRecorder().setContextMissingStrategy(oldStrategy);
}
}
use of com.amazonaws.xray.strategy.IgnoreErrorContextMissingStrategy 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.strategy.IgnoreErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class TracingStatementTest method testCaptureSqlExceptionWithoutSegment.
@Test
public void testCaptureSqlExceptionWithoutSegment() throws Exception {
ContextMissingStrategy oldStrategy = AWSXRay.getGlobalRecorder().getContextMissingStrategy();
AWSXRay.getGlobalRecorder().setContextMissingStrategy(new IgnoreErrorContextMissingStrategy());
try {
SQLException exception = new SQLException("foo");
when(delegate.execute(SQL)).thenThrow(exception);
try {
statement.execute(SQL);
fail("Expected exception is not thrown");
} catch (SQLException th) {
assertEquals(exception, th);
}
} finally {
AWSXRay.getGlobalRecorder().setContextMissingStrategy(oldStrategy);
}
}
use of com.amazonaws.xray.strategy.IgnoreErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testBeginSubsegmentOnEmptyThreadDoesNotThrowExceptionWithIgnoreErrorContextMissingStrategy.
@Test
public void testBeginSubsegmentOnEmptyThreadDoesNotThrowExceptionWithIgnoreErrorContextMissingStrategy() {
AWSXRay.getGlobalRecorder().setContextMissingStrategy(new IgnoreErrorContextMissingStrategy());
AWSXRay.beginSubsegment("test");
}
use of com.amazonaws.xray.strategy.IgnoreErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testBeginSegmentWhenMissingContext.
@Test
public void testBeginSegmentWhenMissingContext() {
AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withSegmentContextResolverChain(new SegmentContextResolverChain()).withContextMissingStrategy(new IgnoreErrorContextMissingStrategy()).build();
Segment segment = recorder.beginSegment("hello");
assertThat(segment).isNotNull();
assertThat(segment.getNamespace()).isEmpty();
// No-op
segment.setNamespace("foo");
assertThat(segment.getNamespace()).isEmpty();
}
Aggregations