track celery task with django application

Hi all,
I am working on a web application that has celery tasks running on the background. I am using visual studio code and I want to track the celery task. any idea how to do that?
Thanks

One option is Flower - Celery monitoring tool — Flower 1.0.1 documentation for monitoring Celery.

Thank you very much, but I want to track the excution steps of one of the celery tasks. I want to see the value of the variables when code is being excuted like debugging but I couldn’t do debug to the celery task because it is running on the background. so any suggested approach please?

Hmm sorry I’m not sure on that hopefully someone else here may know.

The most straightforward approach is to use some form of remote debugger. The celery docs actually have a section specifically for this: Debugging — Celery 5.3.4 documentation
Other remote debuggers exist that would allow you to similarly set a trace point.

Another approach is to use the usual pdb.set_trace() but limit the task to be synchronous for the purposes of your test/debugging session. This also would be in local dev environment

  1. your settings should have CELERY_ALWAYS_EAGER=True
  2. open up a shell (i.e. python manage.py shell)
  3. import your task within the shell environment (from app.blah import TestTask)
  4. run the task and the pdb break point will be reached and execution will stop
  5. you can treat this like a usual debugging session from here.

The second approach is useful for simple testing and debugging. The first approach is a more accurate way since it mirrors a more realistic deployment environment.