Description
We try to achieve faster response time for english translation files by using service workers fetch request hijack.
We are observing a significant discrepancy in response time measurements for certain requests between Chrome DevTools and DataDog RUM. Our implementation uses a service worker to handle i18n translation files. For the English version (en-US), our service worker returns a synthesized empty JSON object, resulting in nearly instantaneous fetch times (∼1ms) as observed in Chrome DevTools' Network tab.
However, in DataDog RUM explorer, these same responses are being reported with latencies around 60ms. We believe the additional time may be due to aspects such as Instrumentation or processing delays captured by the RUM SDK that are not visible in the network tab
In general:
- The service worker intercepts a request for an en-US JSON translation file.
- The code path in the service worker immediately returns an empty JSON object ({}).
- Chrome DevTools Network tab reports a response time of around 1ms.
- DataDog RUM explorer, however, records the same request with a response time of approximately 60ms for the 75th percentile.
Additional details:
- npm version of @datadog/browser-rum: 6.2.1
- We are sure that the recorded response in from the service worker as we added a unique response header from the SW that we can filter in RUM explorer.
- To test our assumptions we compared results for specific user sessions manually in devtools and datado
Questions:
- Could you help explain what additional processing or events DataDog RUM might be capturing that results in the higher timing (∼60ms) compared to the nearly instantaneous response observed in the network tab?
- Are there any known issues or configuration settings within DataDog RUM that may affect measurements for responses handled by service workers?
- Do you have any recommendations or best practices for aligning the RUM measurements more closely with the actual network and processing times in such scenarios?
Screenshots:
Fetch request example: