You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have checked the issues list for similar or identical feature requests.
I have checked the pull requests list for existing proposed implementations of this feature.
I have checked the commit log to find out if the same feature was already implemented in the main branch.
I have included all related issues and possible duplicate issues in this issue.
Related Issues and Possible Duplicates
Related Issues
None
Possible Duplicates
None
Brief Summary
Currently, Celery uses UUID for task IDs which is hardcoded in the implementation. In distributed systems, we often need custom ID generation strategies (like Snowflake ID) for better tracing and debugging.
Design
Architectural Considerations
The change would only affect task ID generation in Celery core, with no external dependencies required.
Proposed Behavior
Add a configuration option task_id_generator that accepts a callable
If provided, use this callable instead of the default UUID generator
Maintain backward compatibility by using UUID as default when no custom generator is provided
After reviewing the current Celery implementation (basically send_task() in celery.app.base and celery.app.utils), its clear there is no clean way to globally override task ID generation today without few workarounds like manually passing task_id to each task or subclassing Task. After exploring the new Stamping API (from 5.3) is good for metadata and traceability, it does not serve the same purpose. Stamping while allowing additional fields like monitoring_id, but Celery's core task tracking (including results backend, retries, and monitoring tools like Flower) still depends on actual task_id.
After exploring I found out... why celery only supports UUIDs. UUIDs are safe defaults, simple, its immune to clock drift or backward time change issue. So uuids avoids most of the issues but if we want traceability, time-sortable task IDs (for logs, observability) adding a task_id_generator config could be a practical and low-risk improvement. But its necessary to choose the identifier wisely... immediate substitute to UUIDs could be ULIDs which solves the time and lexicologically ordered, have no clock drift issue and is also immune to backward time change... Snowflakes on the other hand are Globally unique, are time sortable but they could have clock issue...
I would like to contribute to implementing a task_id_generator configuration option in Celery, it could provide this flexibility while keeping UUIDs as the default. This change would be backward compatible and optional, it would be a safe enhancement for users with more advanced ID needs. Let me know your thoughts, would like to take this forward with PR if maintainers are open to it.
Great! I'll start a PR for adding task_id_generator as an optional config, defaulting to uuid like now... but can be overridden for stuff like custom identifiers... should be clean and backward compatible.
let me know if there's anything in particular you'd want me to watch out for, otherwise I'll push something soon.
Activity
Nusnus commentedon Apr 9, 2025
Check out the stamping feature:
https://docs.celeryq.dev/en/stable/userguide/canvas.html#stamping
jiisanda commentedon May 4, 2025
After reviewing the current Celery implementation (basically
send_task()incelery.app.baseandcelery.app.utils), its clear there is no clean way to globally override task ID generation today without few workarounds like manually passingtask_idto each task or subclassingTask. After exploring the new Stamping API (from 5.3) is good for metadata and traceability, it does not serve the same purpose. Stamping while allowing additional fields likemonitoring_id, but Celery's core task tracking (including results backend, retries, and monitoring tools like Flower) still depends on actualtask_id.After exploring I found out... why celery only supports UUIDs. UUIDs are safe defaults, simple, its immune to clock drift or backward time change issue. So uuids avoids most of the issues but if we want traceability, time-sortable task IDs (for logs, observability) adding a
task_id_generatorconfig could be a practical and low-risk improvement. But its necessary to choose the identifier wisely... immediate substitute to UUIDs could be ULIDs which solves the time and lexicologically ordered, have no clock drift issue and is also immune to backward time change... Snowflakes on the other hand are Globally unique, are time sortable but they could have clock issue...I would like to contribute to implementing a
task_id_generatorconfiguration option in Celery, it could provide this flexibility while keeping UUIDs as the default. This change would be backward compatible and optional, it would be a safe enhancement for users with more advanced ID needs. Let me know your thoughts, would like to take this forward with PR if maintainers are open to it.auvipy commentedon May 6, 2025
may be this could be an option....
jiisanda commentedon May 7, 2025
Great! I'll start a PR for adding
task_id_generatoras an optional config, defaulting to uuid like now... but can be overridden for stuff like custom identifiers... should be clean and backward compatible.let me know if there's anything in particular you'd want me to watch out for, otherwise I'll push something soon.
auvipy commentedon May 8, 2025
I want to see a draft PR first