Technology Stack:
- Python
- OpenTelemetry
We will explore the Kubernetes Sidecar design pattern which deploys an agent sidecar container within an application pod that sends traces to a centralized Grafana Tempo. The application will send tracing data to a collector agent (sidecar) that offloads responsibility by sending the data to a storage backend, in our case, the central Grafana Tempo instance.
Instrumentation is the process of adding observability code to an application. Auto instrumentation creates this tracing framework without significant code changes by automatically injecting and configuring auto-instrumentation libraries in a variety of supported languages. Auto instrumentation of .NET sends data on port 4318 via the OTLP/HTTP protocol.
Inside your workspace is a Python Application that listens at /api/check
for web requests and returns an HTTP 200 or 500 status code based on the payload.
From the Terminal, deploy the Python Application in your project using:
oc new-build --binary --name workshop-<your username>
oc start-build workshop-<your username> --from-dir=.
oc new-app workshop-<your username> --name workshop-<your username>
NOTE: Please keep your application name unique from others in the workshop, otherwise you won’t be able to find your web requests in Jaeger UI.
- Deploy the sidecar with the OpenTelemetryCollector sidecar manifest:
oc apply -f manifests/sidecar.yaml
- Create an Instrumentation manifest in the project that will be used by the OpenTelemetry operator:
oc apply -f manifests/instrumentation.yaml
- Configure your deployment with annotations for .NET auto instrumentation:
oc edit deployment workshop-<your username>
spec:
template:
metadata:
annotations:
..
instrumentation.opentelemetry.io/inject-python: "true"
sidecar.opentelemetry.io/inject: sidecar
-
There is a cronjob at
curl-cron/cronjob.yaml
that will poll the application at service port 5000 every minute.- Modify the environment variable
ENDPOINT
to match the service nameworkshop-<your username>
and deploy it withoc apply -f curl-cron/cronjob.yaml
- Modify the environment variable
-
A centralized Grafana Tempo instance has been deployed for the workshop. In OpenShift web console, navigate to the Applications Menu -> Jaeger UI to view the web requests.
-
The cronjob polling the application returns an HTTP 500. Fix the application so that it returns HTTP 200.
-
(Optional) To generate additional web traffic, without waiting 1 minute for the cronjob to kickoff, we have provided a shell script that will randomly generate 20 HTTP POST requests to your service. To run this in the terminal of your Dev Space, run the following:
sh traffic-generator.sh workshop-<your username>:5000
-
You can create a new build of the application with the following command:
oc start-build workshop-<your username> --from-dir=.
- There is an easter egg in Jaeger
- Explored Kubernetes Sidecar design pattern
- Auto-instrumented application to collect tracing data
- Generated application traffic to produce tracing data
- Used tracing data to troubleshoot application