# What are the possibilities to inject more than distributed trace header in the tracers using inject in Elastic RUM agent

**URL:** <https://discuss.elastic.co/t/what-are-the-possibilities-to-inject-more-than-distributed-trace-header-in-the-tracers-using-inject-in-elastic-rum-agent/250098>\
**Category:** APM\
**Tags:** rum\
**Created:** [September 27, 2020, 5:18pm UTC](https://discuss.elastic.co/t/what-are-the-possibilities-to-inject-more-than-distributed-trace-header-in-the-tracers-using-inject-in-elastic-rum-agent/250098 "2020-09-27T17:18:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rejitha1](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rejitha1](https://discuss.elastic.co/u/rejitha1)\
**Post date:** [September 27, 2020, 5:18pm UTC](https://discuss.elastic.co/t/what-are-the-possibilities-to-inject-more-than-distributed-trace-header-in-the-tracers-using-inject-in-elastic-rum-agent/250098/1 "2020-09-27T17:18:32Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

TIP 1: select at least one tag that further categorizes your topic. For example `server` for APM Server related questions, `java` for questions regarding the Elastic APM Java agent, or `ui` for questions about the APM App within Kibana.

TIP 2: Check out the [troubleshooting guide](https://www.elastic.co/guide/en/apm/get-started/current/troubleshooting.html) first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.

**Kibana version** : 7.9.0

**Elasticsearch version** :7.9.0

**APM Server version** :7.9.0

**APM Agent language and version** : RUM /6.4.1

**Browser version** : chrome Version 85.0.4183.121

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: Docker containers on windows 10

**Fresh install or upgraded from other version?** Fresh install

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

Is it possible to inject a span context other than distributed trace header in Elastic rum.As currently for both the supported formats :  
FORMAT\_TEXT\_MAP  
FORMAT\_HTTP\_HEADERS  
only header information can be injected.  
I have a situation where some actions are added to a queue in one component and at a later time the items are pulled from the queue by another component and perform the action mentioned in the item.But logically they are part of one complete transaction.I am not sure what is the best way to create single transaction for this whole flow.  
If we can inject a context while starting a span on adding the request to queue and later extract the context from the trace using a GUID and connect the spans then the whole span will appear under one transaction(I think).

Please let me know if there is a better approach for this scenario.

Regards,  
Rejitha Raj

---

<div class="post-metadata">

**Author:** ![rejitha1](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rejitha1](https://discuss.elastic.co/u/rejitha1)\
**Post date:** [September 29, 2020, 2:09pm UTC](https://discuss.elastic.co/t/what-are-the-possibilities-to-inject-more-than-distributed-trace-header-in-the-tracers-using-inject-in-elastic-rum-agent/250098/2 "2020-09-29T14:09:22Z")

</div>

Is there no way to solve this issue as the custom transaction ends after the first entry in the queue .

---

<div class="post-metadata">

**Author:** ![Emanuil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuil/32/36783_2.png) [@Emanuil](https://discuss.elastic.co/u/Emanuil)\
**Post date:** [October 5, 2020, 1:59pm UTC](https://discuss.elastic.co/t/what-are-the-possibilities-to-inject-more-than-distributed-trace-header-in-the-tracers-using-inject-in-elastic-rum-agent/250098/3 "2020-10-05T13:59:54Z")

</div>

> [@rejitha1](#):
>
> using a GUID

Isn't that what the Trace ID is?

> [@rejitha1](#):
>
> connect the spans then the whole span will appear under one transaction

Multiple spans will appear under one trace. A transaction is simply one service answering a request. It could call another service as part of its work, and this would be a second transaction. Those transactions can have multiple spans. They are grouped together into one Trace via the Trace ID in the headers.

It sounds like the request is received by a web component and that triggers a background job of some kind. Various backend clients do support background jobs via custom transaction types (other than "request"). See [this public demo](https://demo.elastic.co/app/apm#/services/opbeans-node/transactions?rangeFrom=now-2d&rangeTo=now&transactionType=Worker) for example. Try switching the transaction type in the top left from "request" to "Worker" and you'll see what I mean. This is a demo of the APM Node.js agent, the instructions to do something like this yourself are [here](https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html). To begin with, you may want to monitor the requests and background jobs separately, this is what most people do.

Now, if you really wanted to track all spans under one trace, you _may_ be able to do that.

> [@rejitha1](#):
>
> the custom transaction ends after the first entry

So you're already tracking the request as it comes in. By also instrumenting your backend, you could use a custom transaction, but set the request type to "request". You're pretending the background job processing is actually a standard web request. Make sure to pass the trace ID from the RUM agent to your background job processor and set it on the back-end transaction too. Then, the spans from your job processor should appear under the spans your web server performs.

---

<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:** [October 26, 2020, 9:59am UTC](https://discuss.elastic.co/t/what-are-the-possibilities-to-inject-more-than-distributed-trace-header-in-the-tracers-using-inject-in-elastic-rum-agent/250098/4 "2020-10-26T09:59:54Z")

</div>

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