Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 65567c1

Browse files
committed
Only add DB tracing on Django 2.0+
1 parent 3e2ecff commit 65567c1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

opencensus/trace/ext/django/middleware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from opencensus.trace import tracer as tracer_module
2424
from opencensus.trace.samplers import probability
2525

26+
import django
2627
from django.db import connection
2728
try:
2829
from django.utils.deprecation import MiddlewareMixin
@@ -219,7 +220,8 @@ def process_request(self, request):
219220
SPAN_THREAD_LOCAL_KEY,
220221
span)
221222

222-
connection.execute_wrappers.append(self._trace_db_call)
223+
if django.VERSION >= (2,):
224+
connection.execute_wrappers.append(self._trace_db_call)
223225

224226
except Exception: # pragma: NO COVER
225227
log.error('Failed to trace request', exc_info=True)

0 commit comments

Comments
 (0)