This guide covers Python applications running on ECS, EC2, Kubernetes, or any container/VM environment. For AWS Lambda, see the Python Lambda guide.
1. Install the OpenTelemetry SDK
2. Install Instrumentation Libraries
opentelemetry-bootstrap automatically detects your installed packages (Django, FastAPI, Boto3, etc.) and installs the matching instrumentation libraries.
3. Set Environment Variables
Add these environment variables to your service. ReplaceYOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.
| Variable | Value |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | https://app.trace0hq.com/api |
OTEL_EXPORTER_OTLP_HEADERS | X-API-KEY=YOUR_TRACE0_ENV_API_KEY |
OTEL_EXPORTER_OTLP_PROTOCOL | http/protobuf |
OTEL_PYTHON_LOG_CORRELATION | true |
OTEL_PYTHON_LOG_CODE_ATTRIBUTES | true |