# Distributed traces on background jobs

**URL:** <https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555>\
**Category:** APM\
**Tags:** ruby\
**Created:** [November 24, 2020, 6:08pm UTC](https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555 "2020-11-24T18:08:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brightredchilli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brightredchilli/32/79634_2.png) [@brightredchilli](https://discuss.elastic.co/u/brightredchilli)\
**Post date:** [November 24, 2020, 6:08pm UTC](https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555/1 "2020-11-24T18:08:48Z")

</div>

Hi, a question prodding feasability of getting distributed traces on asynchronous jobs. In my (Rails) application, web requests kick off background jobs that are processed in Sidekiq. I see the Sidekiq transaction and the request transaction separately in Kibana APM. I'd like to see them as a distributed trace, even though I know that the web transaction might end before the asynchronous job begins.

Does this make sense as a thing to do? Because and if so, might I be right in thinking that the Traceparent and TraceState need to somehow be passed over to the background job, and set on the transaction there?

---

<div class="post-metadata">

**Author:** ![mikker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikker/32/22118_2.png) [@mikker](https://discuss.elastic.co/u/mikker)\
**Post date:** [November 24, 2020, 7:25pm UTC](https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555/2 "2020-11-24T19:25:57Z")

</div>

Your idea makes a lot of sense! This is actually something we're currently investigating. No work yet on the agent but it's something we want to do.

Can't give you any dates or timelines though, sorry.

---

<div class="post-metadata">

**Author:** ![brightredchilli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brightredchilli/32/79634_2.png) [@brightredchilli](https://discuss.elastic.co/u/brightredchilli)\
**Post date:** [November 24, 2020, 8:29pm UTC](https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555/3 "2020-11-24T20:29:45Z")

</div>

Thanks for the confirmation. Could you give some high level pointers on what it might mean to get it implemented?

For the agent work, I imagine would be more generalized, but if we have a specific setup, say with rails and sidekiq, would passing additional parameters to the job(in particular traceparent and tracestate) work? Any thoughts on how one might serialize info like that to be passed over to sidekiq? Am I missing any other info that I need to pass?

---

<div class="post-metadata">

**Author:** ![Emily\_Stolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emily_stolfo/32/55017_2.png) [@Emily\_Stolfo](https://discuss.elastic.co/u/Emily_Stolfo)\
**Post date:** [November 25, 2020, 11:28am UTC](https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555/4 "2020-11-25T11:28:58Z")

</div>

We have a discussion in [a GitHub issue](https://github.com/elastic/apm/issues/122), if you'd like to follow it. Unfortunately, as Mikkel said, we don't have a timeline for it yet.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 16, 2020, 7:29am UTC](https://discuss.elastic.co/t/distributed-traces-on-background-jobs/256555/5 "2020-12-16T07:29:00Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
