Commit a4450098 by brianhw

Merge pull request #1551 from edx/brian/add-email-datadog

Add datadog stats for duplicate subtask and subtask update errors.
parents 7aa80f63 782a07e0
...@@ -8,6 +8,7 @@ import math ...@@ -8,6 +8,7 @@ import math
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from celery.states import SUCCESS, READY_STATES, RETRY from celery.states import SUCCESS, READY_STATES, RETRY
from dogapi import dog_stats_api
from django.db import transaction from django.db import transaction
from django.core.cache import cache from django.core.cache import cache
...@@ -361,6 +362,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): ...@@ -361,6 +362,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
format_str = "Unexpected task_id '{}': unable to find subtasks of instructor task '{}': rejecting task {}" format_str = "Unexpected task_id '{}': unable to find subtasks of instructor task '{}': rejecting task {}"
msg = format_str.format(current_task_id, entry, new_subtask_status) msg = format_str.format(current_task_id, entry, new_subtask_status)
TASK_LOG.warning(msg) TASK_LOG.warning(msg)
dog_stats_api.increment('instructor_task.subtask.duplicate.nosubtasks', tags=[entry.course_id])
raise DuplicateTaskException(msg) raise DuplicateTaskException(msg)
# Confirm that the InstructorTask knows about this particular subtask. # Confirm that the InstructorTask knows about this particular subtask.
...@@ -370,6 +372,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): ...@@ -370,6 +372,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
format_str = "Unexpected task_id '{}': unable to find status for subtask of instructor task '{}': rejecting task {}" format_str = "Unexpected task_id '{}': unable to find status for subtask of instructor task '{}': rejecting task {}"
msg = format_str.format(current_task_id, entry, new_subtask_status) msg = format_str.format(current_task_id, entry, new_subtask_status)
TASK_LOG.warning(msg) TASK_LOG.warning(msg)
dog_stats_api.increment('instructor_task.subtask.duplicate.unknown', tags=[entry.course_id])
raise DuplicateTaskException(msg) raise DuplicateTaskException(msg)
# Confirm that the InstructorTask doesn't think that this subtask has already been # Confirm that the InstructorTask doesn't think that this subtask has already been
...@@ -380,6 +383,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): ...@@ -380,6 +383,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
format_str = "Unexpected task_id '{}': already completed - status {} for subtask of instructor task '{}': rejecting task {}" format_str = "Unexpected task_id '{}': already completed - status {} for subtask of instructor task '{}': rejecting task {}"
msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status) msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status)
TASK_LOG.warning(msg) TASK_LOG.warning(msg)
dog_stats_api.increment('instructor_task.subtask.duplicate.completed', tags=[entry.course_id])
raise DuplicateTaskException(msg) raise DuplicateTaskException(msg)
# Confirm that the InstructorTask doesn't think that this subtask is already being # Confirm that the InstructorTask doesn't think that this subtask is already being
...@@ -393,6 +397,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): ...@@ -393,6 +397,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
format_str = "Unexpected task_id '{}': already retried - status {} for subtask of instructor task '{}': rejecting task {}" format_str = "Unexpected task_id '{}': already retried - status {} for subtask of instructor task '{}': rejecting task {}"
msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status) msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status)
TASK_LOG.warning(msg) TASK_LOG.warning(msg)
dog_stats_api.increment('instructor_task.subtask.duplicate.retried', tags=[entry.course_id])
raise DuplicateTaskException(msg) raise DuplicateTaskException(msg)
# Now we are ready to start working on this. Try to lock it. # Now we are ready to start working on this. Try to lock it.
...@@ -402,6 +407,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): ...@@ -402,6 +407,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
format_str = "Unexpected task_id '{}': already being executed - for subtask of instructor task '{}'" format_str = "Unexpected task_id '{}': already being executed - for subtask of instructor task '{}'"
msg = format_str.format(current_task_id, entry) msg = format_str.format(current_task_id, entry)
TASK_LOG.warning(msg) TASK_LOG.warning(msg)
dog_stats_api.increment('instructor_task.subtask.duplicate.locked', tags=[entry.course_id])
raise DuplicateTaskException(msg) raise DuplicateTaskException(msg)
...@@ -494,6 +500,7 @@ def update_subtask_status(entry_id, current_task_id, new_subtask_status): ...@@ -494,6 +500,7 @@ def update_subtask_status(entry_id, current_task_id, new_subtask_status):
except Exception: except Exception:
TASK_LOG.exception("Unexpected error while updating InstructorTask.") TASK_LOG.exception("Unexpected error while updating InstructorTask.")
transaction.rollback() transaction.rollback()
dog_stats_api.increment('instructor_task.subtask.update_exception', tags=[entry.course_id])
raise raise
else: else:
TASK_LOG.debug("about to commit....") TASK_LOG.debug("about to commit....")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment