This is a Django-based Notes application deployed on Kubernetes with distributed tracing using OpenTelemetry and Grafana.
- Django Web Application
- PostgreSQL Database
- Kubernetes Deployment
- OpenTelemetry Instrumentation
- Grafana Tempo for Distributed Tracing
- Kubernetes Cluster
- kubectl
- Helm (optional)
- Docker
notes-app
: Django web applicationpostgresql
: Database for storing notes
DB_NAME
: Database name (default:notes
)DB_USER
: Database user (default:django
)DB_PASSWORD
: Database passwordOTEL_EXPORTER_OTLP_ENDPOINT
: OpenTelemetry collector endpoint
kubectl apply -f deployment.yaml
After deploying, execute database migrations:
# Find the correct pod name
kubectl get pods
# Run makemigrations
kubectl exec <notes-app-pod-name> -- python manage.py makemigrations
# Apply migrations
kubectl exec <notes-app-pod-name> -- python manage.py migrate
Example:
kubectl exec notes-app-64887b67d6-86w86 -- python manage.py makemigrations
kubectl exec notes-app-64887b67d6-86w86 -- python manage.py migrate
When you run migrations, you'll see:
- Creation of initial migrations for
notes_app
- Application of Django default migrations (contenttypes, auth, admin, sessions)
- Uses OpenTelemetry Django and Psycopg2 instrumentations
- Traces include:
- Database connection details
- Query performance
- Distributed tracing context
opentelemetry-instrumentation-django
opentelemetry-instrumentation-psycopg2
opentelemetry-exporter-otlp
- Comprehensive OpenTelemetry instrumentation
- Spans for each view method
- Error tracking and status reporting
- Detailed attributes:
- HTTP methods
- Note primary keys
- Form validation status
- List notes
- Create notes
- Update notes
- Delete notes
- View note details
http.method
: HTTP request methodnotes.count
: Number of notesnote.pk
: Primary key of specific notesform.is_valid
: Form validation status
- Verify OpenTelemetry packages are installed
- Check OTLP exporter configuration
- Ensure tracing is enabled in Django settings
- Verify OTLP exporter endpoint
- Check Grafana Alloy configuration
- Ensure network connectivity between services and tracing backend
http://grafana-k8s-monitoring-alloy.grafana.svc.cluster.local:4317
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run locally:
python manage.py runserver
docker build -t dalareo/notes-app:latest .
Traces can be viewed in the Grafana Tempo dashboard.