opentelemetry

Instrumenting Python applications with EDOT SDKs on Kubernetes

This document focuses on instrumenting Python applications on Kubernetes, using the OpenTelemetry Operator, Elastic Distribution of OpenTelemetry (EDOT) Collectors, and the EDOT Python SDK.

Supported environments and configuration

Instrument a Python app with EDOT Python SDK on Kubernetes

In this example, you’ll learn how to:

For this example, we assume the application you’re instrumenting is a deployment named python-app running in the python-ns namespace.

  1. Ensure you have successfully installed the OpenTelemetry Operator, and confirm that the following Instrumentation object exists in the system:
$ kubectl get instrumentation -n opentelemetry-operator-system
NAME                      AGE    ENDPOINT
elastic-instrumentation   107s   http://opentelemetry-kube-stack-daemon-collector.opentelemetry-operator-system.svc.cluster.local:4318

[!NOTE] If your Instrumentation object has a different name or is created in a different namespace, you will have to adapt the annotation value in the next step.

  1. Enable auto-instrumentation of the Python application using one of the following methods:
  1. Restart application:

Once the annotation has been set, restart the application to create new Pods and inject the instrumentation libraries:

```bash
kubectl rollout restart deployment python-app -n python-ns
```
  1. Verify the auto-instrumentation resources are injected in the Pod:

Run a kubectl describe of one of your application pods and check:

Ensure the environment variable OTEL_EXPORTER_OTLP_ENDPOINT points to a valid endpoint and there’s network communication between the Pod and the endpoint.

  1. Confirm data is flowing to Kibana:

Note that the container logs are not provided by the instrumentation library, but by the DaemonSet collector deployed as part of the operator installation.

Troubleshooting