Skip to main content

Timing and measurements

Custom measurement

Custom measurement allows you to send numeric data to Coralogix for precise monitoring and analysis.

CoralogixRum.sendCustomMeasurement('my-page-load', 1000);

Add timing

Add timing is a simple API to add extra performance timing to your RUM data.
The timing relates to the time between the page load and the moment the timing is added.
For example, you can add a timing for the first click event.

window.addEventListener('click', function handler() {
window.removeEventListener('click', handler);

CoralogixRum.addTiming('first-click');
});

OR

You can provide your own timing.

window.addEventListener('click', function handler() {
window.removeEventListener('click', handler);

CoralogixRum.addTiming('first-click', 1000);
});

Custom time measurement

Custom time measurement allows you to track the time between two points by starting a timer with startTimeMeasure and stopping it with endTimeMeasure, using a unique name to identify each measurement. Labels can be added at the start for additional context.

CoralogixRum.startTimeMeasure('login', {
paymentMethod: 'visa',
userTheme: 'dark',
});
CoralogixRum.endTimeMeasure('login');

A few behaviours worth knowing:

  • Starting a key while a measurement for it is still in progress does nothing, and neither does a blank key: startTimeMeasure returns and the running timer is left alone.
  • endTimeMeasure takes only the key, so there is no way to pass labels at the end. The object handed to startTimeMeasure is held by reference, and at the end it is merged over the SDK's global labels as they stand then - so a later CoralogixRum.setLabels() does affect the result.
  • Ending a measurement releases its key, so the same key can be measured again afterwards.
  • Open measurements are dropped the next time you start or end one while the session is idle. The check runs on those calls rather than on a timer, and activity clears the idle flag, so a measurement spanning a short idle gap may still report.
Last updated on
Was this page helpful?