Automatically configures OpenTelemetry auto-instrumentation for your application pods.
When you link an external_source_code or image_base component to an OTEL component, Stacktic automatically:
| Attribute | Required | Description |
|---|---|---|
| otel_language | Yes | Language for auto-instrumentation: java, python, nodejs, dotnet, go |
| pythonpath | For Python | Required for Python apps. The working directory of your app (e.g., /usr/src/app) |
| otel_language_custom | No | Custom annotation key (overrides default instrumentation.opentelemetry.io/inject-{language}) |
metadata:
annotations:
instrumentation.opentelemetry.io/inject-python: "otel/otel-instrumentation"
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector-collector.otel.svc.cluster.local:4318 OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector-collector.otel.svc.cluster.local:4318/v1/traces OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://otel-collector-collector.otel.svc.cluster.local:4318/v1/metrics OTEL_SERVICE_NAME=my-app PYTHONPATH=/usr/src/app # Only for Python
containers:
- name: app
env:
- name: PYTHONPATH
value: "/usr/src/app"
envFrom:
- secretRef:
name: my-app-external-source-secrets
The OTEL operator's Python auto-instrumentation has a known issue (GitHub #2495):
sitecustomize.py runs before your app startssys.pathglobal_settings which has DEBUG=FalseCommandError: You must set settings.ALLOWED_HOSTS if DEBUG is Falsepythonpath attribute to your app's working directory (must match Dockerfile WORKDIR)
The OTEL operator init container behavior:
That's why Stacktic generates PYTHONPATH in both places:
cloud.env (secret) - For non-OTEL scenariossource_code.yaml (deployment env:) - For OTEL to work correctly| otel_language | Annotation | Extra Config |
|---|---|---|
| java | instrumentation.opentelemetry.io/inject-java | None |
| python | instrumentation.opentelemetry.io/inject-python | Requires pythonpath attribute |
| nodejs | instrumentation.opentelemetry.io/inject-nodejs | None |
| dotnet | instrumentation.opentelemetry.io/inject-dotnet | None |
| go | instrumentation.opentelemetry.io/inject-go | None |
Link: django -> otel Attributes: otel_language: "python" pythonpath: "/usr/src/app"
Link: backend -> otel Attributes: otel_language: "java"
Link: api -> otel Attributes: otel_language: "nodejs"
Check your Dockerfile for the WORKDIR directive:
# Dockerfile FROM python:3.12-slim WORKDIR /usr/src/app # <-- This is your pythonpath COPY . . CMD ["python", "manage.py", "runserver"]
Common values:
/usr/src/app - Django default/app - Generic Python apps/code - Some Docker Compose setupsTroubleshooting