Amazon X-Ray sample application
The Amazon X-Ray eb-java-scorekeep
See the Scorekeep tutorial to start installing and using an instrumented sample application, using the Amazon Web Services Management Console or the Amazon CLI.
The sample includes a front-end web app, the API that it calls, and the DynamoDB tables that it uses to store
data. Basic instrumentation with filters, plugins, and instrumented Amazon 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:
-
HTTP request filter –
WebConfig.java
-
Amazon SDK client instrumentation –
build.gradle
The xray
branch of the application includes the use of HTTPClient, Annotations, SQL queries, custom subsegments, an instrumented Amazon Lambda function, and instrumented initialization code and scripts.
To support user log-in and Amazon SDK for JavaScript use in the browser, the xray-cognito
branch 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 trace map, and
records additional information, including the URL of the page that the user is viewing, and the
user's ID.
Finally, the xray-worker
branch adds an instrumented Python Lambda function that
runs independently, processing items from an Amazon SQS queue. Scorekeep adds an item to the queue
each time a game ends. The Lambda worker, triggered by CloudWatch Events, pulls items from the queue every
few minutes and processes them to store game records in Amazon S3 for analysis.
Topics
- Getting started with the Scorekeep sample application
- Manually instrumenting Amazon SDK clients
- Creating additional subsegments
- Recording annotations, metadata, and user IDs
- Instrumenting outgoing HTTP calls
- Instrumenting calls to a PostgreSQL database
- Instrumenting Amazon Lambda functions
- Instrumenting startup code
- Instrumenting scripts
- Instrumenting a web app client
- Using instrumented clients in worker threads