Installation
🐍 Don’t forget to install the AppSignal for Python package in your application first.
opentelemetry-instrumentation-django package, as well as the opentelemetry-instrumentation-wsgi and opentelemetry-instrumentation-asgi packages. To add these packages to your project, add the following line to your requirements.txt file:
The AppSignal for Python integration will automatically use this instrumentation when the corresponding package is installed. To disable this instrumentation without uninstalling the package, use the
disable_default_instrumentations configuration option.Development setup
Django requires some extra setup, as it’s usually the first thing started in an app. As shown in the example below, theappsignal module needs to be imported in the manage.py file. Then in the main method, the appsignal.start method needs to be called to initialize the instrumentation configured in the __appsignal__.py file.
Production setup (WSGI/ASGI)
In production, it is recommended to run Django using a WSGI or ASGI server, such as Gunicorn or Uvicorn. In this scenario, themanage.py file that is modified in the development setup above is never called.
To instrument your application when started as a WSGI or ASGI server, add the following
to your project’s wsgi.py file, if using a WSGI server:
asgi.py file, if using an ASGI server: