python3 manage.py migrate
python3 manage.py collectstatic
python3 manage.py createsuperuser
pip3 install -r requirements.txt
opentelemetry-bootstrap --action=install
- add a file
gunicorn.config.py
as given in this repo - specify that config file when running gunicorn as in below run command
DJANGO_SETTINGS_MODULE=<DJANGO_APP>.settings OTEL_RESOURCE_ATTRIBUTES=service.name=<serviceName> OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP OF SigNoz>:4317" opentelemetry-instrument gunicorn <DJANGO_APP>.wsgi -c gunicorn.config.py --workers 2 --threads 2 --reload
specifying DJANGO_SETTINGS_MODULE is necessary for opentelemetry instrumentation to work
For this example, sample command would look like
DJANGO_SETTINGS_MODULE=mysite.settings OTEL_RESOURCE_ATTRIBUTES=service.name=MainApp OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP Of SigNoz>:4317" opentelemetry-instrument gunicorn mysite.wsgi -c gunicorn.config.py --workers 2 --threads 2 --reload
docker run --env OTEL_METRICS_EXPORTER=none \
--env OTEL_SERVICE_NAME=djangoApp \
--env OTEL_EXPORTER_OTLP_ENDPOINT=host.docker.internal:4317 \
--env DJANGO_SETTINGS_MODULE=mysite.settings \
-p 8000:8000 \
-t signoz/sample-django:latest opentelemetry-instrument gunicorn mysite.wsgi -c gunicorn.config.py --workers 2 --threads 2 --reload --bind 0.0.0.0:8000
Add below service to your docker-compose
django-app:
image: "signoz/sample-django:latest"
container_name: sample-django
command: opentelemetry-instrument gunicorn mysite.wsgi -c gunicorn.config.py --workers 2 --threads 2 --reload --bind 0.0.0.0:8000
ports:
- "8000:8000"
environment:
- OTEL_METRICS_EXPORTER=none
- OTEL_SERVICE_NAME=djangoApp
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- DJANGO_SETTINGS_MODULE=mysite.settings
- Visit
http://localhost:8000/admin
and create a question for poll - Then visit the list of polls at
http://localhost:8000/polls/
and explore the polls - The data should be visible now in SigNoz at
http://<IP of SigNoz>:3000