This repository contains example code on how to integrate a basic Spring Boot todo application with OpenTelemetry. It also ships with a preconfigured stack of monitoring and tracing applications including:
The code presented here is merely for demonstration purposes, do not use it in production environments.
To get everything running you first need to build the application Docker image and install the Docker Driver Client for Loki.
./gradlew jibDockerBuild
Afterwards you can start the system with
docker-compose up
The service provides a reasonable REST API to manage todos. The following endpoints are available:
GET /api/todos
: Get a list of todos.POST /api/todos
: Create a new todo.GET /api/todos/{id}
: Get todo with the given {id}.PUT /api/todos/{id}
: Update todo with the given {id}.PUT /api/todos/{id}/pending
: Set status of todo with {id} to 'pending'.PUT /api/todos/{id}/in-progress
: Set status of todo with {id} to 'in progress'.PUT /api/todos/{id}/done
: Set status of todo with {id} to 'done'.DELETE /api/todos/{id}
: Delete todo with the given {id}.
You may use HTTPie or a similar tool to make requests. The service API is available at port 8080 of your machine.
After you have made some requests take a look at the logs in Grafana. Select the
preconfigured Loki datasource and filter for the log label {job=example-spring-otel}
. You can then expand a log
message and click on the Tempo
button next to the detected TraceID
field. A new view with all spans belonging to the
same trace will be opened.
You can also lookup a trace ID using Jaeger.
Metrics can be viewed in Prometheus and Grafana .