This is a demo application that shows how to integrate OpenTelemetry in a Spring Boot application. The application consists of two services: api and product. The api service calls the product service several times requesting some products to return. The application uses Jaeger to visualize the traces.
- Java 17
- Maven
- Docker
- Docker Compose
The project uses two maven modules. To build the application, run the following command in the root directory of the project:
mvn clean package
This will build the application and generate two JAR files in their respective target folders (api-service/target and product-service/target).
To build the Docker image, run the following command in the root directory of the project:
docker build -t oteldemo/api-service api-service
docker build -t oteldemo/product-service product-service
This will build the Docker images for both components.
To run the application with Docker Compose, run the following command in the root directory of the project:
docker-compose up
This will start four containers: both applications, Jaeger and the open-telemetry-collector.
The application can be accessed at http://localhost:8080. Try calling:
curl http://localhost:8080/products
The response should be:
[{"name":"milk","category":"beverages"},{"name":"fruit","category":"food"},{"name":"bread","category":"food"}]
Jaeger can be accessed at http://localhost:16686.
To view traces in Jaeger, follow these steps:
- Open Jaeger at http://localhost:16686.
- Click on the service product-service.
- Click on the Find Traces button.
- Click on a trace to view its details.
You should see something like this: