Pokeshop and Grafana Cloud Tempo
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.
Grafana Tempo is an open-source, high-scale distributed tracing data store. It utilizes object storage to minimize costs, allowing you to store more information at a lower cost. It is deeply integrated with Grafana, Prometheus, and Loki. Grafana Tempo is also available as a paid hosted service at Grafana Cloud.
Grafana Cloud is a managed service offering from Grafana Labs that provides scalable and secure monitoring, visualization, and alerting for metrics, logs, and traces. It integrates seamlessly with various data sources, enabling users to create dynamic, interactive dashboards and gain insights into their system performance and reliability. With features like team collaboration, alerting, and plugins, Grafana Cloud is designed to simplify observability and help teams efficiently monitor their applications and infrastructure.
Pokeshop API is a testing ground, the team at Tracetest has implemented a sample instrumented API around the PokeAPI.
Pokeshop API with Grafana Cloud Tempo, 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 Grafana Cloud Tempo as the trace data store and the Pokeshop API to generate the telemetry data.
Prerequisites​
Tracetest Account:
- Sign up to
app.tracetest.io
or follow the get started docs. - Have access to the environment's agent API key.
Grafana Cloud Account
- Sign up to Grafana Cloud.
- Create tokens for both reading and writing traces by following this guide.
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 Grafana Cloud Tempo Pokeshop Quickstart:
git clone https://github.com/kubeshop/tracetest
cd tracetest/examples/tracetest-grafana-cloud-tempo-pokeshop
Follow these instructions to run the quick start:
- Copy the
.env.template
file to.env
. - Fill out the TRACETEST_TOKEN and ENVIRONMENT_ID details by editing your
.env
file. - Fill out the GRAFANA_AUTH_READ_HASH and GRAFANA_AUTH_WRITE_HASH deatails from your Tempo setup.
- Run
docker compose run tracetest-run
. - Follow the links in the output to view the test results.
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.yaml
file in the root directory of the quick start runs the Pokeshop Demo app, OpenTelemetry Collector, 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.
# Get the required information here: https://app.tracetest.io/retrieve-token
TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>"
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>"
# https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/
GRAFANA_AUTH_READ_HASH="<YOUR_GRAFANA_AUTH_READ_HASH>"
GRAFANA_AUTH_WRITE_HASH="<YOUR_GRAFANA_AUTH_WRITE_HASH>"