Skip to content

Commit

Permalink
Instrument the sample application using CWOperator. (#44)
Browse files Browse the repository at this point in the history
This PR Instrument the sample application using CWOperator by setting up
following:
1. annotation: instrumentation.opentelemetry.io/inject-python: "true"
2. run the server with `--noreload`
3. Add `DJANGO_SETTINGS_MODULE` env variable.
4. Add `PYTHONPATH` env variable, this is required as CWOperator
instrumentation when application is mount in a specific directory
instead of root.
5. Add `OTEL_TRACES_SAMPLER`, this will be removed when Xray remote
sampler is ready.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
  • Loading branch information
zzhlogin authored Feb 8, 2024
1 parent 9275ff9 commit 476503d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ services:
context: .
dockerfile: VehicleInventoryApp/Dockerfile
container_name: vehicle-inventory-backend
command: sh -c "python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py runserver 0.0.0.0:8001"
command: sh -c "python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py runserver 0.0.0.0:8001 --noreload"
restart: always
volumes:
- ./VehicleInventoryApp/.:/vehicle-inventory-app
environment:
DJANGO_SETTINGS_MODULE: "VehicleInventoryApp.settings"
OTEL_TRACES_SAMPLER: "always_on"
ports:
- "8001:8001"
depends_on:
Expand All @@ -44,11 +47,14 @@ services:
context: .
dockerfile: ImageServiceApp/Dockerfile
container_name: image-service-backend
command: sh -c "python3 manage.py runserver 0.0.0.0:8000"
command: sh -c "python3 manage.py runserver 0.0.0.0:8000 --noreload"
restart: always
volumes:
- ./ImageServiceApp/.:/image-service-app
- $HOME/.aws/credentials:/home/app/.aws/credentials:ro
environment:
DJANGO_SETTINGS_MODULE: "ImageServiceApp.settings"
OTEL_TRACES_SAMPLER: "always_on"
ports:
- "8000:8000"
depends_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
annotations:
kompose.cmd: kompose convert -f docker-compose.yaml
kompose.version: 1.31.2 (HEAD)
instrumentation.opentelemetry.io/inject-python: "true"
creationTimestamp: null
labels:
io.kompose.network/vehicleinventoryapp-default: "true"
Expand All @@ -31,7 +32,7 @@ spec:
- args:
- sh
- -c
- python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py runserver 0.0.0.0:8001
- python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py runserver 0.0.0.0:8001 --noreload
image: ${REPOSITORY_PREFIX}/pythonsampleapp/vehicle-inventory-service:latest
name: vehicle-inventory-backend
env:
Expand All @@ -41,6 +42,13 @@ spec:
value: ${POSTGRES_PASSWORD}
- name: POSTGRES_USER
value: djangouser
- name: PYTHONPATH
value: "/vehicle-inventory-app"
- name: DJANGO_SETTINGS_MODULE
value: "VehicleInventoryApp.settings"
# TODO: Remove OTEL_TRACES_SAMPLER when XRay trace sampler is ready
- name: OTEL_TRACES_SAMPLER
value: "always_on"
imagePullPolicy: Always
ports:
- containerPort: 8001
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
annotations:
kompose.cmd: Kompose convert -f docker-compose.yaml
kompose.version: 1.31.2 (HEAD)
instrumentation.opentelemetry.io/inject-python: "true"
creationTimestamp: null
labels:
io.kompose.network/imageserviceapp-default: "true"
Expand All @@ -31,7 +32,7 @@ spec:
- args:
- sh
- -c
- python3 manage.py runserver 0.0.0.0:8000
- python3 manage.py runserver 0.0.0.0:8000 --noreload
image: ${REPOSITORY_PREFIX}/pythonsampleapp/image-service:latest
name: image-service-backend
imagePullPolicy: Always
Expand All @@ -49,5 +50,12 @@ spec:
value: ${POSTGRES_PASSWORD}
- name: POSTGRES_USER
value: djangouser
- name: PYTHONPATH
value: "/image-service-app"
- name: DJANGO_SETTINGS_MODULE
value: "ImageServiceApp.settings"
# TODO: Remove OTEL_TRACES_SAMPLER when XRay trace sampler is ready
- name: OTEL_TRACES_SAMPLER
value: "always_on"
restartPolicy: Always
status: {}

0 comments on commit 476503d

Please sign in to comment.