From 3108b7eb873b2183a5596359f43025f78cf15b5e Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Wed, 23 Oct 2024 14:58:54 -0400 Subject: [PATCH] feat: Add variables to enable DD profiling. We want to be able to turn on profiling separate from Datadog in general. Introduce a new variable that could be set per-environment. --- playbooks/roles/common_vars/defaults/main.yml | 1 + playbooks/roles/edxapp/defaults/main.yml | 1 + playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 | 5 +++++ playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 | 5 +++++ playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/playbooks/roles/common_vars/defaults/main.yml b/playbooks/roles/common_vars/defaults/main.yml index ef2b5be854c..e461607cdf3 100644 --- a/playbooks/roles/common_vars/defaults/main.yml +++ b/playbooks/roles/common_vars/defaults/main.yml @@ -103,6 +103,7 @@ COMMON_ENABLE_DATADOG: False # Enable APM monitoring with Datadog (metrics, traces, and logs) COMMON_ENABLE_DATADOG_APP: False COMMON_ENABLE_DATADOG_APP_SERVICES: [] +COMMON_ENABLE_DATADOG_PROFILING: False COMMON_ENABLE_NGINXTRA: False COMMON_ENABLE_SPLUNKFORWARDER: False COMMON_ENABLE_NEWRELIC: False diff --git a/playbooks/roles/edxapp/defaults/main.yml b/playbooks/roles/edxapp/defaults/main.yml index 54cf414806a..666132d4be3 100644 --- a/playbooks/roles/edxapp/defaults/main.yml +++ b/playbooks/roles/edxapp/defaults/main.yml @@ -631,6 +631,7 @@ EDXAPP_XML_S3_BUCKET: !!null EDXAPP_XML_S3_KEY: !!null EDXAPP_DATADOG_ENABLE: "{{COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP}}" +EDXAPP_DATADOG_PROFILING_ENABLE: "{{EDXAPP_DATADOG_ENABLE and COMMON_ENABLE_DATADOG_PROFILING}}" # ddtrace 2.7.9 contains a fix for a pymongo incompatibility. # (Same fix is present in 2.8.2 on the 2.8.x release line.) EDXAPP_DDTRACE_PIP_SPEC: 'ddtrace>=2.7.9' diff --git a/playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 b/playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 index 3a718694912..f3dc209aa3b 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 @@ -26,6 +26,11 @@ export DD_TRACE_LOG_STREAM_HANDLER=false export DD_DJANGO_INSTRUMENT_MIDDLEWARE=false {% endif -%} +# We want to be able to toggle this on separately from DD in general. +{% if EDXAPP_DATADOG_PROFILING_ENABLE %} +export DD_PROFILING_ENABLED=true +{% endif -%} + export PORT="{{ edxapp_cms_gunicorn_port }}" export ADDRESS="{{ edxapp_cms_gunicorn_host }}" export LANG="{{ EDXAPP_LANG }}" diff --git a/playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 b/playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 index 0d1850c9cc9..e473cf59b24 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 @@ -27,6 +27,11 @@ export DD_DJANGO_INSTRUMENT_MIDDLEWARE=false {% endif -%} +# We want to be able to toggle this on separately from DD in general. +{% if EDXAPP_DATADOG_PROFILING_ENABLE %} +export DD_PROFILING_ENABLED=true +{% endif -%} + export PORT="{{ edxapp_lms_gunicorn_port }}" export ADDRESS="{{ edxapp_lms_gunicorn_host }}" export LANG="{{ EDXAPP_LANG }}" diff --git a/playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 b/playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 index 30baae42094..a4d81156772 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 @@ -26,6 +26,10 @@ export DD_TRACE_LOG_STREAM_HANDLER=false export DD_DJANGO_INSTRUMENT_MIDDLEWARE=false {% endif -%} +# We want to be able to toggle this on separately from DD in general. +{% if EDXAPP_DATADOG_PROFILING_ENABLE %} +export DD_PROFILING_ENABLED=true +{% endif -%} # We exec so that celery is the child of supervisor and can be managed properly