You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/django/README.rst
+5-32Lines changed: 5 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,35 +46,7 @@ an ``opentelemetry.instrumentation.django.DjangoInstrumentor`` to instrument the
46
46
47
47
Clone the ``opentelemetry-python`` repository and go to ``opentelemetry-python/docs/examples/django``.
48
48
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.
78
50
79
51
Run the Django app with ``python manage.py runserver --noreload``.
80
52
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
137
109
Auto Instrumentation
138
110
--------------------
139
111
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()``
0 commit comments