Autoinstrument and transaction handling logic

Hi,

We were trying the autoinstrument feature and we experienced the following behavior with the RUM JS library:

When autoinstrumentation detects an AJAX call, it creates a task (an internal object that represents the task of creating a span for that event), and adds it to a task list.
If another AJAX call is detected before the previous task is completed, it creates a new task and adds it to the list.
When a task is completed, is removed from the tasks list, and the execution continues with the next task in the list.
If the tasks list is empty, the current transaction is closed, and subsequent calls are not sent to the APM server.

We are using version 4.4.4.

We are wondering if there is a way to have autoinstrument to automatically create spans but not closing the transaction when all then but leave the control to the user to finish the transaction manually.

Thanks in advance.

Hi Ignacio,

We have changed the auto instrumentation logic a bit in our latest version and the users of the library would be able to tune the transaction according to the needs (PR Link - https://github.com/elastic/apm-agent-rum-js/pull/440) and its released as part of version @elastic/apm-rum@4.5.0 https://github.com/elastic/apm-agent-rum-js/blob/master/CHANGELOG.md#450-2019-09-30.

We are working on docs at the moment. Let us know if this works for you.

But as a interim solution if you want to hold the transaction for any specific needs, you can add a task manually and end the transaction when needed.

const tr = agent.getCurrentTransaction();
const id = tr.addTask('hold-tr');

// forcefully end it later somewhere.
tr.end()

// or you can remove task which would trigger our internal closing logic
tr.removeTask(id)

Thanks,
Vignesh

1 Like

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