diff --git a/playbooks/roles/xqueue/defaults/main.yml b/playbooks/roles/xqueue/defaults/main.yml index 507665e566c..8b9ad0873b5 100644 --- a/playbooks/roles/xqueue/defaults/main.yml +++ b/playbooks/roles/xqueue/defaults/main.yml @@ -58,6 +58,10 @@ XQUEUE_MYSQL_CONN_MAX_AGE: 0 # This is Django's default https://docs.djangoproje XQUEUE_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-xqueue" XQUEUE_CONSUMER_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-xqueue_consumer" + +XQUEUE_CONSUMER_DATADOG_APPNAME: "xqueue_consumer" + +XQUEUE_DATADOG_APPNAME: "{{ xqueue_service_name }}" # Set the number of gunicorn front end workers explicitely for xqueue XQUEUE_WORKERS: !!null diff --git a/playbooks/roles/xqueue/tasks/main.yml b/playbooks/roles/xqueue/tasks/main.yml index 5804e01522d..8fc4676a1eb 100644 --- a/playbooks/roles/xqueue/tasks/main.yml +++ b/playbooks/roles/xqueue/tasks/main.yml @@ -74,6 +74,19 @@ - install - install:app-requirements +- name: "Install Datadog APM requirements" + when: COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP + pip: + name: + - ddtrace + extra_args: "--exists-action w" + virtualenv: "{{ xqueue_venv_dir }}" + state: present + become_user: "{{ xqueue_user }}" + tags: + - install + - install:app-requirements + ######## END PYTHON3 ######## - name: build virtualenv with python2.7 diff --git a/playbooks/roles/xqueue/templates/xqueue.conf.j2 b/playbooks/roles/xqueue/templates/xqueue.conf.j2 index b058f73bc3c..39eb0687506 100644 --- a/playbooks/roles/xqueue/templates/xqueue.conf.j2 +++ b/playbooks/roles/xqueue/templates/xqueue.conf.j2 @@ -6,12 +6,16 @@ {% set executable = xqueue_venv_bin + '/gunicorn' %} {% endif %} +{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %} +{% set executable = xqueue_venv_bin + '/ddtrace-run ' + executable %} +{% endif -%} + command={{ executable }} -c {{ xqueue_app_dir }}/xqueue_gunicorn.py {{ XQUEUE_GUNICORN_WORKERS_EXTRA }} xqueue.wsgi user={{ common_web_user }} directory={{ xqueue_code_dir }} -environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ XQUEUE_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}PID=/var/tmp/xqueue.pid,PORT={{ xqueue_gunicorn_port }},ADDRESS={{ xqueue_gunicorn_host }},LANG={{ XQUEUE_LANG }},DJANGO_SETTINGS_MODULE=xqueue.{{ XQUEUE_SETTINGS }},XQUEUE_CFG={{ COMMON_CFG_DIR }}/xqueue.yml +environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ XQUEUE_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %}DD_TAGS={{ XQUEUE_DATADOG_APPNAME }},{% endif -%}PID=/var/tmp/xqueue.pid,PORT={{ xqueue_gunicorn_port }},ADDRESS={{ xqueue_gunicorn_host }},LANG={{ XQUEUE_LANG }},DJANGO_SETTINGS_MODULE=xqueue.{{ XQUEUE_SETTINGS }},XQUEUE_CFG={{ COMMON_CFG_DIR }}/xqueue.yml stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log diff --git a/playbooks/roles/xqueue/templates/xqueue_consumer.conf.j2 b/playbooks/roles/xqueue/templates/xqueue_consumer.conf.j2 index fe6a0c58496..014ada0809d 100644 --- a/playbooks/roles/xqueue/templates/xqueue_consumer.conf.j2 +++ b/playbooks/roles/xqueue/templates/xqueue_consumer.conf.j2 @@ -6,12 +6,16 @@ {% set executable = xqueue_venv_bin + '/django-admin run_consumer' %} {% endif %} +{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %} +{% set executable = xqueue_venv_bin + '/ddtrace-run ' + executable %} +{% endif -%} + command={{ executable }} --pythonpath={{ xqueue_code_dir }} --settings=xqueue.{{ XQUEUE_SETTINGS }} user={{ common_web_user }} directory={{ xqueue_code_dir }} -environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_STARTUP_TIMEOUT=10,NEW_RELIC_APP_NAME={{ XQUEUE_CONSUMER_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}LANG={{ XQUEUE_LANG }},XQUEUE_CFG={{ COMMON_CFG_DIR }}/xqueue.yml +environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_STARTUP_TIMEOUT=10,NEW_RELIC_APP_NAME={{ XQUEUE_CONSUMER_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %}DD_TAGS={{ XQUEUE_CONSUMER_DATADOG_APPNAME }},{% endif -%}LANG={{ XQUEUE_LANG }},XQUEUE_CFG={{ COMMON_CFG_DIR }}/xqueue.yml stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log diff --git a/playbooks/roles/xqwatcher/defaults/main.yml b/playbooks/roles/xqwatcher/defaults/main.yml index d79b0551ce6..2bfe8760ee8 100644 --- a/playbooks/roles/xqwatcher/defaults/main.yml +++ b/playbooks/roles/xqwatcher/defaults/main.yml @@ -75,6 +75,7 @@ XQWATCHER_REPOS: XQWATCHER_NEWRELIC_APPNAME: "{{ COMMON_DEPLOYMENT }}-{{ COMMON_ENVIRONMENT }}-xqwatcher" XQWATCHER_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}" +XQWATCHER_DATADOG_APPNAME: "{{ xqwatcher_service_name }}" # # # vars are namespace with the module name. diff --git a/playbooks/roles/xqwatcher/tasks/deploy_watcher.yml b/playbooks/roles/xqwatcher/tasks/deploy_watcher.yml index 8cbd29c52f3..e9a13e29113 100644 --- a/playbooks/roles/xqwatcher/tasks/deploy_watcher.yml +++ b/playbooks/roles/xqwatcher/tasks/deploy_watcher.yml @@ -14,6 +14,19 @@ - install - install:app-requirements +- name: "Install Datadog APM requirements" + when: COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP + pip: + name: + - ddtrace + extra_args: "--exists-action w" + virtualenv: "{{ xqwatcher_app_dir }}/venvs/{{ xqwatcher_service_name }}" + state: present + become_user: "{{ xqwatcher_user }}" + tags: + - install + - install:app-requirements + - name: Write out course config files template: src: "edx/app/xqwatcher/conf.d/course.json.j2" diff --git a/playbooks/roles/xqwatcher/templates/edx/app/supervisor/conf.d/xqwatcher.conf.j2 b/playbooks/roles/xqwatcher/templates/edx/app/supervisor/conf.d/xqwatcher.conf.j2 index 94b94fdb05d..778e7a7217e 100644 --- a/playbooks/roles/xqwatcher/templates/edx/app/supervisor/conf.d/xqwatcher.conf.j2 +++ b/playbooks/roles/xqwatcher/templates/edx/app/supervisor/conf.d/xqwatcher.conf.j2 @@ -8,6 +8,9 @@ {% else %} {% set executable = xqwatcher_venv_dir + '/bin/python' %} {% endif %} +{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %} +{% set executable = xqwatcher_venv_dir + '/ddtrace-run ' + executable %} +{% endif -%} [program:{{ xqwatcher_service_name }}] command={{ executable }} -m {{ xqwatcher_module }} -d {{ xqwatcher_conf_dir }} @@ -16,6 +19,6 @@ user={{ common_web_user }} directory={{ xqwatcher_code_dir }} stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log -environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ XQWATCHER_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%} +environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ XQWATCHER_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}{% if COMMON_ENABLE_DATADOG and COMMON_ENABLE_DATADOG_APP %}DD_TAGS="service:{{ XQWATCHER_DATADOG_APPNAME }}",{% endif -%} killasgroup=true stopasgroup=true