Skip to content

Commit

Permalink
Allow django to be instrumented automatically
Browse files Browse the repository at this point in the history
Django instrumentation required that OTEL_PYTHON_DJANGO_INSTRUMENT
environment variable be set to "True" by users. All other
instrumentations are enabled out of the box and there is no apparent
reason to disable Django by default. This commit changes the logic so
that Django instrumentation is applied by default. Users can set
`OTEL_PYTHON_DJANGO_INSTRUMENT` env var to `"False"` to disable it.
  • Loading branch information
owais committed Oct 14, 2020
1 parent 6019a91 commit d92c457
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
8 changes: 7 additions & 1 deletion docs/examples/django/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Execution of the Django app

Set these environment variables first:

#. ``export OTEL_PYTHON_DJANGO_INSTRUMENT=True``
#. ``export DJANGO_SETTINGS_MODULE=instrumentation_example.settings``

The way to achieve OpenTelemetry instrumentation for your Django app is to use
Expand Down Expand Up @@ -100,6 +99,13 @@ output similar to this one:
The last output shows spans automatically generated by the OpenTelemetry Django
Instrumentation package.

Disabling Django Instrumentation
--------------------------------

Django's instrumentation can be disabled by setting the following environment variable.

#. ``export OTEL_PYTHON_DJANGO_INSTRUMENT=False``

References
----------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _instrument(self, **kwargs):
# built inside the Configuration class itself with the magic method
# __bool__

if not Configuration().DJANGO_INSTRUMENT:
if Configuration().DJANGO_INSTRUMENT is False:
return

# This can not be solved, but is an inherent problem of this approach:
Expand Down

This file was deleted.

0 comments on commit d92c457

Please sign in to comment.