A Kubernetes init container (Docker image only — no Python package) that injects Python auto-instrumentation into application pods. It copies the instrumentation packages into a shared volume that the app pod mounts onto its PYTHONPATH, so the app is instrumented with zero code change.
| File | Role |
|---|---|
Dockerfile |
builds the init-container image; installs the matching locks/ file, runs setup-instrumentation.py |
setup-instrumentation.py |
copies packages from /instrumentations/{INSTRUMENTATION_PROVIDER} → shared volume /otel-tracing-sdk, incl. sitecustomize.py |
sitecustomize.py |
minimal bootstrap auto-imported by the app's Python: sets Traceloop env vars and calls Traceloop.init() |
Makefile |
build / load image; make lock (regenerate locks) / make check-locks (hermetic verify) |
requirements.in |
loose dependency inputs (extras beyond traceloop-sdk); compiled into locks/ |
locks/traceloop-<T>-python<X.Y>.txt |
fully-pinned dependency tree per (traceloop × python); the image installs these |
scripts/gen-locks.sh |
regenerates locks/ (re-resolves live PyPI in python:<X.Y>-slim) |
scripts/check-locks.sh |
hermetic CI check that committed locks cover the release-config matrix |
RELEASING.md |
release runbook |
- Init container runs
setup-instrumentation.py, which copies the provider's packages +sitecustomize.pyinto anemptyDirvolume at/otel-tracing-sdk/. - The app pod mounts the same volume and puts it on
PYTHONPATH. - Python auto-imports
sitecustomize.pyat startup →Traceloop.init(telemetry_enabled=False, api_endpoint=AMP_OTEL_ENDPOINT, headers={...}).
sitecustomize.py reads AMP_OTEL_ENDPOINT + AMP_AGENT_API_KEY; it also sets TRACELOOP_TRACE_CONTENT (default true), TRACELOOP_METRICS_ENABLED=false, and OTEL_EXPORTER_OTLP_INSECURE=true.
make build # docker build (PYTHON_VERSION, TRACELOOP_VERSION args) → ghcr.io/wso2/amp-python-instrumentation-provider:TAG
make docker-load-k3d # build + load into k3d (K3D_CLUSTER_NAME=openchoreo-local-setup)
make helpBuild args: PYTHON_VERSION (default 3.11), TRACELOOP_VERSION (default 0.60.0). Default TAG=dev-python3.11.
sitecustomize.pymust land at the root of/otel-tracing-sdk/for Python to auto-import it.OTEL_EXPORTER_OTLP_INSECURE=trueis hard-coded (no TLS validation) — expected for in-cluster export.- Fail-open by design (diverges from the library contract). This
sitecustomize.pywraps its entire body intry/except Exceptionand only logs (logger.exception) — it never re-raises. So ifAMP_OTEL_ENDPOINT/AMP_AGENT_API_KEYare missing (it raises aValueError), or Traceloop import/init fails, instrumentation is silently skipped and the host app keeps running. This is intentional: an init container must not crash the app it instruments. Note this differs from../libs/amp-instrumentation/AGENTS.md, whereinitialize_instrumentation()raisesConfigurationError/ImportErroron missing required vars. If you change this file, preserve the swallow-and-log behavior unless you deliberately want startup to hard-fail. - No tests — it's a build/copy script.
Ships the package documented in ../libs/amp-instrumentation/AGENTS.md.