title: How to monitor Celery task completion with Prometheus
body: <p>I am trying to use Prometheus for monitoring Celery tasks for which I am relatively new and I have a problem with incrementing a counter. It's just not incrementing if I am trying to do it inside of <code>Celery.task</code></p>
  
  <p>E.g.</p>
  
  <pre><code>from celery import Celery
  from prometheus_client import Counter
  
  app = Celery('tasks', broker='redis://localhost')
  TASKS = Counter('tasks', 'Count of tasks')
  
  
  @app.task
  def add(x, y):
      TASKS.inc(1)
      return x + y
  </code></pre>
  
  <p>When I visit an endpoint to see which metrics are exposed I can see <code>tasks_total</code>, but its value doesn't change no matter how much <code>add</code> tasks have been executed. 
  However, when I am trying to increment the same counter from regular function, it works. </p>
  
  <p>E.g. </p>
  
  <pre><code>def dummy_add(x, y):
      TASKS.inc()
      return x + y
  </code></pre>
  
  <p>Could you please explain to me what I am doing wrong?</p>