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

pip install opentelemetry-distro 
pip install opentelemetry-exporter-otlp
pip install opentelemetry-instrumentation-system-metrics

2. Install Instrumentation Libraries

opentelemetry-bootstrap -a install
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. Replace YOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.
VariableValue
OTEL_EXPORTER_OTLP_ENDPOINThttps://app.trace0hq.com/api
OTEL_EXPORTER_OTLP_HEADERSX-API-KEY=YOUR_TRACE0_ENV_API_KEY
OTEL_EXPORTER_OTLP_PROTOCOLhttp/protobuf
OTEL_PYTHON_LOG_CORRELATIONtrue
OTEL_PYTHON_LOG_CODE_ATTRIBUTEStrue

4. Deploy Service

Deploy your service and watch traces, metrics, and logs appear in the Trace0 dashboard within seconds.

Example Service

See our Python FastAPI EC2 example app for a working service you can deploy to your AWS account.