Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design.
Install the Instrumentation
First, install the
opentelemetry-instrumentation-django package. To add it to your project, add the following line to your
# requirements.txt opentelemetry-instrumentation-django
Django requires some extra setup, as it's usually the first thing started in an app.
As shown in the example below, the
__appsignal__ 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
# manage.py #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys # Add this import statement from __appsignal__ import appsignal def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', '<YOUR_APP_NAME_HERE>.settings') # Add this method call appsignal.start() try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': main()
By default, the Django instrumentation reports incoming request parameters, like query strings and routing parameters.