Manually instrumenting Amazon SDK clients - Amazon X-Ray
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Manually instrumenting Amazon SDK clients

The X-Ray SDK for Java automatically instruments all Amazon SDK clients when you include the Amazon SDK Instrumentor submodule in your build dependencies.

You can disable automatic client instrumentation by removing the Instrumentor submodule. This enables you to instrument some clients manually while ignoring others, or use different tracing handlers on different clients.

To illustrate support for instrumenting specific Amazon SDK clients, the application passes a tracing handler to AmazonDynamoDBClientBuilder as a request handler in the user, game, and session model. This code change tells the SDK to instrument all calls to DynamoDB using those clients.

Example src/main/java/scorekeep/SessionModel.java – Manual Amazon SDK client instrumentation

import com.amazonaws.xray.AWSXRay; import com.amazonaws.xray.handlers.TracingHandler; public class SessionModel { private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard() .withRegion(Constants.REGION) .withRequestHandlers(new TracingHandler(AWSXRay.getGlobalRecorder())) .build(); private DynamoDBMapper mapper = new DynamoDBMapper(client);

If you remove the Amazon SDK Instrumentor submodule from project dependencies, only the manually instrumented Amazon SDK clients appear in the service map.