use of com.amazonaws.xray.strategy.LogErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testBeginSubsegmentOnEmptyThreadDoesNotThrowExceptionWithLogErrorContextMissingStrategy.
@Test
public void testBeginSubsegmentOnEmptyThreadDoesNotThrowExceptionWithLogErrorContextMissingStrategy() {
AWSXRay.getGlobalRecorder().setContextMissingStrategy(new LogErrorContextMissingStrategy());
AWSXRay.beginSubsegment("test");
}
use of com.amazonaws.xray.strategy.LogErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class LambdaSegmentContextTest method testEndSubsegmentUsesContextMissing.
@Test
@SetEnvironmentVariable(key = "_X_AMZN_TRACE_ID", value = TRACE_HEADER)
void testEndSubsegmentUsesContextMissing() {
AWSXRay.getGlobalRecorder().setContextMissingStrategy(new LogErrorContextMissingStrategy());
// No exception
AWSXRay.endSubsegment();
AWSXRay.getGlobalRecorder().setContextMissingStrategy(new RuntimeErrorContextMissingStrategy());
assertThatThrownBy(AWSXRay::endSubsegment).isInstanceOf(SubsegmentNotFoundException.class);
}
use of com.amazonaws.xray.strategy.LogErrorContextMissingStrategy in project aws-xray-sdk-java by aws.
the class TracingHandlerTest method testRaceConditionOnRecorderInitialization.
@Test
void testRaceConditionOnRecorderInitialization() {
AWSXRay.setGlobalRecorder(null);
// TracingHandler will not have the initialized recorder
AWSLambda lambda = AWSLambdaClientBuilder.standard().withRequestHandlers(new TracingHandler()).withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))).build();
mockHttpClient(lambda, "null");
// Now init the global recorder
AWSXRayRecorder recorder = AWSXRayRecorderBuilder.defaultRecorder();
recorder.setContextMissingStrategy(new LogErrorContextMissingStrategy());
AWSXRay.setGlobalRecorder(recorder);
// Test logic
InvokeRequest request = new InvokeRequest();
request.setFunctionName("testFunctionName");
lambda.invoke(request);
}
Aggregations