Skip to content

Python

Instrumenting your existing Python application with the OpenTelemetry SDK gives you the flexibility to capture custom metrics, manual spans, and tailored application context.

Install the required OpenTelemetry API, SDK, and exporter packages for Python:

pip install opentelemetry-api \
  opentelemetry-sdk \
  opentelemetry-exporter-otlp

Configure the OpenTelemetry exporter to send data to the KloudMate Agent’s OTLP endpoint. By default, the KloudMate agent listens on port 4318 for HTTP OTLP traffic.

You can set these environment variables before running your instrumented code:

export OTEL_EXPORTER_OTLP_ENDPOINT="http://KM_AGENT_HOST:4318"
export OTEL_SERVICE_NAME="your-python-service"

(Replace KM_AGENT_HOST with the IP address or hostname of your KloudMate Agent).

OpenTelemetry is continuously evolving. For the most up-to-date SDK instructions, advanced configurations, and custom instrumentation details, refer to the official OpenTelemetry documentation:


Looking for a step-by-step tutorial?
Check out our Instrument a Python App guide to see how to instrument simple Flask and Django applications.