sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Celery `app.send_task()` doesn't propagate trace

Open divaltor opened this issue 2 years ago • 3 comments

How do you use Sentry?

Self-hosted/on-premise

Version

1.30.0

Steps to Reproduce

I execute tasks via app.send_task(<task_name>, kwarsg={...}) (where app is Celery() instance) because it's simpler for me and my case (I have a lot of circular errors if use tasks directly) and it seems that Sentry doesn't wrap this method hence there is no attached trace for tasks

Expected Result

I see every trace starting from front-end -> back-end -> queue tasks

Actual Result

image

divaltor avatar Sep 14 '23 13:09 divaltor

Hey @Divaltor ! Thanks for writting in. In deed, we do not propagate traces when using send_task() right now. We need to update the Celery integration for supporting this. I put in our internal backlog (but this will take some time because we have a lot of things on our plates right now)

antonpirker avatar Sep 15 '23 07:09 antonpirker

Hi guys, any update on this topic? I have FastAPI based service and separate Celery service. FastAPI knows only task names and required args, it doesn't have access to Celery task src, so I just can't apply_async them. Elastic-APM provides possibility to use specific header to bind traces, do you have something similar in Sentry? Of course, it would be awesome to get everything ready-2-go out from the box, without headers manipulations, but for now it would be just fine.

Dogrtt avatar Jan 21 '24 10:01 Dogrtt

Hey @Dogrtt, @divaltor submitted a PR to make this work so this could soon be part of the out of the box SDK experience -- in the meantime, you could try forwarding the sentry-trace and baggage headers to the task.

sentrivana avatar Jan 24 '24 12:01 sentrivana