# Javascript APM agent pass message with transaction

**URL:** https://discuss.elastic.co/t/javascript-apm-agent-pass-message-with-transaction/151468
**Category:** APM
**Created:** [October 8, 2018, 1:59pm UTC](https://discuss.elastic.co/t/javascript-apm-agent-pass-message-with-transaction/151468 "2018-10-08T13:59:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![KMSundar](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@KMSundar](https://discuss.elastic.co/u/KMSundar)
#### Post date: [October 8, 2018, 1:59pm UTC](https://discuss.elastic.co/t/javascript-apm-agent-pass-message-with-transaction/151468/1 "2018-10-08T13:59:49Z")

</div>

I'm using Javascript APM agent, I need to sent my report information to APM server. I want to sent below messages with two transactions with different customContext message. Actually what it happend is customContext message is same for two transactions. Could you please suggest , any other logics availble for this scenrio.

```
message = [{"name": "abc"}, {"name": xyz}]
apm = InitApm.init({
    'serviceName': serviceName,
    'serverUrl': serverUrl
});
for (msg in message) {
	name = 'transaction-name' + msg.name;
	transaction = apm.startTransaction(transactionName, 'custom');
    httpSpan = transaction.startSpan(null, null);
    apm.setCustomContext(msg);
    httpSpan.end();
    transaction.end();
}
```

---

<div class="post-metadata">

### Author: ![Hamidreza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamidreza/32/21369_2.png) [@Hamidreza](https://discuss.elastic.co/u/Hamidreza)
#### Post date: [October 9, 2018, 7:40am UTC](https://discuss.elastic.co/t/javascript-apm-agent-pass-message-with-transaction/151468/2 "2018-10-09T07:40:10Z")

</div>

Hi,

Thanks for your interest in Elastic APM.  
The `apm.setCustomContext` sets the global custom context that will be included in every transaction and error. Currently we don't support setting context on individual transactions, I have created [this issue](https://github.com/elastic/apm-agent-js-base/issues/65) to keep track of this feature request. Please feel free to make comments on the issue.

Cheers,  
Hamid

---

<div class="post-metadata">

### Author: ![KMSundar](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@KMSundar](https://discuss.elastic.co/u/KMSundar)
#### Post date: [October 10, 2018, 6:56am UTC](https://discuss.elastic.co/t/javascript-apm-agent-pass-message-with-transaction/151468/3 "2018-10-10T06:56:19Z")

</div>

Thank you for your reply.

---

<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 31, 2018, 2:56am UTC](https://discuss.elastic.co/t/javascript-apm-agent-pass-message-with-transaction/151468/4 "2018-10-31T02:56:22Z")

</div>

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