Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Report counts of Tasks created by name.
Browse files Browse the repository at this point in the history
Summary: This is a cheap way to track task creation for monitoring.

Test Plan: Ran unit.

Reviewers: jukka

Reviewed By: jukka

Subscribers: changesbot, wwu

Differential Revision: https://tails.corp.dropbox.com/D94291
  • Loading branch information
kylec1 committed Mar 9, 2015
1 parent 81adbd7 commit 7fbf2ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion changes/queue/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from threading import local, Lock
from uuid import uuid4

from changes.config import db, queue
from changes.config import db, queue, statsreporter
from changes.constants import Result, Status
from changes.db.utils import get_or_create
from changes.models import Task
Expand Down Expand Up @@ -302,6 +302,9 @@ def delay_if_needed(self, **kwargs):
countdown=CONTINUE_COUNTDOWN,
)

if created:
self._report_created()

def delay(self, **kwargs):
"""
Enqueue this task.
Expand Down Expand Up @@ -335,6 +338,9 @@ def delay(self, **kwargs):

db.session.commit()

if created:
self._report_created()

queue.delay(
self.task_name,
kwargs=kwargs,
Expand Down Expand Up @@ -400,6 +406,10 @@ def verify_all_children(self):

return status

def _report_created(self):
"""Reports to monitoring that a new Task was created."""
statsreporter.stats().incr('new_task_created_' + self.task_name)


# bind to a decorator-like naming scheme
def tracked_task(func=None, **kwargs):
Expand Down

0 comments on commit 7fbf2ed

Please sign in to comment.