Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Celery Task shadow_name Property #468

Open
andreangelucci opened this issue Mar 6, 2025 · 1 comment
Open

Add Celery Task shadow_name Property #468

andreangelucci opened this issue Mar 6, 2025 · 1 comment

Comments

@andreangelucci
Copy link

Celery tasks have a property called shadow_name that helps identify task execution in logs, as executions typically share the same task names.

After running a Celery task, we can monitor the execution with the TaskResult object. However, when there are multiple executions of the same task that differ only by their arguments, identification becomes challenging.

Would it be feasible to add a shadow_name property to the TaskResult model and enable filtering through Django admin? Alternatively, we could prioritize the shadow name as the task_name if it has been defined.

Shadow name example:

def shadow_name(task, args, kwargs, options):
    return f"sleep_{args[0]}_seconds"

@shared_task(name='sleep-example', shadow_name=shadow_name)
def sleep_example(seconds):
    sleep(seconds)

After running sleep_example.delay(15), we can see:

Image

Image

Image

Image

Image

Celery documentation:
https://docs.celeryq.dev/en/stable/reference/celery.app.task.html#celery.app.task.Task.shadow_name

@andreangelucci
Copy link
Author

I opened this draft PR representing the idea: #469
Feel free to share your opinions. If the draft makes sense, we can work on some unit tests.

There's another issue pointing to the same demand: #379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant