Adding OpenTelemetry tracing to a Django app (and finding an N+1 in SigNoz)
When a Django page is slow, logs tell you that it was slow. A trace tells you where : which view, which SQL query, which outbound call. OpenTelemetry (OTel) gives you traces in a vendor-neutral format, and the Python agent can instrument Django and PostgreSQL without you editing your views.
In this guide you will:
Trace a small Django + PostgreSQL app with no code changes.
Add one custom span with useful attributes.
Spot an N+1 query in a trace, fix it, and compare.
Run it under Gunicorn, correlate logs with traces, and cut noise with sampling.
Send everything to SigNoz , an OpenTelemetry-native backend.
Everything below was run against a throwaway project: Python 3.13, Django 6.1, opentelemetry-sdk 1.45.2 with instrumentation packages 0.66b2, Gunicorn 27, psycopg2-binary 2.9.13 and a local PostgreSQL.…