A demo project showing how to add distributed tracing to a Java/Spring Boot API using the OpenTelemetry Java agent — no changes to application source code required.
React Frontend (port 80)
↓
Spring Boot API (port 8080)
↓ OTLP/HTTP :4318
OTel Collector (ports 4317, 4318)
↓ OTLP/gRPC :4317
Jaeger (port 16686)
| Service | Description |
|---|---|
obi-test-app |
React + TypeScript frontend |
obi-test-api |
Spring Boot 3 REST API |
otel-collector |
OpenTelemetry Collector — receives and forwards telemetry |
jaeger |
Trace storage and UI |
docker compose up --build| URL | Description |
|---|---|
| http://localhost | React frontend |
| http://localhost:8080 | Spring Boot API |
| http://localhost:16686 | Jaeger UI |
Hit any API endpoint to produce traces, then search for obi-test-api in the Jaeger service dropdown.
Successful requests:
curl http://localhost:8080/users
curl http://localhost:8080/posts
curl http://localhost:8080/posts/1Error scenario (triggers a NoSuchElementException, visible as a red span in Jaeger):
curl http://localhost:8080/posts/999The OTel Java agent JAR is downloaded at Docker build time and attached to the JVM via -javaagent. No code changes are needed in the Spring Boot application — the agent instruments HTTP requests, responses, and exceptions automatically.
The agent is configured entirely through environment variables in docker-compose.yml:
OTEL_SERVICE_NAME=obi-test-api
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318