https://github.com/hyperdxio/sample-django
https://github.com/hyperdxio/sample-django
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hyperdxio/sample-django
- Owner: hyperdxio
- License: mit
- Created: 2024-06-21T19:58:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-27T07:50:41.000Z (almost 2 years ago)
- Last Synced: 2025-01-08T19:41:51.069Z (over 1 year ago)
- Language: Python
- Size: 34.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Preparing Django app
1. `python3 manage.py migrate`
2. `python3 manage.py collectstatic`
3. `python3 manage.py createsuperuser`
# Running with HyperDX
- Create a virtual environment and activate it
```
python3 -m venv .venv
source .venv/bin/activate
```
- Install requirements
```
pip install -r requirements.txt
```
- Install instrumentation packages
```
opentelemetry-bootstrap --action=install
```
## To run with gunicorn you need to add post_fork hook
1. Add a file `gunicorn.config.py` as given in this repo
2. Specify that config file when running gunicorn as in below run command
```
DJANGO_SETTINGS_MODULE=mysite.settings OTEL_SERVICE_NAME=mysite HYPERDX_API_KEY= opentelemetry-instrument gunicorn mysite.wsgi -c gunicorn.config.py --workers 2 --threads 2
```
*specifying **DJANGO_SETTINGS_MODULE** is necessary for opentelemetry instrumentation to work*
# Browsing the app and checking at HyperDX
1. Visit `http://localhost:8000/admin` and create a question for poll
2. Then visit the list of polls at `http://localhost:8000/polls/` and explore the polls
3. The data should be visible now in HyperDX at `https://hyperdx.io/search`