Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jennydaman/otel_django_2302
Reproduction case for https://github.com/open-telemetry/opentelemetry-operator/issues/2302
https://github.com/jennydaman/otel_django_2302
Last synced: 21 days ago
JSON representation
Reproduction case for https://github.com/open-telemetry/opentelemetry-operator/issues/2302
- Host: GitHub
- URL: https://github.com/jennydaman/otel_django_2302
- Owner: jennydaman
- Created: 2023-11-04T03:58:06.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-04T03:58:21.000Z (about 1 year ago)
- Last Synced: 2024-04-24T04:42:03.071Z (9 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Open Telemetry Django Python Import Bug
Minimal reproduction case for https://github.com/open-telemetry/opentelemetry-operator/issues/2302
## Setup
```shell
./create_cluster.sh # create cluster using kind, install cert-manager, opentelemetry operator
kubectl apply -f pod-otel-installed.yml,pod-otel-operator.yml
```### Tests
```shell
# Import a normal Python module
kubectl exec django-uses-operator -- python manage.py shell -c 'import vanilla.bean' # WORKS# Import a normal Python module which defines a Django model
kubectl exec django-uses-operator -- python manage.py shell -c 'import pears.models' # FAILS# Same as above, but prepend /app to PYTHONPATH
kubectl exec django-uses-operator -- sh -c 'env PYTHONPATH="/app:$PYTHONPATH" python manage.py shell -c "import pears.models"' # FAILS# Same as above, but unset PYTHONPATH
kubectl exec django-uses-operator -- sh -c 'env PYTHONPATH= python manage.py shell -c "import pears.models"' # WORKS# Functionally the same as above, explicit PYTHONPATH
kubectl exec django-uses-operator -- sh -c 'env PYTHONPATH="/app" python manage.py shell -c "import pears.models"' # WORKS
```Error message for failing test cases:
```
RuntimeError: Model class pears.models.Pear doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
``````shell
# not using otel operator
kubectl exec django-uses-installed -- python manage.py shell -c 'import pears.models' # WORKS# manual usage of autoinstrumentation, without otel operator
kubectl exec django-uses-installed -- opentelemetry-instrument --traces_exporter console,otlp --metrics_exporter console --service_name pearfarm --exporter_otlp_endpoint https://example.com python manage.py shell -c 'import pears.models' # FAILS
# manual usage of autoinstrumentation, but unset PYTHONPATH
kubectl exec django-uses-installed -- sh -c 'opentelemetry-instrument --traces_exporter console,otlp --metrics_exporter console --service_name pearfarm --exporter_otlp_endpoint https://example.com env PYTHONPATH= python manage.py shell -c "import pears.models"' # WORKS
```Same error message as before.
### Tear Down
```shell
kind delete cluster
```## Notes to self
I used these commands to build the images.
```shell
docker buildx build -t docker.io/jennydaman/djangoexamplepear:latest --push .
docker buildx build -t docker.io/jennydaman/djangoexamplepear:otel --build-arg otel=y --push .
```