Skip to content

Commit 3cd7278

Browse files
author
Emanuele Palazzetti
committed
[django] improve docs
1 parent 80db5ee commit 3cd7278

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

ddtrace/contrib/django/__init__.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
11
"""
2-
The Django middleware will trace requests, database calls and template
2+
The Django integration will trace requests, database calls and template
33
renders.
44
55
To install the Django tracing middleware, add it to the list of your
6-
application's installed in middleware in settings.py::
6+
installed apps and in your middleware classes in ``settings.py``::
77
8+
INSTALLED_APPS = [
9+
# ...
10+
11+
# the order is not important
12+
'ddtrace.contrib.django',
13+
]
814
915
MIDDLEWARE_CLASSES = (
10-
...
16+
# the tracer must be the first middleware
1117
'ddtrace.contrib.django.TraceMiddleware',
1218
...
1319
)
1420
15-
DATADOG_SERVICE = 'my-app'
21+
The configuration of this integration is all namespaced inside a single
22+
Django setting, named ``DATADOG_APM``. For example, your ``settings.py``
23+
may contain::
24+
25+
DATADOG_APM = {
26+
'DEFAULT_SERVICE': 'my-django-app',
27+
}
28+
29+
If you need to access to the tracing settings, you should::
30+
31+
from ddtrace.contrib.django.conf import settings as dd_settings
32+
33+
tracer = dd_settings.DEFAULT_TRACER
34+
tracer.trace("something")
35+
# your code ...
36+
37+
The available settings are:
1638
39+
* ``DEFAULT_TRACER`` (default ``ddtrace.tracer``): set the default tracer
40+
instance that is used to trace Django internals. By default the ``ddtrace``
41+
tracer is used.
42+
* ``DEFAULT_SERVICE`` (default: ``django``): set the service name used by the
43+
tracer. Usually this configuration must be updated with a meaningful name.
44+
* ``ENABLED``: (default: ``not django_settings.DEBUG``): set if the tracer
45+
is enabled or not. When a tracer is disabled, Django internals are not
46+
automatically instrumented and the requests are not traced even if the
47+
``TraceMiddleware`` is properly installed. This settings cannot be changed
48+
at runtime and a restart is required. By default the tracer is disabled
49+
when in ``DEBUG`` mode, enabled otherwise.
1750
"""
1851
from ..util import require_modules
1952

ddtrace/contrib/django/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ class DatadogSettings(object):
6161
A settings object, that allows Datadog settings to be accessed as properties.
6262
For example:
6363
64-
# TODO
64+
from ddtrace.contrib.django.conf import settings
65+
66+
tracer = settings.DEFAULT_TRACER
6567
6668
Any setting with string import paths will be automatically resolved
6769
and return the class, rather than the string literal.

0 commit comments

Comments
 (0)