Merge pull request #4108 from overleaf/jpa-lean-pdf-caching-metrics

[frontend] PdfJsMetrics: submit a subset of data points, flatten nested

GitOrigin-RevId: a98ede58f5823020a4c78f46b9800369185f1336
This commit is contained in:
Jakob Ackermann 2021-06-01 15:52:55 +02:00 committed by Copybot
parent 0015002e53
commit 5988e03dac

View file

@ -51,11 +51,33 @@ export function trackPdfDownload(response, compileTimeClientE2E) {
}
function submitCompileMetrics(metrics) {
let {
latencyFetch,
latencyRender,
compileTimeClientE2E,
stats,
timings,
} = metrics
stats = stats || {}
timings = timings || {}
const leanMetrics = {
latencyFetch,
latencyRender,
pdfSize: stats['pdf-size'],
compileTimeClientE2E,
compileTimeServerE2E: timings.compileE2E,
}
sl_console.log('/event/compile-metrics', JSON.stringify(metrics))
sendMBSampled('compile-metrics', metrics, SAMPLING_RATE)
sendMBSampled('compile-metrics', leanMetrics, SAMPLING_RATE)
}
function submitPDFBandwidth(metrics) {
const metricsFlat = {}
Object.entries(metrics).forEach(([section, items]) => {
Object.entries(items).forEach(([key, value]) => {
metricsFlat[section + '_' + key] = value
})
})
sl_console.log('/event/pdf-bandwidth', JSON.stringify(metrics))
sendMBSampled('pdf-bandwidth', metrics, SAMPLING_RATE)
sendMBSampled('pdf-bandwidth', metricsFlat, SAMPLING_RATE)
}