To run OpenTelemetry (OTEL) collector to send observability data from a Java spring boot app to Grafana stack.
Check Spring Boot app/ directory for more details on the demo app.
There are different ways to collect observability data out of your java applicaion. Refer : https://opentelemetry.io/docs/languages/java/#repositories
We are using the https://github.com/open-telemetry/opentelemetry-java-instrumentation java agent method.
First, download the OpenTelemetry Java agent:
## get latest when possible (test it first, ofcourse)
cd examples/java/spring-boot/etc/
wget -q -O ./opentelemetry-javaagent.jar https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.4.0/opentelemetry-javaagent.jar
# Pre-req: you need to have `sdk`: https://sdkman.io/install.
# Again this is upto you. If you have the correct java runtime already, feel free to move to the build part.
sdk use java 17.0.9-tem # to select correct java runtime
## Build the jar using gradle. You can use maven if you want, then the path to the jar needs to be updated in the Dockerfile
./gradlew bootJar
Next, run the Docker Compose file with the following commands:
docker compose up --remove-orphans
Loki: See Logs
Tempo: See Traces
Prometheus: See Metrics
docker-compose down --remove-orphans
docker volume rm otel_grafana-storage otel_loki-storage otel_mimir-storage otel_minio-data otel_prometheus-data otel_tempo-storage