Closed
Description
openedon Oct 13, 2021
Our code currently loads APM RUM
to create app based transactions.
When the apm-rum
init
function is called, it internally creates a page-load
transaction. However, due to the way our code is structured, the duration of this transaction is just an arbitrary number (time of loading bootstrap
+ some extra processing) and it does not accurately reflect our real load time.
This is a rough diagram of the current page-load
event:
After chatting with @vigneshshanmugam, we have come up with a way to patch this behavior.
If it is found useful, @elastic/apm-agent-rum might improve their API at some point.
The steps for the patch are:
- Immediately after initializing
apm
by callinginit
(inapm_system.ts
), get the current transaction and prevent it from closing by callingpageLoadTransaction.block(true)
(docs). This shouldn't normally happen, but if the transaction is undefined or it's type is notpage-load
we should report an error (where to?). - Right after, add a marker (
transaction.mark
) calledapm-setup
to thepage-load
transaction. - Inside the
start
function, add another marker calledapm-start
. - When about to start a new
route-change
transaction for the first time, close thepage-load
transaction explicitly by callingpageLoadTransaction.block(false)
.
The result would be a more accurate page load event that can be used to measure our actual load time:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment