# Custom Transactions no longer detect external.http spans automatically

**URL:** <https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702>\
**Category:** APM\
**Tags:** rum\
**Created:** [October 8, 2019, 4:45pm UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702 "2019-10-08T16:45:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 8, 2019, 4:45pm UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/1 "2019-10-08T16:45:59Z")

</div>

I am upgrading my JS agent from 3.0.0 to 4.5.0 and the custom transactions I had already implemented no longer work. I have an angular app so I am using angular-rum 0.2.0.

I have enabled debug mode so I can see it is detecting external.http spans but somehow not including them in the customs transaction I created.

Can anyone say what I am doing wrong?

Here is an example:

TransactionService.startTransaction Transaction {name: "XXX", .....}  
logging-service.js:56 TransactionService.startSpan POST [http://localhost:8080/XXX](http://localhost:8080/XXX) external.http  
logging-service.js:56 TransactionService.addTask task1  
logging-service.js:56 TransactionService.removeTask task1  
logging-service.js:56 TransactionService.startSpan GET [http://localhost:8080/YYY](http://localhost:8080/YYY) external.http  
logging-service.js:56 TransactionService.addTask task1  
logging-service.js:56 TransactionService.removeTask task1  
logging-service.js:56 TransactionService transaction finished Transaction {name: "XXX",...}  
logging-service.js:56 Transaction was discarded! Transaction does not include any spans  
logging-service.js:56 Could not create a payload from the Transaction Transaction {name: "XXX",...}  
logging-service.js:56 TransactionService.add Transaction {name: "XXX",...}

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [October 9, 2019, 8:37am UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/2 "2019-10-09T08:37:32Z")

</div>

Hi Kartheek,

Agent 3.x and 4.5 differs in a way how managed(automatic instrumentation) and custom transactions works. There can be only 1 active managed transaction at a time and can be multiple custom transactions. If you are creating custom transactions, you would need to explicitly add spans to that transactions since all automatic instrumented spans would get added to the managed transactions. An example would be

```auto
const tr = apm.startTransaction('my-custom-tr', 'custom');

const span = tr.startSpan('ex-function');
(function expensiveFunction() {
// code
})()
span.end();
tr.end()

```

The transaction `tr` would only contain the `ex-function` span and would not include any XHR or resource timing spans captured during the transaction time frame.

From the logs, I see that the transaction `XXX` does not include any spans and therefore discarded. Could you please paste a snippet of code on whether the custom transaction contains any spans and you can also check if there an active transaction by calling `apm.getCurrentTransaction()`.

The logging needs a bit of work and I will create an issue in the RUM repo to address it which would clear any confusion.

Thanks,  
Vignesh

---

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 10, 2019, 12:47am UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/3 "2019-10-10T00:47:11Z")

</div>

In my code I do not create a span explicitly. I was relying on the agent to automatically pick the spans that occurred after a transaction was created.

Once I use the startSpan method I can see the spans but that makes the thing we want to track harder since its not automatically tracked anymore. That was definitely a useful feature.

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [October 21, 2019, 8:53am UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/4 "2019-10-21T08:53:33Z")

</div>

If you are creating the transaction through custom API, you can use the managed option in the API so that the custom transaction becomes managed one and all automatically instrumented spans would be added to them.

```auto
apm.startTransaction('custom', 'custom', {
    managed: true
})

```

Thanks,  
Vignesh

---

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 29, 2019, 10:04pm UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/5 "2019-10-29T22:04:56Z")

</div>

That sounds good. I will give it a try.

---

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 30, 2019, 12:26am UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/6 "2019-10-30T00:26:34Z")

</div>

@vigneshshanmugam - Do you know what version of the JS agent the custom API will be available? I am using 4.5.0 and I don't see an option to send in a 3rd parameter.

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [October 30, 2019, 9:13am UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/7 "2019-10-30T09:13:59Z")

</div>

@Kartheek_Mannepalli Its available from `4.5.0`, Check the changelog [https://github.com/elastic/apm-agent-rum-js/blob/master/CHANGELOG.md#450-2019-09-30](https://github.com/elastic/apm-agent-rum-js/blob/master/CHANGELOG.md#450-2019-09-30)

Thanks,  
Vignesh

---

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [November 5, 2019, 11:04pm UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/8 "2019-11-05T23:04:25Z")

</div>

@vigneshshanmugam - Sorry I was looking at the wrong version. I will give this a try. Thanks.

---

<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:** [November 26, 2019, 7:04pm UTC](https://discuss.elastic.co/t/custom-transactions-no-longer-detect-external-http-spans-automatically/202702/9 "2019-11-26T19:04:29Z")

</div>

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