Skip to content

Commit 45a5c85

Browse files
docs(django): enabling automatically and manually (#1249)
* docs(django): enabling automatically and manually * Update ddtrace/contrib/django/__init__.py Co-Authored-By: Brett Langdon <[email protected]> Co-authored-by: Brett Langdon <[email protected]>
1 parent 873caf2 commit 45a5c85

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ddtrace/contrib/django/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
and cache calls in a Django application.
44
55
6+
Enable Django tracing automatically via ``ddtrace-run``::
7+
8+
ddtrace-run python manage.py runserver
9+
10+
11+
Django tracing can also be enabled manually::
12+
13+
from ddtrace import patch_all
14+
patch_all()
15+
16+
617
To have Django capture the tracer logs, ensure the ``LOGGING`` variable in
718
``settings.py`` looks similar to::
819
@@ -104,6 +115,9 @@
104115
3. Remove ``TraceMiddleware`` or ``TraceExceptionMiddleware`` if used in
105116
``settings.py``.
106117
118+
3. Enable Django tracing automatically via `ddtrace-run`` or manually by
119+
adding ``ddtrace.patch_all()`` to ``settings.py``.
120+
107121
The mapping from old configuration settings to new ones.
108122
109123
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------+
@@ -191,8 +205,9 @@
191205
tracer.set_tags({'env': 'production'})
192206
193207
import my.custom.tracer
194-
from ddtrace import Pin
208+
from ddtrace import Pin, patch_all
195209
import django
210+
patch_all()
196211
Pin.override(Pin.get_from(django), tracer=my.custom.tracer)
197212
198213
.. __: https://www.djangoproject.com/

0 commit comments

Comments
 (0)