Python Monitoring
Python monitoring
for Django, Flask and FastAPI.
Find the slow view, the N+1 query or the stuck Celery task. The OpenTelemetry distro detects the libraries you already import and instruments them, so you run your app under one wrapper command and traces start flowing.
What you see
Traces, metrics and logs from Python
opentelemetry-instrument wraps your start command and patches supported libraries as they load.
Distributed traces
Views, tasks, HTTP clients and database calls as spans, linked across services.
Metrics
Request latency and throughput per endpoint, plus anything you record with the metrics API.
Correlated logs
Standard library logging picks up trace context, so logs and traces line up.
Frameworks and libraries
Each of these has official OpenTelemetry instrumentation. aiAxonIQ receives it over OTLP, so anything the OpenTelemetry project adds for Python works here too.
- Django
- Flask
- FastAPI
- Starlette
- Celery
- requests
- httpx
- SQLAlchemy
- psycopg
- PyMySQL
- Redis
- gRPC
Set up
Send Python telemetry in three steps
The full guide, including sampling and resource attributes, is in the documentation.
1Install
pip install opentelemetry-distro opentelemetry-exporter-otlp opentelemetry-bootstrap -a installopentelemetry-bootstrap inspects what you already import and installs instrumentation only for those libraries, so the list stays in step with your dependencies rather than with a snapshot of them.
2Configure
export OTEL_EXPORTER_OTLP_ENDPOINT="https://app.aiaxoniq.com/otlp" export OTEL_EXPORTER_OTLP_HEADERS="x-license-key=YOUR_LICENSE_KEY" export OTEL_SERVICE_NAME="my-service"3Run
opentelemetry-instrument python your_app.py
How the data flows
- 1. Instrument. The OpenTelemetry SDK for Python records spans, metrics and logs in your process.
- 2. Export. It sends them over OTLP, straight to aiAxonIQ or through an OpenTelemetry Collector you already run.
- 3. Explore. Traces, metrics and logs land in one store, so a slow request opens onto its queries and its log lines.
Because the wire format is OTLP, the same instrumentation works with any OpenTelemetry backend. Moving to aiAxonIQ, or away from it, is an endpoint change.
Python questions
- Does it work behind Gunicorn or uWSGI?
- Yes, with one rule from the OpenTelemetry docs: pre-fork servers should initialise the SDK in each worker after it forks, for example in Gunicorn's post_fork hook, because exporter threads do not survive a fork.
- Can I add my own spans?
- Yes. Get a tracer from opentelemetry.trace and wrap any block in a span; it nests inside the automatic request span.