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

Commit 522c144

Browse files
committed
Only add DB tracing on Django 2.0+
1 parent d0b9001 commit 522c144

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

contrib/opencensus-ext-django/opencensus/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 utils
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
@@ -238,7 +239,8 @@ def process_request(self, request):
238239
SPAN_THREAD_LOCAL_KEY,
239240
span)
240241

241-
connection.execute_wrappers.append(self._trace_db_call)
242+
if django.VERSION >= (2,):
243+
connection.execute_wrappers.append(self._trace_db_call)
242244

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

0 commit comments

Comments
 (0)