Developer Guide

AWS X-Ray Sample Application

The AWS X-Ray eb-java-scorekeep sample app, available on GitHub, shows the use of the AWS X-Ray SDK to instrument incoming HTTP calls, DynamoDB SDK clients, and HTTP clients. The sample app uses AWS Elastic Beanstalk features to create DynamoDB tables, compile Java code on instance, and run the X-Ray daemon without any additional configuration.

      Scorekeep uses the AWS X-Ray SDK to instrument incoming HTTP calls, DynamoDB SDK
        clients, and HTTP clients

The sample is an instrumented version of the Scorekeep project on AWSLabs. It includes a front-end web app, the API that it calls, and the DynamoDB tables that it uses to store data. All the components are hosted in an Elastic Beanstalk environment for portability and ease of deployment.

Basic instrumentation with filters, plugins, and instrumented AWS SDK clients is shown in the project's xray-gettingstarted branch. This is the branch that you deploy in the getting started tutorial. Because this branch only includes the basics, you can diff it against the master branch to quickly understand the basics.

The sample application shows basic instrumentation in these files:

The xray branch of the application adds the use of HTTPClient, Annotations, SQL queries, custom subsegments, an instrumented AWS Lambda function, and instrumented initialization code and scripts. This service map shows the xray branch running without a connected SQL database:

A third branch, xray-cognito, adds Amazon Cognito to support user authentication and authorization. With credentials retrieved from Amazon Cognito, the web app also sends trace data to X-Ray to record request information from the client's point of view. The browser client appears as its own node on the service map, and records additional information, including the URL of the page that the user is viewing, and the user's ID.

With all features enabled, Scorekeep's service map looks like this:

For instructions on using the sample application with X-Ray, see the getting started tutorial. In addition to the basic use of the X-Ray SDK for Java discussed in the tutorial, the sample also shows how to use the following features.