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

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 :slight_smile:

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 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

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

Isn't that what the Trace ID is?

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 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. 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.

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.

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