OpenTelemetry
In order to make a system observable, it must be instrumented. Language specific implementation of OpenTelemetry provides a way to instrument your application without touching your source code. In this lab we're going to instrument a Java application.
Prerequisites
Make sure the following Apps are enabled:
Tempo
on PlatformOtel
on PlatformLoki
on PlatformGrafana
for the Team
Enable tracing for Istio
and ingress-nginx-platform
:
-
Go to
Apps
. -
Click on
Istio
. -
Click on the configuration icon.
-
Click on the
Values
tab. -
In the values click
Edit
and set the following values:
tracing:
enabled: true
samplingRatio: "100"
Setting the
samplingRatio
to100
is only done for this lab to make sure all traces are sampled. In a production environment the ratio would normally be set to0.01
.
-
Click
Submit
. -
Repeat step 2 to 6 for the
ingress-nginx-platform
app.
Build an image from source code
For this lab we're going to use the Spring PetClinic Sample Application. Follow these steps to build an image from source code:
Using a Gitea repository is not required. You can also build using public repositories.
Create the code repository
-
Create a new repo called
petclinic
in theteam-labs
Gitea organization. -
Clone the Spring PetClinic Sample Application:
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
- Mirror the Spring PetClinic Sample Application to the
petclinc
repo:
git push --mirror https://gitea.<your-domain>/<team-name>/petclinic.git
Add the code repository
-
In the left menu in the Console, click on
Code Repositories
. -
Click on
ADD CODE REPOSITORY
. -
Provide a name for this code repository. The name will be used to identify the code repository in App Platform. You can only use the name once within a Team. We are going to use the name
petclinic
for this code repository. -
Select
Gitea
for the Git service (default) -
Select
petclinic
from theRepository
drop-down list: -
Click
Add Code repository
Create the container image
-
In the left menu of the Console, click on
Container Images
. -
Click on
CREATE CONTAINER IMAGE
. -
Select the
BuildPacks
build task. -
Select the
petclinic
repository from the Repository drop-down list. -
Select the Reference
main
. -
Optionally you can change the Image name and tag. This is the name and tag used to store the image in the private Harbor image registry.
-
Click
Create Container Image
.
Create a workload from the developer catalog
-
Go to Container Images in the left menu and click on the
Add to clipboard
of thepetclinc
image in the Repository column. Remember that the tag is main. -
Go to
Workloads
in the left menu and click onCreate Workload
. -
Select
Quickstart-K8s-Deployment-Otel
from the catalog. -
Add the Name
petclinic
for the workload. -
Leave the
Auto image updater
toDisabled
. -
In the workload
values
, change the following parameters:image: repository: <paste from clipboard> tag: main
Because we're deploying a Java application here, maybe also change the resources:
resources: limits: cpu: 500m memory: 1Gi requests: cpu: 300m memory: 256Mi
-
Click
Submit
.
Expose the service
-
In the left menu click
Services
then click onCREATE SERVICE
. -
Select the
petclinic
service from theService Name
drop-down list: -
Click
Create Service
.
See traces
To be able to see traces, we'll first need to generate some requests. Click on the URL of the petclinic
service and generate some requests.
To see traces, you'll first need to find a TraceID
of a trace. Go to Apps
in the left menu and then click op Loki
. Select the label App
and select value petclinic
.
Click on a log entry of a request. Note that the requests are logged by the Istio Envoy proxy. You will now see a link to the full trace in Grafana Tempo. Click on it.
If you don't see any traces, then check and see if the pod runs the
ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:1.26.0
container. Sometimes the pod starts before theInstrumentation
resource has been created. If this is the case, restart the Pod.
And when you click on the Node graph, you’ll see the complete flow:
Updated 4 days ago