The aim of this project is to demonstrate the use of tracing opentelemetry with Java and Spring Boot.
The opentelemetry project is an attempt to unify a complex, vendor-specific multitude of SDKs, agents and configuration procedures, thereby allowing to make projects vendor-specific and independent from their specific SDKs.
A change of vendor will therefore not have any impact on the code base, just on configuration.
This project only covers the distributed tracing for a very simple architecture (one service + mongoDB), using (to my knowledge) the state of the art and prioritising the use of OTLP over vendor-specific protocols, in order to achieve maximum vendor independence.
Collection of logs and metrics is out of scope.
This project implements this kind of deployment, as described here
A few clarifications:
- the
Application
is a dummy Spring Boot REST API - instead of using the
OpenTelemetry SDK
, I opted for letting theopentelemetry-javaagent
attach to the JVM and collect traces (Zero-code instrumentation). Code-based instrumentation is also possible - the
OpenTelemtry Collector
is deployed via docker, seecompose.yml
, and is configured incollector-config.yml
to receive and export data viaOTLP
(OpenTelemetry Protocol) - the
Backend
is Jaeger, but any tool to visualize distributed traces will do. I chose Jaeger because it's opensource, easy to get up&running and supports OTLP. It can be further integrated into a full observability solution thanks to Grafana (out of scope)
Assuming you have docker and docker-compose installed, you have to:
- start the dependencies via compose, for example by opening a shell into the project directory and entering
docker compose up -d
and wait for them to be up&running - start the service by executing
./run.sh
(tested on Linux).
Should you use a different shell, you'll have to create your own run script by taking the commands found in run.sh
.
Send a request to the REST API via curl localhost:8080/persons
.
Open the Jaeger web UI at localhost:16686
and you should see a new trace.
For any feedback or appreciation, feel free to reach out via the Issues section or Star this repo 🙏.
I'm also on LinkedIn.