In my spring boot application using Jaeger UI to track the logs.We are using 'bootbuildimage' plugin to build and push the image. due to this not using 'Docker' file and only using 'docker-compose.yml' only.
due to this the following details given in docker file is not executing.
ADD https://github.com/open-telemetry/opentelemetry-java- instrumentation/releases/latest/download/opentelemetry-javaagent.jar . ENV JAVA_TOOL_OPTIONS "-javaagent:./opentelemetry-javaagent.jar"
How to configure opentelemetry-javaagent.jar without using Docker file to trace the logs in Jaeger UI?
docker-compose.yml is given below
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
image : demo-management
container_name: demo-management-service
environment :
- OTEL_SERVICE_NAME=demo-management
- OTEL_TRACES_EXPORTER=jaeger
- OTEL_EXPORTER_JAEGER_ENDPOINT=http://jaeger:14250
- OTEL_METRICS_EXPORTER=none
- OTEL_EXPORTER_JAEGER_TIMEOUT=40000
jaeger:
container_name: jaeger
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14250:14250"
networks:
demo-management-network: {}
Docker file is given below. This is not going to use so need to configure last two lines in another method.
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar .
ENV JAVA_TOOL_OPTIONS "-javaagent:./opentelemetry-javaagent.jar"
Configure following two lines other than Docker file
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar .
ENV JAVA_TOOL_OPTIONS "-javaagent:./opentelemetry-javaagent.jar
Update: I was able to export traces by adding an
entrypointto the docker compose which overrides the imageentrypoint. The docker compose first downloads the agent jar and then runs the app jar.Below is the Dockerfile.
Hope this helps you.