In this tutorial, we will walk through how to get started with instrumenting the emojivoto application, a well known microservice example running locally on a Kubernetes cluster.
The following tools are required to run this tutorial:
From the root directory, build the tool as a local docker image called otel-go-instrumentation:
make docker-build
Create a new local Kubernetes cluster, by running the following command:
kind create cluster
Load the docker image into Kind:
kind load docker-image otel-go-instrumentation
The Kubernetes cluster will run the emojivoto applications and a jaeger UI for visualizing the OpenTelemetry traces:
The different emojivoto applications are communicating via gRPC. Instrumenting those applications would allow us to view the gRPC requests between the applications.
Run the following command:
kubectl apply -k emojivoto/
Install Jaeger UI by running:
kubectl apply -f jaeger.yaml -n emojivoto
This command installs Jaeger as a new Deployment and an additional Service that we will use later for accessing the Jaeger UI.
In a real world application, you would probably want to send the tracing data to OpenTelemetry collector instead of directly to Jaeger.
Apply the automatic instrumentation to the emoji, voting, and web applications by executing the following command:
kubectl apply -f emojivoto-instrumented.yaml -n emojivoto
Now all that's left to do is to perform some actions on the target application that will cause the creation of detailed distributed traces.
Port forward to the frontend service:
kubectl port-forward svc/web-svc 8080:80 -n emojivoto
Go to http://localhost:8080, and click the view the leaderboard button.
First, port forward to the Jaeger UI:
kubectl port-forward svc/jaeger 16686:16686 -n emojivoto
Then, open the Jaeger UI in your browser.
After selecting the emojivoto-web service, you should see the following traces:
Let's start with a simple trace, click on one of the /api/vote traces, you should see something like the following:
A few things worth noticing in this trace:
web application got an HTTP request (the root span) which caused two sequential gRPC requests to the emoji and voting services.Now we will view a more complex trace, search for traces for the /api/leaderboard endpoint. You can quickly find them by clicking on the points with the highest duration in Jaeger's main screen. We can get a pretty good understanding of how the leaderboard feature works by looking at this trace:
voting service to get a list of the available emojis.emoji service to get the amount of votes for the current item.Notice that we did not change any application code to get those traces, we are using the exact same containers from the emojivoto project.
Delete the Kubernetes cluster:
kind delete cluster