Skip to main content

Pokeshop API with AWS X-Ray (Node.js SDK) and AWS Distro for OpenTelemetry

Tracetest is a testing tool based on OpenTelemetry that allows you to test your distributed application. It allows you to use data from distributed traces generated by OpenTelemetry to validate and assert if your application has the desired behavior defined by your test definitions.

AWS X-Ray provides a complete view of requests as they travel through your application and filters visual data across payloads, functions, traces, services, APIs, and more with no-code and low-code motions.

AWS Distro for OpenTelemetry (ADOT) is a secure, production-ready, AWS-supported distribution of the OpenTelemetry project. Part of the Cloud Native Computing Foundation, OpenTelemetry provides open source APIs, libraries, and agents to collect distributed traces and metrics for application monitoring.

Pokeshop API As a testing ground, the team at Tracetest has implemented a sample instrumented API around the PokeAPI.

Pokeshop API Demo with AWS X-Ray (Node.js SDK), AWS Distro for OpenTelemetry and Tracetest

This is a simple quick start guide on how to configure a fully instrumented API to be used with Tracetest for enhancing your E2E and integration tests with trace-based testing. The infrastructure will use AWS X-Ray as the trace data store, the ADOT as a middleware and the Pokeshop API to generate the telemetry data.


Tracetest Account:

AWS Account:

Docker: Have Docker and Docker Compose installed on your machine.

Run This Quckstart Example

The example below is provided as part of the Tracetest project. You can download and run the example by following these steps:

Clone the Tracetest project and go to the AWS X-Ray Pokeshop Quickstart:

git clone
cd tracetest/examples/tracetest-amazon-x-ray-pokeshop

Follow these instructions to run the quick start:

  1. Copy the .env.template file to .env.
  2. Log into the Tracetest app.
  3. Fill out the token and API key details by editing your .env file. You can find these values in the Settings area for your environment.
  4. Fill out the AWS credentials in the .env file. You can create credentials by following this guide.
  5. Run docker compose -f ./docker-compose.agent.yaml up -d.
  6. This example is configured to use the AWS X-Ray Tracing Backend. Ensure the environment you're using to run this example is configured to use the AWS X-Ray Tracing Backend by clicking on Settings, Tracing Backend, AWS X-Ray, Save. Or, use the CLI as explained below.
  7. Run tests from the Tracetest Web UI by accessing the app with the URL http://demo-api:8081/pokemon/import.

Follow along with the sections below for an in detail breakdown of what the example you just ran did and how it works.

Project Structure

The project contains the Tracetest Agent, and the Pokeshop Demo app.

The docker-compose.agent.yaml file in the root directory of the quick start runs the Pokeshop Demo app, AWS Distro for OpenTelemetry (ADOT), and the Tracetest Agent setup.

Configuring the Pokeshop Demo App

The Pokeshop API is a fully instrumented REST API that makes use of different services to mimic a real life scenario.

It is instrumented using the OpenTelemetry standards for Node.js, sending the data to the ADOT collector that will be pushing the telemetry information to both the AWS X-Ray service.

This is a fragment from the main tracing file from the Pokeshop API repo.

Configure the .env like shown below.


Configuring AWS X-Ray

Configure AWS X-Ray as a Tracing Backend in Tracetest.

Get temporary credentials.

aws sts get-session-token
"Credentials": {
"AccessKeyId": "<yourkeyid>",
"SecretAccessKey": "<youraccesskey>",
"SessionToken": "<yoursessiontoken>",
"Expiration": "2024-05-23T21:01:38+00:00"

Edit the tracetest-tracing-backend.yaml.

type: DataStore
name: awsxray
type: awsxray
accessKeyId: <your-accessKeyId>
secretAccessKey: <your-secretAccessKey>
sessionToken: <your-session-token>
region: "<your-region>"
tracetest config -t <YOUR_API_TOKEN>
tracetest apply datastore -f ./tracetest-tracing-backend.yaml

Run the Pokeshop Demo App, ADOT, and Tracetest Agent with Docker Compose

The docker-compose.agent.yaml file in the root directory contains the Pokeshop Demo app services.

The docker-compose.agent.yaml file also contains the Tracetest Agent and ADOT.

To start it, run this command:

docker compose -f ./docker-compose.agent.yaml up -d

This will start the Pokeshop Demo app, ADOT, and Tracetest Agent.

Run Tracetest Tests

  1. Open Tracetest.
  2. Configure AWS X-Ray as a tracing backend if you have not already as explained above.
  3. Start creating tests! Make sure to use the http://demo-api:8081/pokemon/import URL in your test creation.
  4. To trigger tests in the CLI, first install the CLI, configure it, and run a test. From the root of the quick start directory, run:
tracetest configure -t <YOUR_API_TOKEN>
tracetest run test -f ./tests/test.yaml

Learn More

Please visit our examples in GitHub and join our Slack Community for more info!