in packages/rum-core/src/performance-monitoring/breakdown.js [154:200]
export function captureBreakdown(transaction, timings = PERF.timing) {
const breakdowns = []
const { name, type, sampled } = transaction
const transactionDetails = { name, type }
/**
* Capture breakdown metrics only for sampled transactions
*/
if (!sampled) {
return breakdowns
}
if (type === PAGE_LOAD && timings) {
for (let i = 0; i < pageLoadBreakdowns.length; i++) {
const current = pageLoadBreakdowns[i]
const start = timings[current[0]]
const end = timings[current[1]]
const duration = getDuration(start, end)
if (duration === 0 || duration == null) {
continue
}
breakdowns.push(
getSpanBreakdown(transactionDetails, {
details: { type: current[2] },
duration
})
)
}
} else {
/**
* Construct the breakdown timings based on span types
*/
const spanMap = groupSpans(transaction)
Object.keys(spanMap).forEach(key => {
const [type, subtype] = key.split('.')
const { duration, count } = spanMap[key]
breakdowns.push(
getSpanBreakdown(transactionDetails, {
details: { type, subtype },
duration,
count
})
)
})
}
return breakdowns
}