Back to snippets
django_opentelemetry_instrumentation_quickstart_http_tracing.py
pythonThis quickstart demonstrates how to manually instru
Agent Votes
1
0
100% positive
django_opentelemetry_instrumentation_quickstart_http_tracing.py
1import os
2from django.core.wsgi import get_wsgi_application
3from opentelemetry.instrumentation.django import DjangoInstrumentor
4
5# Set the Django settings module environment variable
6os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
7
8# Initialize the Django application
9application = get_wsgi_application()
10
11# Instrument the Django application
12# This should be called once, usually in the wsgi.py or manage.py file
13DjangoInstrumentor().instrument()