5.2 Tracing

Tracing in a Microservices Architecture

Tracing

When it comes to large distributed cloud native system with many different components involved, debugging production issues or even finding a way to display how components interact with each other becomes quite hard and tricky.

This is where tracing comes into the picture. Tracing allows us to collect all sorts of requests in a group of requests, which somehow belong together to a single business transaction. In our Quarkus applications, we use Eclipse MicroProfile OpenTracing to collect the tracing data and Jaeger as a component where those traces are sent to and been visualised for further analysis.

Task 5.2.1: Check project setup

We first check that the project is ready for the lab.

Ensure that the LAB_USER environment variable is set.

echo $LAB_USER

If the result is empty, set the LAB_USER environment variable.

command hint
export LAB_USER=<username>

Change to your main Project.

command hint
oc project $LAB_USER

Don’t forget to deploy/update your resources with the git instead of the oc command for this lab.

Task 5.2.2: Deploy Jaeger instance

Then let’s quickly deploy a Jaeger instance.

Create the local file <workspace>/jaeger.yaml with the following content:

apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
  name: jaeger-all-in-one-inmemory

source

Let ArgoCD manage the resources by adding the file to git and push it.

command hint
git add jaeger.yaml && git commit -m "Add Jaeger Manifest" && git push

Wait for ArgoCD to deploy the Jaeger instance or do it manually by applying the file.

command hint
oc apply -f jaeger.yaml

Expected result:

jaeger.jaegertracing.io/jaeger-all-in-one-inmemory created

Verify the deployment

oc get pod -w

The newly deployed Jaeger instance is also available over a route.

oc get route jaeger-all-in-one-inmemory --template={{.spec.host}}
jaeger-all-in-one-inmemory-<username>.techlab.openshift.ch

Use this URL with https protocol to open the Jaeger web console in a Browser window. Use your techlab user credentials to log in. Ensure to allow the proposed permissions.

Task 5.2.3: Send Traces to Jaeger

Now let’s make sure the traces that are collected within our microservices are also been sent to the running Jaeger services.

To achieve that, we need to configure the application by its environment. Update the deployment config (producer.yaml) to use the Jaeger feature:

    spec:
      containers:
        - image: quay.io/puzzle/quarkus-techlab-data-producer:jaegerkafka
          imagePullPolicy: Always
          env:
            - name: PRODUCER_JAEGER_ENABLED
              value: 'true'
          livenessProbe:
            failureThreshold: 5

Update your resources and apply the changes.

command hint
git add . && git commit -m "Enable jaeger feature on producer" && git push

Next we configure the consumer to use the Jaeger feature. To enable Jaeger, open <workspace>/consumerConfigMap.yaml and change the consumer.jaeger.enabled property.

apiVersion: v1
kind: ConfigMap
metadata:
  name: consumer-config
data:
  # Configure the SmallRye Kafka connector
  kafka.bootstrap.servers: 'amm-techlab-kafka-bootstrap:9092'

  #Toggle jaeger trace feature
  consumer.jaeger.enabled: 'true'

  # Configure the Kafka sink
  mp.messaging.incoming.data.connector: smallrye-kafka
  mp.messaging.incoming.data.topic: manual
  mp.messaging.incoming.data.value.deserializer: ch.puzzle.quarkustechlab.reactiveconsumer.control.SensorMeasurementDeserializer

source

Update your resources and apply the changes.

command hint
git add . && git commit -m "Enable jaeger feature on consumer" && git push

After you need to roll out the deployment. This is necessary for reloading the config map.

oc rollout restart deployment data-consumer

And also reconfigure the environment of the data-transformer (<workspace>/data-transformer.yaml) to enable Jaeger by changing the transformer.jaeger.enabled env to true

...
env:
...
- name: transformer.jaeger.enabled
  value: 'true'
command hint
git add . && git commit -m "Enable jaeger feature on transformer" && git push

Task 5.2.4: Explore the Traces

Explore the Traces in the Jaeger Console once again. You should see the data-producer and data-consumer as services.