Skip to content

Commit e9b5d83

Browse files
feat: add dd-trace to edxapp workers (edx#6)
This PR adds dd-trace to the worker boxes so we can monitor them (and celery tasks). It does not require dd to be enabled. --------- Co-authored-by: Tim McCormack <[email protected]>
1 parent 4942912 commit e9b5d83

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

playbooks/roles/edxapp/templates/edx/app/edxapp/worker.sh.j2

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,31 @@
44

55
{% set edxapp_venv_bin = edxapp_venv_dir + "/bin" %}
66
source {{ edxapp_app_dir }}/edxapp_env
7+
{% set executable = edxapp_venv_bin + '/celery' %}
8+
79
{% if COMMON_ENABLE_NEWRELIC_APP %}
8-
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/celery' %}
10+
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + executable %}
911

1012
export NEW_RELIC_CONFIG_FILE="{{ edxapp_app_dir }}/newrelic.ini"
1113
if command -v ec2metadata >/dev/null 2>&1; then
1214
INSTANCEID=$(ec2metadata --instance-id);
1315
HOSTNAME=$(hostname)
1416
export NEW_RELIC_PROCESS_HOST_DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
1517
fi
16-
{% else %}
17-
{% set executable = edxapp_venv_bin + '/celery' %}
1818
{% endif %}
1919

20+
{% if EDXAPP_DATADOG_ENABLE %}
21+
{% set executable = edxapp_venv_bin + '/ddtrace-run ' + executable %}
22+
export DD_TAGS="service:edx-edxapp-workers-{{ SERVICE_VARIANT }},queue:{{QUEUE_NAME}}"
23+
export DD_DJANGO_USE_LEGACY_RESOURCE_FORMAT=true
24+
# Copied from edx_django_service playbook for consistency; Datadog
25+
# trace debug logging issue doesn't actually affect edxapp for some
26+
# reason.
27+
export DD_TRACE_LOG_STREAM_HANDLER=false
28+
# Datadog's instrumentation breaks pymongo: https://github.com/edx/edx-arch-experiments/issues/580
29+
export DD_TRACE_PYMONGO_ENABLED=false
30+
{% endif -%}
31+
2032
# We exec so that celery is the child of supervisor and can be managed properly
2133

2234
exec {{ executable }} $@

playbooks/roles/edxapp/templates/edx/app/supervisor/conf.d.available/workers.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% for w in edxapp_workers %}
22
[program:{{ w.service_variant }}_{{ w.queue }}_{{ w.concurrency }}]
33

4-
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 }}
4+
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 }}
55
user={{ common_web_user }}
66
directory={{ edxapp_code_dir }}
77
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log

0 commit comments

Comments
 (0)