Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding debug stack trace feature to celery tasks #1946

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/celery/scheduled_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ def beat_inbox_email_bulk():
receipt_id_email, list_of_email_notifications = email_bulk.poll()


if current_app.config["FF_DEBUG_STACK_TRACE"]:

@notify_celery.task(name="debug-stack-trace")
@statsd(namespace="tasks")
def debug_stack_trace():
"""
This function, when enabled, will throw an exception so that we can test multi-line logging
"""
raise Exception("Debugging")


@notify_celery.task(name="beat-inbox-email-priority")
@statsd(namespace="tasks")
def beat_inbox_email_priority():
Expand All @@ -325,6 +336,7 @@ def beat_inbox_email_priority():
to another list(list#2). The heartbeat will then call a job that saves list#2 to the DB
and actually sends the email for each notification saved.
"""

receipt_id_email, list_of_email_notifications = email_priority.poll()

while list_of_email_notifications:
Expand Down
14 changes: 14 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class Config(object):
# 'options': {'queue': QueueNames.PERIODIC}
# },
}

CELERY_QUEUES: List[Any] = []

CONTACT_FORM_EMAIL_ADDRESS = os.getenv("CONTACT_FORM_EMAIL_ADDRESS", "[email protected]")
Expand Down Expand Up @@ -525,6 +526,19 @@ class Config(object):
# Timestamp in epoch milliseconds to seed the bounce rate. We will seed data for (24, the below config) included.
FF_BOUNCE_RATE_SEED_EPOCH_MS = os.getenv("FF_BOUNCE_RATE_SEED_EPOCH_MS", False)

# Feature flag for stack trace debugging
FF_DEBUG_STACK_TRACE = env.bool("FF_DEBUG_STACK_TRACE", False)
if FF_DEBUG_STACK_TRACE:
CELERYBEAT_SCHEDULE.update(
{
"debug-stack-trace": {
"task": "debug-stack-trace",
"schedule": 10,
"options": {"queue": QueueNames.PERIODIC},
},
}
)

@classmethod
def get_sensitive_config(cls) -> list[str]:
"List of config keys that contain sensitive information"
Expand Down