From f28648e35b2918de8efa8d8a6e2cb8d7e10f188e Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Thu, 3 Oct 2024 19:27:18 +0000 Subject: [PATCH] feat: Disable NR for edxapp and gate it on new edxapp-specific variable (#74) Introduces `EDXAPP_NEWRELIC_ENABLE` and sets it to false so edxapp is no longer drawing from the common `COMMON_ENABLE_NEWRELIC_APP` variable. This is now possible thanks to fixes in ddtrace 2.14.2. See https://github.com/edx/edx-arch-experiments/issues/692 --- playbooks/roles/edxapp/defaults/main.yml | 2 ++ .../edxapp/templates/edx/app/edxapp/beat_scheduler.sh.j2 | 2 +- playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 | 2 +- playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 | 2 +- playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 | 2 +- .../edx/app/supervisor/conf.d.available/workers.conf.j2 | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/playbooks/roles/edxapp/defaults/main.yml b/playbooks/roles/edxapp/defaults/main.yml index 2f81167457e..772949873e2 100644 --- a/playbooks/roles/edxapp/defaults/main.yml +++ b/playbooks/roles/edxapp/defaults/main.yml @@ -630,6 +630,8 @@ EDXAPP_XML_FROM_GIT: false EDXAPP_XML_S3_BUCKET: !!null EDXAPP_XML_S3_KEY: !!null +# Whether to enable newrelic APM for edxapp webapp or worker processes. +EDXAPP_NEWRELIC_ENABLE: false EDXAPP_NEWRELIC_LMS_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-edxapp-lms" EDXAPP_NEWRELIC_CMS_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-edxapp-cms" EDXAPP_NEWRELIC_WORKERS_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-edxapp-workers" diff --git a/playbooks/roles/edxapp/templates/edx/app/edxapp/beat_scheduler.sh.j2 b/playbooks/roles/edxapp/templates/edx/app/edxapp/beat_scheduler.sh.j2 index 88d764c41f5..241a7dddeda 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/beat_scheduler.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/beat_scheduler.sh.j2 @@ -4,7 +4,7 @@ {% set edxapp_venv_bin = edxapp_venv_dir + "/bin" %} source {{ edxapp_app_dir }}/edxapp_env -{% if COMMON_ENABLE_NEWRELIC_APP %} +{% if EDXAPP_NEWRELIC_ENABLE %} {% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/single-beat ' + edxapp_venv_bin + '/celery' %} export NEW_RELIC_CONFIG_FILE="{{ edxapp_app_dir }}/newrelic.ini" 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 df8e0f8b5e6..df902fc3a62 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2 @@ -6,7 +6,7 @@ {% set executable = edxapp_venv_bin + '/gunicorn' %} -{% if COMMON_ENABLE_NEWRELIC_APP %} +{% if EDXAPP_NEWRELIC_ENABLE %} {% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + executable %} export NEW_RELIC_DISTRIBUTED_TRACING_ENABLED="{{ EDXAPP_CMS_ENABLE_NEWRELIC_DISTRIBUTED_TRACING }}" 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 1ab63de2adb..b8792825a6c 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2 @@ -6,7 +6,7 @@ {% set executable = edxapp_venv_bin + '/gunicorn' %} -{% if COMMON_ENABLE_NEWRELIC_APP %} +{% if EDXAPP_NEWRELIC_ENABLE %} {% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + executable %} export NEW_RELIC_DISTRIBUTED_TRACING_ENABLED="{{ EDXAPP_LMS_ENABLE_NEWRELIC_DISTRIBUTED_TRACING }}" 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 e09ff4668f2..e3d4e7bb45e 100644 --- a/playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2 @@ -5,7 +5,7 @@ {% set edxapp_venv_bin = edxapp_venv_dir + "/bin" %} source {{ edxapp_app_dir }}/edxapp_env {% set executable = edxapp_venv_bin + '/celery' %} -{% if COMMON_ENABLE_NEWRELIC_APP %} +{% if EDXAPP_NEWRELIC_ENABLE %} {% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + executable %} export NEW_RELIC_CONFIG_FILE="{{ edxapp_app_dir }}/newrelic.ini" diff --git a/playbooks/roles/edxapp/templates/edx/app/supervisor/conf.d.available/workers.conf.j2 b/playbooks/roles/edxapp/templates/edx/app/supervisor/conf.d.available/workers.conf.j2 index a317e27f548..685f375878a 100644 --- a/playbooks/roles/edxapp/templates/edx/app/supervisor/conf.d.available/workers.conf.j2 +++ b/playbooks/roles/edxapp/templates/edx/app/supervisor/conf.d.available/workers.conf.j2 @@ -1,7 +1,7 @@ {% for w in edxapp_workers %} [program:{{ w.service_variant }}_{{ w.queue }}_{{ w.concurrency }}] -environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_WORKERS_APPNAME }}-{{ w.service_variant }},NEW_RELIC_DISTRIBUTED_TRACING_ENABLED={{ EDXAPP_WORKERS_ENABLE_NEWRELIC_DISTRIBUTED_TRACING }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}CONCURRENCY={{ w.concurrency }},LOGLEVEL=info,DJANGO_SETTINGS_MODULE={{ w.service_variant }}.envs.{{ worker_django_settings_module }},LANG={{ EDXAPP_LANG }},PYTHONPATH={{ edxapp_code_dir }},SERVICE_VARIANT={{ w.service_variant }},BOTO_CONFIG="{{ edxapp_app_dir }}/.boto",EDX_REST_API_CLIENT_NAME=edx.{{ w.service_variant }}.core.{{ w.queue }},QUEUE_NAME={{ w.service_variant }}.core.{{ w.queue }} +environment={% if EDXAPP_NEWRELIC_ENABLE %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_WORKERS_APPNAME }}-{{ w.service_variant }},NEW_RELIC_DISTRIBUTED_TRACING_ENABLED={{ EDXAPP_WORKERS_ENABLE_NEWRELIC_DISTRIBUTED_TRACING }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}CONCURRENCY={{ w.concurrency }},LOGLEVEL=info,DJANGO_SETTINGS_MODULE={{ w.service_variant }}.envs.{{ worker_django_settings_module }},LANG={{ EDXAPP_LANG }},PYTHONPATH={{ edxapp_code_dir }},SERVICE_VARIANT={{ w.service_variant }},BOTO_CONFIG="{{ edxapp_app_dir }}/.boto",EDX_REST_API_CLIENT_NAME=edx.{{ w.service_variant }}.core.{{ w.queue }},QUEUE_NAME={{ w.service_variant }}.core.{{ w.queue }} user={{ common_web_user }} directory={{ edxapp_code_dir }} stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log @@ -20,7 +20,7 @@ programs={%- for w in edxapp_workers %}{{ w.service_variant }}_{{ w.queue }}_{{ {% if EDXAPP_ENABLE_CELERY_BEAT|bool and EDXAPP_CELERY_BROKER_TRANSPORT == "redis" %} [program:celerybeat_scheduler] environment= - {% if COMMON_ENABLE_NEWRELIC_APP %} + {% if EDXAPP_NEWRELIC_ENABLE %} NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_WORKERS_APPNAME }}-lms, NEW_RELIC_DISTRIBUTED_TRACING_ENABLED={{ EDXAPP_WORKERS_ENABLE_NEWRELIC_DISTRIBUTED_TRACING }}, NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},