Skip to content

Commit 24e39ba

Browse files
authored
NDH-565: Implementing collecting traces and sending to Datadog (#368)
* NDH-565: Implementing collecting traces and sending to Datadog
1 parent 235adb8 commit 24e39ba

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

backend/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ USER appuser
7373
# Expose the application port
7474
EXPOSE 8000
7575

76+
# Run Django’s development server
77+
# CMD ["ddtrace-run", "python", "manage.py", "runserver", "--insecure", "0.0.0.0:8000"]
78+
79+
# Start the application using Gunicorn
80+
#CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "3", "app.wsgi:application"]
7681
# In production, collect static assets then start gunicorn in entrypoint.sh
7782
# Note that this behavior is disabled for local dev by updating entrypoint in compose.yml
7883
ENTRYPOINT ["./entrypoint.sh"]
79-
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "3", "app.wsgi:application"]
84+
CMD ["ddtrace-run", "gunicorn", "--bind", "0.0.0.0:8000", "--workers", "3", "app.wsgi:application"]

backend/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ types-python-dateutil==2.9.0.20250516
5050
typing_extensions==4.14.0
5151
unittest-xml-reporting==3.2.0
5252
urllib3==2.6.3
53-
whitenoise==6.11.0
53+
ddtrace==4.3.0
54+
whitenoise==6.11.0

compose.test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ services:
3232
environment:
3333
NPD_DB_NAME: npd_test
3434
TESTING: True
35+
depends_on: !override
36+
- db
37+
- db-migrations
3538

3639
volumes:
3740
postgres_data:

compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ services:
2222
NPD_DB_HOST: ${NPD_DB_HOST:-db}
2323
NPD_DB_PORT: ${NPD_DB_PORT:-5432}
2424
NPD_REQUIRE_AUTHENTICATION: False
25+
DD_AGENT_HOST: datadog-agent
26+
DD_ENV: "${ENV_KEY:-dev}"
27+
DD_SERVICE: "django-web"
28+
DD_VERSION: "1.0.0"
29+
DD_LOGS_INJECTION: true
30+
labels:
31+
com.datadoghq.tags.env: "${ENV_KEY:-dev}"
32+
com.datadoghq.tags.service: "django-web"
33+
com.datadoghq.tags.version: "1.0.0"
2534
ports:
2635
- '8000:8000'
2736
volumes:
2837
- './backend/:/app'
2938
- ./backend/artifacts:/app/artifacts:rw
3039
- ./backend/provider_directory/static:/app/provider_directory/static:rw
3140
depends_on:
41+
- db
42+
- datadog-agent
3243
- db-migrations
3344

3445
db:
@@ -93,6 +104,23 @@ services:
93104
IN_DOCKER: 1
94105
command: ["npm", "run", "watch"]
95106

107+
datadog-agent:
108+
image: datadog/agent:latest
109+
environment:
110+
- DD_API_KEY=${DATADOG_API_KEY:-dummy-api-key}
111+
- DD_SITE=ddog-gov.com
112+
- DD_APM_ENABLED=true
113+
- DD_APM_NON_LOCAL_TRAFFIC=true
114+
volumes:
115+
- /var/run/docker.sock:/var/run/docker.sock:ro
116+
- /proc/:/host/proc/:ro
117+
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
118+
healthcheck:
119+
test: ["CMD", "agent", "status"]
120+
interval: 30s
121+
retries: 3
122+
timeout: 10s
123+
96124
volumes:
97125
postgres_data:
98126
node_modules:

0 commit comments

Comments
 (0)