Skip to content

Commit 16c42d4

Browse files
Update Django README.rst to avoid duplication and clarify auto-instrumentation
Co-authored-by: BrianPetkovsek <[email protected]>
1 parent 8eeb1ed commit 16c42d4

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

docs/examples/django/README.rst

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,7 @@ an ``opentelemetry.instrumentation.django.DjangoInstrumentor`` to instrument the
4646

4747
Clone the ``opentelemetry-python`` repository and go to ``opentelemetry-python/docs/examples/django``.
4848

49-
Once there, open the ``manage.py`` file. To see spans output to console, you need to:
50-
51-
1. Set up a ``TracerProvider``
52-
2. Add a ``SpanProcessor`` with an exporter (e.g., ``ConsoleSpanExporter`` for stdout)
53-
3. Call ``DjangoInstrumentor().instrument()`` to instrument the Django app
54-
55-
The ``manage.py`` example includes this setup:
56-
57-
.. code-block:: python
58-
59-
from opentelemetry import trace
60-
from opentelemetry.instrumentation.django import DjangoInstrumentor
61-
from opentelemetry.sdk.trace import TracerProvider
62-
from opentelemetry.sdk.trace.export import (
63-
BatchSpanProcessor,
64-
ConsoleSpanExporter,
65-
)
66-
67-
# Set up tracing with console exporter to see spans in stdout
68-
trace.set_tracer_provider(TracerProvider())
69-
trace.get_tracer_provider().add_span_processor(
70-
BatchSpanProcessor(ConsoleSpanExporter())
71-
)
72-
73-
# This call is what makes the Django application be instrumented
74-
DjangoInstrumentor().instrument()
75-
76-
Without the ``TracerProvider`` and ``SpanProcessor`` setup, the instrumentation will
77-
capture traces but they won't be exported anywhere (no output will be visible).
49+
Once there, open the ``manage.py`` file, which uses the OpenTelemetry SDK to set up tracing with console exporter and manual instrumentation of Django.
7850

7951
Run the Django app with ``python manage.py runserver --noreload``.
8052
The ``--noreload`` flag is needed to avoid Django from running ``main`` twice.
@@ -137,9 +109,10 @@ Django's instrumentation can be disabled by setting the following environment va
137109
Auto Instrumentation
138110
--------------------
139111

140-
This same example can be run using auto instrumentation. Comment out the call
141-
to ``DjangoInstrumentor().instrument()`` in ``main``, then Run the django app
142-
with ``opentelemetry-instrument python manage.py runserver --noreload``.
112+
This same example can be run using auto instrumentation. Comment out the
113+
``TracerProvider`` setup and the call to ``DjangoInstrumentor().instrument()``
114+
in ``main``, then run the Django app with
115+
``opentelemetry-instrument python manage.py runserver --noreload``.
143116
Repeat the steps with the client, the result should be the same.
144117

145118
Usage with Auto Instrumentation and uWSGI

0 commit comments

Comments
 (0)