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
#10676 introduced a regression which causes the task_postrun signal to never be able to attach tags to a span when working with Celery canvases (chains, callbacks, chords etc).
When working with a chain for instance, the task always calls apply_async on its callback just before it finishes (before task_postrun is fired). With the changes introduced in #10676, the span is already finished at this point (and sent to the tracer), so adding new tags doesn't do anything, making the span degenerated.
Task.apply_async is invoked, but it's wrapped with _traced_apply_async_inner. Inside its finally block it sees that there's a prerun_span belonging to the worker span - therefore forcefully finishing it
task_postrun is fired, and tries to attach tags to the span, but at this point it's doomed, since the span has already finished.
All in all I would recommend to revert #10676 and come up with a better implementation, or at least to remove the task_postrun part of it, since it's utterly broken.
Thank you for the report and sorry for the behavior that the change had on your spans. The update was to fix a bug where we weren’t closing spans. I really appreciate the level of detail you provided on how to reproduce and your suggestion!
I will be taking a look to discuss with my team the best way to safely get the experience you’re looking for.
As a workaround - are you ok with pinning your version for now?
#10676 introduced a regression which causes the
task_postrun
signal to never be able to attach tags to a span when working with Celery canvases (chains, callbacks, chords etc).When working with a chain for instance, the task always calls
apply_async
on its callback just before it finishes (beforetask_postrun
is fired). With the changes introduced in #10676, the span is already finished at this point (and sent to the tracer), so adding new tags doesn't do anything, making the span degenerated.This means that the following happens:
task_prerun
is called, creating a new span, and registering it underprerun_span
Task.apply_async
is invoked, but it's wrapped with_traced_apply_async_inner
. Inside itsfinally
block it sees that there's aprerun_span
belonging to the worker span - therefore forcefully finishing ittask_postrun
is fired, and tries to attach tags to the span, but at this point it's doomed, since the span has already finished.All in all I would recommend to revert #10676 and come up with a better implementation, or at least to remove the
task_postrun
part of it, since it's utterly broken.Reproduce
tasks.py:
fire.py:
Run Celery with:
Then fire the chain with:
You'll see the following debug logs in the Celery worker:
And you'll see that the first span doesn't have any
celery.*
tags, for examplecelery.state
.The text was updated successfully, but these errors were encountered: