From 5bde1eca0d8e80c03911ad9d1925fb566717850c Mon Sep 17 00:00:00 2001 From: Chris Pappas Date: Mon, 20 May 2024 14:14:22 -0400 Subject: [PATCH 1/2] feat: REV-4051 | allow edx_django_service to be provided with specific app names to run datadog on fix: interpolation for DD installation conditional. also formatting fix: Apply suggestions from code review Co-authored-by: Tim McCormack fix: update variable name fix: update j2 file with new conditional --- playbooks/roles/common_vars/defaults/main.yml | 1 + playbooks/roles/edx_django_service/defaults/main.yml | 1 + playbooks/roles/edx_django_service/tasks/main.yml | 4 +++- .../roles/edx_django_service/templates/edx/app/app/app.sh.j2 | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/playbooks/roles/common_vars/defaults/main.yml b/playbooks/roles/common_vars/defaults/main.yml index b81f99637ea..423248a6388 100644 --- a/playbooks/roles/common_vars/defaults/main.yml +++ b/playbooks/roles/common_vars/defaults/main.yml @@ -102,6 +102,7 @@ COMMON_MONGO_READ_ONLY_PASS: !!null 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_NGINXTRA: False COMMON_ENABLE_SPLUNKFORWARDER: False COMMON_ENABLE_NEWRELIC: False diff --git a/playbooks/roles/edx_django_service/defaults/main.yml b/playbooks/roles/edx_django_service/defaults/main.yml index e0a1da0f162..ada2bde200e 100644 --- a/playbooks/roles/edx_django_service/defaults/main.yml +++ b/playbooks/roles/edx_django_service/defaults/main.yml @@ -104,6 +104,7 @@ edx_django_service_basic_auth_exempted_paths: '{{ edx_django_service_basic_auth_ edx_django_service_newrelic_appname: '{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-{{ edx_django_service_name }}' edx_django_service_enable_newrelic_distributed_tracing: false edx_django_datadog_service: 'edx-{{ edx_django_service_name }}' +edx_django_service_datadog_enable: '{{ COMMON_ENABLE_DATADOG and (COMMON_ENABLE_DATADOG_APP or edx_django_service_name in COMMON_ENABLE_DATADOG_APP_SERVICES }}' edx_django_service_repos: - PROTOCOL: '{{ edx_django_service_git_protocol }}' diff --git a/playbooks/roles/edx_django_service/tasks/main.yml b/playbooks/roles/edx_django_service/tasks/main.yml index 14004b11dcc..5b984f1c9ad 100644 --- a/playbooks/roles/edx_django_service/tasks/main.yml +++ b/playbooks/roles/edx_django_service/tasks/main.yml @@ -213,7 +213,9 @@ - install:app-requirements - name: "Install Datadog APM requirements" - when: COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP + when: > + COMMON_ENABLE_DATADOG and + (COMMON_ENABLE_DATADOG_APP or edx_django_service_datadog_enable) pip: name: - ddtrace diff --git a/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 b/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 index 606403ff2ba..22fd3802776 100644 --- a/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 +++ b/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 @@ -20,7 +20,7 @@ fi export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}" {% endif -%} -{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %} +{% if COMMON_ENABLE_DATADOG and (COMMON_ENABLE_DATADOG_APP or edx_django_service_datadog_enable) %} {% set executable = edx_django_service_venv_bin + '/ddtrace-run ' + executable %} export DD_TAGS="service:{{ edx_django_datadog_service }}" export DD_DJANGO_USE_HANDLER_RESOURCE_FORMAT=true From 58aa8c5ee42b48ce68f21d6547a765c6bc8d387c Mon Sep 17 00:00:00 2001 From: Chris Pappas Date: Wed, 22 May 2024 13:22:51 -0400 Subject: [PATCH 2/2] fix: Apply suggestions from code review Co-authored-by: Tim McCormack --- playbooks/roles/edx_django_service/tasks/main.yml | 4 +--- .../roles/edx_django_service/templates/edx/app/app/app.sh.j2 | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/playbooks/roles/edx_django_service/tasks/main.yml b/playbooks/roles/edx_django_service/tasks/main.yml index 5b984f1c9ad..18c3cfd1925 100644 --- a/playbooks/roles/edx_django_service/tasks/main.yml +++ b/playbooks/roles/edx_django_service/tasks/main.yml @@ -213,9 +213,7 @@ - install:app-requirements - name: "Install Datadog APM requirements" - when: > - COMMON_ENABLE_DATADOG and - (COMMON_ENABLE_DATADOG_APP or edx_django_service_datadog_enable) + when: edx_django_service_datadog_enable pip: name: - ddtrace diff --git a/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 b/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 index 22fd3802776..342386eede7 100644 --- a/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 +++ b/playbooks/roles/edx_django_service/templates/edx/app/app/app.sh.j2 @@ -20,7 +20,7 @@ fi export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}" {% endif -%} -{% if COMMON_ENABLE_DATADOG and (COMMON_ENABLE_DATADOG_APP or edx_django_service_datadog_enable) %} +{% if edx_django_service_datadog_enable %} {% set executable = edx_django_service_venv_bin + '/ddtrace-run ' + executable %} export DD_TAGS="service:{{ edx_django_datadog_service }}" export DD_DJANGO_USE_HANDLER_RESOURCE_FORMAT=true