Hi there, I'm a front-end developer with limited experience, therefore I'm a bit stuck at the moment.
I've applied Elastic RUM for the front-end (Angular) part of our single-page application. Our use case is to obtain performance metrics when users are traversing / clicking through the application. Unfortunately, because it is a single-page application, the user-centric metrics obtained during page-load don't suffice. We don't make use of the Angular router either.
From reading the documentation I figured I could use Custom Transactions to obtain user-centric metrics:
However, when attempting to use the code above an error is thrown, referring to { blocking: true } at line 4:
public createCustomEvent(data: eventData, event: string): void {
const transaction = apm.startTransaction(event, 'custom event', { managed: true });
if (transaction) {
const span = transaction.startSpan('async-task', 'app', { blocking: true })
if (span) {
setTimeout(() => {
span.end()
/**
* This would also end the managed transaction once all the blocking spans are completed and
* transaction would also contain other timing information and spans similar to auto
* instrumented transactions like `page-load` and `route-change`.
*/
}, 1000)
}
}
const url = 'URL_ADDRESS';
if (transaction) {
const httpSpan = transaction.startSpan('GET ' + url, 'external.http');
if (httpSpan) {
fetch(url)
.then((resp) => {
if (!resp.ok) {
apm.captureError(new Error(`fetch failed with status ${resp.status} ${resp.statusText}`));
}
apm.addLabels(this.convertToLabels(data));
httpSpan.end();
transaction.end();
});
}
}
}
This error is correct, because this is what the interface SpanOptions looks like:
interface SpanOptions {
/**
* undocumented, might be removed in future versions
*/
startTime?: number
sync: boolean
}
I tried replacing 'blocking' with 'sync', but this had no effect.
Am I on the right track here, or is it simply not possible to use Custom Transactions to obtain user-centric metrics?