
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 = 'tasks.{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):
                return func(*args, **kwargs)
        return task(name=name, queue=queue, **kwargs)(func)
    return wrapped


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):
                return func(*args, **kwargs)
        return task(name=name, queue=queue, **kwargs)(func)
    return wrapped

Change tasks key prefix to jobs.duration
Change tasks key prefix to jobs.duration

  
  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 = 'tasks.{name}'.format(name=name)
+     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):
                  return func(*args, **kwargs)
          return task(name=name, queue=queue, **kwargs)(func)
      return wrapped
  
Change tasks key prefix to jobs.duration
## Code Before:

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 = 'tasks.{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):
                return func(*args, **kwargs)
        return task(name=name, queue=queue, **kwargs)(func)
    return wrapped

## Instruction:
Change tasks key prefix to jobs.duration
## Code After:

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):
                return func(*args, **kwargs)
        return task(name=name, queue=queue, **kwargs)(func)
    return wrapped
