Django Integration
Auto-instrument Django applications with one pip install. WSGI/ASGI middleware tracing, ORM query spans, Celery task visibility, and DRF support — zero configuration.
How It Works
Install the Package
Run pip install tigerops or add tigerops to your requirements.txt. The package bundles the opentelemetry-instrumentation-django SDK with TigerOps-specific OTLP exporters and a Celery task instrumentation layer.
Add to INSTALLED_APPS & MIDDLEWARE
Add "tigerops.contrib.django" to INSTALLED_APPS and insert "tigerops.contrib.django.middleware.TigerOpsMiddleware" at the top of MIDDLEWARE in settings.py. For ASGI apps the middleware auto-detects the async context.
Set Environment Variables
Set TIGEROPS_API_KEY, TIGEROPS_SERVICE_NAME, and TIGEROPS_ENVIRONMENT in your environment or .env file. The Django app reads these at startup. django-environ and python-decouple are both supported.
Traces, ORM & Celery Flow
Within seconds TigerOps receives Django request spans, ORM query traces with normalized SQL, Celery task execution spans, and cache operation timings from your Django application.
What You Get Out of the Box
WSGI & ASGI Middleware Tracing
The TigerOps middleware creates root spans for every HTTP request with URL pattern, view name, HTTP method, status code, and user authentication state. Works with Gunicorn, uWSGI, Daphne, and Uvicorn.
Django ORM Query Spans
Every database query executed via the Django ORM becomes a child span with normalized SQL, database alias, affected row count, and execution time. Supports PostgreSQL, MySQL, SQLite, and Oracle backends.
Celery Task Visibility
Celery task publish and execution create linked spans. Task name, queue, retry count, execution time, and exception details are captured. Worker concurrency and queue depth are reported as metrics.
Django REST Framework
DRF viewset and serializer spans are auto-instrumented. Serializer validation time, permission check duration, and throttle evaluation are captured as child spans under the request root span.
Cache Instrumentation
Django cache operations (get, set, delete, get_many) are traced as child spans with cache key, backend type, and hit/miss status. Works with Redis, Memcached, and database-backed caches.
Signal & Middleware Timing
Django signal dispatch timing and individual middleware execution times are measured. Long-running signals or slow middleware are flagged in TigerOps with their class name and execution duration.
Install & Initialize
One pip install. Two settings.py lines. Full Django observability.
# Install the TigerOps Django package
pip install tigerops
# Or add to requirements.txt
tigerops>=0.1
# Set environment variables
export TIGEROPS_API_KEY="your-api-key"
export TIGEROPS_SERVICE_NAME="my-django-app"
export TIGEROPS_ENVIRONMENT="production"
# settings.py — add two lines
INSTALLED_APPS = [
"tigerops.contrib.django", # <-- add this
"django.contrib.admin",
# ...
]
MIDDLEWARE = [
"tigerops.contrib.django.middleware.TigerOpsMiddleware", # <-- add at top
"django.middleware.security.SecurityMiddleware",
# ...
]
# Optional: configure tigerops in settings.py
TIGEROPS = {
"API_KEY": env("TIGEROPS_API_KEY"),
"SERVICE_NAME": env("TIGEROPS_SERVICE_NAME", default="django-app"),
"ENVIRONMENT": env("TIGEROPS_ENVIRONMENT", default="production"),
"TRACE_CELERY": True,
"TRACE_CACHE": True,
"SLOW_QUERY_THRESHOLD_MS": 100,
}
# Custom span in a view
from tigerops import span
class OrderView(APIView):
def post(self, request):
with span("order.validate") as s:
s.set_attribute("order.items", len(request.data["items"]))
validated = self.validate_order(request.data)
with span("order.create") as s:
order = Order.objects.create(**validated)
s.set_attribute("order.id", str(order.id))
return Response(OrderSerializer(order).data, status=201)Common Questions
Which Django and Python versions are supported?
Django 3.2, 4.0, 4.1, 4.2, and 5.0 are fully supported. Python 3.9, 3.10, 3.11, and 3.12 are supported. The package works with both sync (WSGI) and async (ASGI) Django deployments.
Does TigerOps affect Django management commands?
By default, TigerOps only instruments HTTP request handling and Celery tasks. Management commands are not traced unless you explicitly wrap them using the TigerOps.span() context manager in your command's handle() method.
How does TigerOps handle database connection pooling with PgBouncer or pgpool?
TigerOps captures query timing at the Django ORM layer, not the TCP connection layer. PgBouncer and pgpool are transparent to the instrumentation. Connection acquisition time is included in the span duration.
Can I use TigerOps with Django Channels (WebSockets)?
Yes. Add tigerops.contrib.channels.TigerOpsChannelMiddleware to your ASGI channel layers configuration. WebSocket connect, disconnect, and message receive events create spans tagged with the channel group name.
Does the middleware capture request and response body content?
No. By default, TigerOps never captures request or response body content. It captures only metadata: URL pattern, HTTP method, status code, and timing. You can add custom attributes via span.set_attribute() in your views.
Full Django Observability in One pip Install
Middleware traces, ORM spans, Celery task visibility, and DRF support — no code changes required.