"""
sentry.tasks.base
~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from celery.task import task
from django_statsd.clients import statsd
from functools import wraps


def instrumented_task(name, queue, stat_suffix=None, **kwargs):
    statsd_key = 'jobs.duration.{name}'.format(name=name)
    if stat_suffix:
        statsd_key += '.{key}'.format(key=stat_suffix)

    def wrapped(func):
        @wraps(func)
        def _wrapped(*args, **kwargs):
            with statsd.timer(statsd_key):
                result = func(*args, **kwargs)
            return result
        return task(name=name, queue=queue, **kwargs)(_wrapped)
    return wrapped

@@ -320,24 +320,115 @@
  **kwargs):%0A
+    def wrapped(func):%0A        @wraps(func)%0A        def _wrapped(*args, **kwargs):%0A        
     statsd_k
@@ -473,16 +473,24 @@
 e=name)%0A
+        
     if s
@@ -501,16 +501,24 @@
 suffix:%0A
+        
         
@@ -566,75 +566,8 @@
 ffix
-)%0A%0A    def wrapped(func):%0A        @wraps(func)%0A        def _wrapped
 (*ar
@@ -571,33 +571,33 @@
 *args, **kwargs)
-:
+)
 %0A            wit

Fix stat_suffix