in packages/rum-core/src/performance-monitoring/navigation/resource-timing.js [62:99]
function createResourceTimingSpans(entries, requestPatchTime, trStart, trEnd) {
const spans = []
for (let i = 0; i < entries.length; i++) {
const { initiatorType, name, startTime, responseEnd } = entries[i]
/**
* Skip span creation if initiatorType is other than known types specified as part of RESOURCE_INITIATOR_TYPES
* The reason being, there are other types like embed, video, audio, navigation etc
*
* Check the below webplatform test to know more
* https://github.com/web-platform-tests/wpt/blob/b0020d5df18998609b38786878f7a0b92cc680aa/resource-timing/resource_initiator_types.html#L93
*/
if (
RESOURCE_INITIATOR_TYPES.indexOf(initiatorType) === -1 ||
name == null
) {
continue
}
/**
* Create Spans for API calls (XHR, Fetch) only if its not captured by the patch
*
* This would happen if our agent is downlaoded asyncrhonously and page does
* API requests before the agent patches the required modules.
*/
if (
(initiatorType === 'xmlhttprequest' || initiatorType === 'fetch') &&
(isIntakeAPIEndpoint(name) ||
isCapturedByPatching(startTime, requestPatchTime))
) {
continue
}
if (shouldCreateSpan(startTime, responseEnd, trStart, trEnd)) {
spans.push(createResourceTimingSpan(entries[i]))
}
}
return spans
}