# APM shared field name between RUM and Java agent

**URL:** <https://discuss.elastic.co/t/apm-shared-field-name-between-rum-and-java-agent/320820>\
**Category:** APM\
**Tags:** java, rum\
**Created:** [December 8, 2022, 6:36pm UTC](https://discuss.elastic.co/t/apm-shared-field-name-between-rum-and-java-agent/320820 "2022-12-08T18:36:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gigaset](https://avatars.discourse-cdn.com/v4/letter/g/85f322/32.png) [@gigaset](https://discuss.elastic.co/u/gigaset)\
**Post date:** [December 8, 2022, 6:36pm UTC](https://discuss.elastic.co/t/apm-shared-field-name-between-rum-and-java-agent/320820/1 "2022-12-08T18:36:58Z")

</div>

Hi,

We have implemented RUM in our React-based frontend and Java APM agents in the backend. We can see that the APM server in the "Service Map" makes correlations between the calls.

However, during the investigations, I cannot trace users' actions from the frontend through all backend services using the individual documents in the "Discover". I cannot find a single field which is shared between them. I see in the ECS docs that you have a `session.id` field, but it's never populated. I've looked at the `transaction.id`, `trace.id` and `parent.id` fields, but these are more or less unique.

How can the APM server show those correlations in the "Service Map", and how to replicate manually in the "Discover"? Also, is there a way to share fields like `user.email` or `user.name` between RUM and Java agents, so that each document from all affected services would show it?

Elastic Cloud version: 7.16.1, tier: Platinum  
Rum-JS version: 5.12.0  
Java Agent version: 1.32.0

---

<div class="post-metadata">

**Author:** ![Alberto\_Delgado](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alberto_delgado/32/98488_2.png) [@Alberto\_Delgado](https://discuss.elastic.co/u/Alberto_Delgado)\
**Post date:** [December 12, 2022, 3:29pm UTC](https://discuss.elastic.co/t/apm-shared-field-name-between-rum-and-java-agent/320820/2 "2022-12-12T15:29:48Z")

</div>

Hi @gigaset,

Thanks for reaching out!

First of all, apologies for the delay.

> However, during the investigations, I cannot trace users' actions from the frontend through all backend services using the individual documents in the "Discover". I cannot find a single field which is shared between them.

When you say "users' actions" do you mean [user clicks](https://www.elastic.co/guide/en/apm/agent/rum-js/5.x/supported-technologies.html#user-interactions)?

Imagine the following scenario:

Setup:  
Frontend side: RUM agent  
Backend side: Java APM agent (for the demo I used a node.js backend btw)

- user performs a click on a button.
- the click triggers a network request to the backend service

As you mentioned, you should see the "Service Map" making the correlation. Something like this:

 ![Screenshot 2022-12-12 at 15.43.02](https://us1.discourse-cdn.com/elastic/original/3X/5/f/5f9cc71ba90130f3f7ea4352ac6c6fa427e52ab1.png)

You can see the name of the service corresponding to my RUM agent (distributed-tracing-client-3) and the name of the service corresponding to my APM backend agent (distributed-tracing-node-js-3)

We can see this correlation on the APM UI waterfall, too:

1. I have filtered out by "user-interaction" transactions type

 ![Screenshot 2022-12-12 at 15.47.14](https://us1.discourse-cdn.com/elastic/original/3X/2/7/278175ec1c0f7bf713c5f5c54f96288a8c73fab0.png)

1. On the waterfall you can see the two services involved:
  - green lines belong to RUM agent
  - blue line belongs to APM backend agent

You can see the legend above the lines, where it says "Services"

 ![Screenshot 2022-12-12 at 15.48.27](https://us1.discourse-cdn.com/elastic/original/3X/1/7/1788e0b128534f77dacdc897353e32d922ba3677.png)

If you click any of these 3 lines you will be able to see the field **trace.id** on the metadata information. The 3 of them will have the very same **trace.id**

 ![Screenshot 2022-12-12 at 15.52.39](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a70c63275d0239242d4aa0ff88bda7ff057d644a.png)

If you want to see the events related to such **trace.id** via discover you could do what you can see in the screenshot above:

1. Get the **trace.id** from the metadata info
2. Filters docs by such trace.id

Make sure you have set the proper timeline otherwise you will not find the events you are looking for.

 ![Screenshot 2022-12-12 at 15.55.11](https://us1.discourse-cdn.com/elastic/original/3X/2/2/2242801879cb18d766889afc4979d946325d18b4.jpeg)

Let me know if this helps you.

Btw, and just in case I misunderstood, we don't support User Sessions. So, if you are looking for a unique id that groups all the actions triggered by a user in the lifespan of their session it's not yet possible OOTB. It's one of our top priorities. You could generate your own ID and attach it to all the transactions via [addLabels](https://www.elastic.co/guide/en/apm/agent/rum-js/current/agent-api.html#apm-add-labels).

--

> Also, is there a way to share fields like `user.email` or `user.name` between RUM and Java agents, so that each document from all affected services would show it?

Both agents will behave separately, you would need to set the user context for the two agents:

- [RUM](https://www.elastic.co/guide/en/apm/agent/rum-js/5.x/agent-api.html#apm-set-user-context)
- [Java](https://www.elastic.co/guide/en/apm/agent/java/1.x/public-api.html#api-transaction-set-user)

If you want both agents to have the same user, you might need to send the frontend username/email via the request you perform to your servers and then set there the setUser dynamically

Thanks,  
Alberto

---

<div class="post-metadata">

**Author:** ![gigaset](https://avatars.discourse-cdn.com/v4/letter/g/85f322/32.png) [@gigaset](https://discuss.elastic.co/u/gigaset)\
**Post date:** [December 13, 2022, 4:18pm UTC](https://discuss.elastic.co/t/apm-shared-field-name-between-rum-and-java-agent/320820/3 "2022-12-13T16:18:48Z")

</div>

Hi,

That is an excellent explanation. We already implemented the `session.id` in RUM using `labels`, and need to investigate sharing this field between the agents.

Thanks  
Les

---

<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:** [January 3, 2023, 12:19pm UTC](https://discuss.elastic.co/t/apm-shared-field-name-between-rum-and-java-agent/320820/4 "2023-01-03T12:19:19Z")

</div>

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