celery / django-celery-results

Celery result back end with django
Other
668 stars 206 forks source link

task_name always null #362

Closed csirmazbendeguz closed 11 months ago

csirmazbendeguz commented 1 year ago

The task_name is always null, even if extended task results are enabled.

I checked the code and the request variable doesn't have a task field. I couldn't find where this field was supposed to be added in the Celery source code either.

Not sure if this is a bug or I'm missing something obvious.

https://github.com/celery/django-celery-results/blob/e840938d4bbf24771ecb6df43f196d7a01d50643/django_celery_results/backends/database.py#L95

My package versions are:

celery==5.2.7
django-celery-results==2.4.0

I also tried to install other versions of django-celery-results, but all of them tries to get the task name from the task field which is never set.

csirmazbendeguz commented 1 year ago

I'm trying to develop a monitoring app for our Celery tasks. Maybe there's an alternative way to do that? Cheers

csirmazbendeguz commented 1 year ago

https://github.com/celery/django-celery-results/issues/289 probably related

krukas commented 1 year ago

Had the same problem, its because of the option CELERY_RESULT_EXTENDED. This needs to be True. It is mentioned in the getting started https://django-celery-results.readthedocs.io/en/latest/getting_started.html. Only the readme is linked to the celery docs where this is not mentioned.

So its easy to miss, also in the docs its not clear that you need this for basic information like task name.

peterfarrell commented 1 year ago

This is the exact reason. Setting this will fix this issue.

Had the same problem, its because of the option CELERY_RESULT_EXTENDED. This needs to be True. It is mentioned in the getting started https://django-celery-results.readthedocs.io/en/latest/getting_started.html. Only the readme is linked to the celery docs where this is not mentioned.

csirmazbendeguz commented 1 year ago

I literally said The task_name is always null, even if extended task results are enabled. in the first sentence. The issue was with the eager mode.

auvipy commented 1 year ago

can you help to find out the root cause of the issue?

markddavidoff commented 11 months ago

@csirmazbendeguz @auvipy did you set CELERY_RESULT_EXTENDED?