This is a sample application that utilizes OpenTelemetry (OTel) auto-instrumentation to seamlessly collect logs, traces, and metrics, and then send them to a specified endpoint. No code change is required for enabling OpenTelemetry instrumentation.
Make sure Docker is installed on your system. You can use the following commands for installation:
sudo apt update
sudo apt install docker.io
sudo su -
usermod -aG docker ubuntu
Update the Dockerfile with the necessary environment variables for OTel configuration. You can set the endpoint and, if applicable, provide authentication headers.
ENV OTEL_EXPORTER_OTLP_ENDPOINT="https://otel.kloudmate.com:4318"
ENV OTEL_EXPORTER_OTLP_HEADERS="Authorization=<YOUR_SECRET_KEY>"
# If no authentication is required, use the endpoint only
# ENV OTEL_EXPORTER_OTLP_ENDPOINT="https://webhook.site/ddd1f40d-e3f7-4178-93e2-5f35760feaca"
No code change is required within the application for enabling OpenTelemetry.
Build the Docker image and run the container with the following commands:
docker build -t <imageName> .
docker run -p 8080:8080 <imageName>:<tag>
- The application will be accessible on
http://localhost:8080
- RollDice will be accessible on
http://localhost:8080/rolldice
- To pass Player name use queryparameter
?player=<playername>
i.ehttp://localhost:8080/rolldice?player=sanjay