# APM Transaction - CUSTOM Tab

**URL:** <https://discuss.elastic.co/t/apm-transaction-custom-tab/173395>\
**Category:** APM\
**Created:** [March 21, 2019, 8:24pm UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395 "2019-03-21T20:24:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zenith](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zenith](https://discuss.elastic.co/u/zenith)\
**Post date:** [March 21, 2019, 8:24pm UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/1 "2019-03-21T20:24:58Z")

</div>

Hello,

We are using APM to monitor our java application performance. We want to populate few additional attributes for a Transaction such that it appears in the CUSTOM tab? (we already populate tags)

Can you please let us know if the java api supports this?

 ![apm_custom_tab](https://us1.discourse-cdn.com/elastic/original/3X/7/5/757bc64571b9d46a82dbc7216d3e4032817ec0e5.png)

![apm_tag_tab](https://us1.discourse-cdn.com/elastic/original/3X/6/c/6c27ce84a1754aeea41074a90c49dc366fce0923.png)

Thanks,  
Zenith

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [March 22, 2019, 7:55am UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/2 "2019-03-22T07:55:35Z")

</div>

Hi and thanks for your question.

We currently have some [ongoing discussions](https://github.com/elastic/apm/issues/7) whether we should deprecate custom context. That's why it's not added to the Java agent.

Could you explain why you feel the need of adding custom context? Why are tags not enough in your case? What does the data look like that you want to add to custom?

Thanks,  
Felix

---

<div class="post-metadata">

**Author:** ![zenith](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zenith](https://discuss.elastic.co/u/zenith)\
**Post date:** [March 22, 2019, 6:35pm UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/3 "2019-03-22T18:35:47Z")

</div>

Hi Felix,

Thank you for the response. We are having multiple JVM running across multiple servers. A single transaction starts and ends from a , b and c servers. (Mostyly, each is one after the other. sometimes a transaction within the other but in different JVM).

We have created the transaction with the same name for all three. In APM dashboard, we see all the transaction in their respective dashboard. we want to see all the transaction from the three different servers into single timeline. As metioned in the below link we used the same transaction name:

```
`https://www.elastic.co/guide/en/kibana/current/traces.html`

```

we are using elastic-apm-agent-1.4.0.jar

Thank you for your help.

Thanks,  
Zenith

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [March 24, 2019, 8:14am UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/4 "2019-03-24T08:14:58Z")

</div>

Hi,

I will be happy to try and assist, but I am not sure I understand your setup properly. Are a, b and c instances of the same service? Or are traces go through some of them for handling same requests (eg a is front tier that uses b and c for backend service)?

Thanks,  
Eyal.

---

<div class="post-metadata">

**Author:** ![zenith](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zenith](https://discuss.elastic.co/u/zenith)\
**Post date:** [March 24, 2019, 6:06pm UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/5 "2019-03-24T18:06:50Z")

</div>

We have a UI service and a backend service running in two different servers. A Transaction is created in UI layer. also in the backend layer with the same transaction name and using the UI transaction's traceId and parentId as below:

> Blockquote  
> if (parentId != null && traceId != null) {  
> String value = String.format(HEADER\_FORMAT, traceId, parentId);  
> transaction = ElasticApm.startTransactionWithRemoteParent(new HeaderExtractor() {  
> @Override  
> public String getFirstHeader(String headerName) {  
> return value;  
> }  
> });  
> } else {  
> transaction = ElasticApm.startTransaction();  
> }

> Blockquote

we want to see the distributed tracing for these two transaction created in two different services.

Thanks,  
Zenith

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [March 25, 2019, 7:47am UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/6 "2019-03-25T07:47:23Z")

</div>

The **Transaction** names in front and backend tier would typically be different as they need to reflect the specific event they are handling. A **Trace** will combine them together for the distributed tracing part. For more information, you can read about [the data model](https://www.elastic.co/guide/en/apm/get-started/current/apm-data-model.html) we rely on.

I can't see your entire code, but it seems you are making a wrong use of the distributed tracing API- you normally shouldn't format the header string yourself, but rather get it through the communication layer. This code shows the usage of [the `startTransactionWithRemoteParent` API](https://www.elastic.co/guide/en/apm/agent/java/master/public-api.html#api-start-transaction-with-remote-parent-header) on the receiver side, but on the sender side, you should use [the `injectTraceHeader` API](https://www.elastic.co/guide/en/apm/agent/java/master/public-api.html#api-span-inject-trace-headers), which formats the right header to send through the communication protocol. Go through the documentation I linked above as it was updated with broader examples.

Just out of curiosity, what type of communication do you use between the front and back tiers?

---

<div class="post-metadata">

**Author:** ![zenith](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zenith](https://discuss.elastic.co/u/zenith)\
**Post date:** [March 25, 2019, 12:35pm UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/7 "2019-03-25T12:35:17Z")

</div>

Thank you Eyal.

We are using thrift call between services hence we do not have http request. i came across the above code sample. I noticed traceId is being used, hence i created the headerExtractor object using the traceId and parentId from the existing transaction which was already created in the different service.

private static final String HEADER\_FORMAT = "00-%s-%s-01";  
String parentId = existingTransaction.ensureParentId()  
String traceId = existingTransaction.getTraceId()  
String value = String.format(HEADER\_FORMAT, traceId, parentId);  
transaction = ElasticApm.startTransactionWithRemoteParent(new HeaderExtractor() {  
@Override  
public String getFirstHeader(String headerName) {  
return value;  
}  
});  
i see in the apm transactions were created with the traceId and same parentId as expected.

Thanks fro haring the documentation. will take a look at it.

 ![apm_traceId](https://us1.discourse-cdn.com/elastic/original/3X/e/c/eca058700eae18abd725962619b391efe4341ed7.png)

{  
"\_index": "apm-6.6.1-2019.03.24",  
"\_type": "doc",  
"\_id": "OmS6rWkBOuTYrgln7xUd",  
"\_version": 1,  
"\_score": null,  
"\_source": {  
"parent": {  
"id": "b7ad6b7169203331"  
},  
"trace": {  
"id": "0af7651916cd43dd8448eb211c80319c"  
},  
"@timestamp": "2019-03-24T03:24:58.666Z",  
"host": {  
"name": "XXXXXXXXX"  
},  
"beat": {  
"hostname": "XXXXXXXXXX",  
"name": "XXXXXXXXXX",  
"version": "6.6.1"  
},  
"context

.....  
....  
...  
"highlight": {  
"trace.id": [  
"@kibana-highlighted-field@0af7651916cd43dd8448eb211c80319c@/kibana-highlighted-field@"  
]  
},  
"sort": [  
1553397898666  
]  
}

---

<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:** [April 22, 2019, 12:35pm UTC](https://discuss.elastic.co/t/apm-transaction-custom-tab/173395/8 "2019-04-22T12:35:20Z")

</div>

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