Django
The example below is using the Python guide for OpenTelemetry (opens in a new tab).
Libraries
First, install the required dependencies.
>_ Terminal
pip install opentelemetry-distro opentelemetry-exporter-otlp
Instrumentation
Method: Agent
Add auto instrumentation and bootstrap your service.
>_ Terminal
opentelemetry-bootstrap -a install
Run the agent
>_ Terminal
opentelemetry-instrument \
--service_name your-service-name \
python main.py # replace with your run command
Required configuration
The following environment variables are always required.
.env
OTEL_EXPORTER_OTLP_ENDPOINT="https://collect.smallhours.dev/"
OTEL_EXPORTER_OTLP_HEADERS="small-hours-api-key=YOUR_API_KEY,small-hours-service-id=YOUR_SERVICE_ID"