mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-29 14:00:05 +02:00

* [clsi-cache] initial revision of the clsi-cache service * [clsi] send output files to clsi-cache and import from clsi-cache * [web] pass editorId to clsi * [web] clear clsi-cache when clearing clsi cache * [web] add split-tests for controlling clsi-cache rollout * [web] populate clsi-cache when cloning/creating project from template * [clsi-cache] produce less noise when populating cache hits 404 * [clsi-cache] push docker image to AR * [clsi-cache] push docker image to AR * [clsi-cache] allow compileGroup in job payload * [clsi-cache] set X-Zone header from latest endpoint * [clsi-cache] use method POST for /enqueue endpoint * [web] populate clsi-cache in zone b with template data * [clsi-cache] limit number of editors per project/user folder to 10 * [web] clone: populate the clsi-cache unless the TeXLive release changed * [clsi-cache] keep user folder when clearing cache as anonymous user * [clsi] download old output.tar.gz when synctex finds empty compile dir * [web] fix lint * [clsi-cache] multi-zonal lookup of single build output * [clsi-cache] add more validation and limits Co-authored-by: Brian Gough <brian.gough@overleaf.com> * [clsi] do not include clsi-cache tar-ball in output.zip * [clsi-cache] fix reference after remaining constant Co-authored-by: Alf Eaton <alf.eaton@overleaf.com> * [web] consolidate validation of filename into ClsiCacheHandler * [clsi-cache] extend metrics and event tracking - break down most of the clsi metrics by label - compile=initial - new compile dir without previous output files - compile=recompile - recompile in existing compile dir - compile=from-cache - compile using previous clsi-cache - extend segmentation on compile-result-backend event - isInitialCompile=true - found new compile dir at start of request - restoredClsiCache=true - restored compile dir from clsi-cache * [clsi] rename metrics labels for download of clsi-cache This is in preparation for synctex changes. * [clsi] use constant for limit of entries in output.tar.gz Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com> * [clsi-cache] fix cloning of project cache --------- Co-authored-by: Brian Gough <brian.gough@overleaf.com> Co-authored-by: Alf Eaton <alf.eaton@overleaf.com> Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com> GitOrigin-RevId: 4901a65497af13be1549af7f38ceee3188fcf881
66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
import { v4 as uuid } from 'uuid'
|
|
import { sendMB } from '../../../infrastructure/event-tracking'
|
|
import { trackPdfDownloadEnabled } from './pdf-caching-flags'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
|
// VERSION should get incremented when making changes to caching behavior or
|
|
// adjusting metrics collection.
|
|
const VERSION = 9
|
|
|
|
// editing session id
|
|
export const EDITOR_SESSION_ID = uuid()
|
|
|
|
const pdfCachingMetrics = {
|
|
viewerId: EDITOR_SESSION_ID,
|
|
}
|
|
|
|
export function getPdfCachingMetrics() {
|
|
return pdfCachingMetrics
|
|
}
|
|
|
|
export function trackPdfDownload(response, compileTimeClientE2E, t0) {
|
|
const { timings, pdfCachingMinChunkSize } = response
|
|
|
|
const deliveryLatencies = {
|
|
compileTimeClientE2E,
|
|
compileTimeServerE2E: timings?.compileE2E,
|
|
}
|
|
|
|
// There can be multiple "first" renderings with two pdf viewers.
|
|
// E.g. two pdf detach tabs or pdf detacher plus pdf detach.
|
|
// Let the pdfCachingMetrics round trip to account for pdf-detach.
|
|
let isFirstRender = true
|
|
function firstRenderDone({ latencyFetch, latencyRender, pdfCachingMetrics }) {
|
|
if (!isFirstRender) return
|
|
isFirstRender = false
|
|
|
|
deliveryLatencies.totalDeliveryTime = Math.ceil(performance.now() - t0)
|
|
deliveryLatencies.latencyFetch = latencyFetch
|
|
if (latencyRender) {
|
|
deliveryLatencies.latencyRender = latencyRender
|
|
}
|
|
if (trackPdfDownloadEnabled) {
|
|
// Submit latency along with compile context.
|
|
submitCompileMetrics({
|
|
pdfCachingMinChunkSize,
|
|
...deliveryLatencies,
|
|
...pdfCachingMetrics,
|
|
})
|
|
}
|
|
}
|
|
|
|
return {
|
|
deliveryLatencies,
|
|
firstRenderDone,
|
|
}
|
|
}
|
|
|
|
function submitCompileMetrics(metrics) {
|
|
const leanMetrics = {
|
|
version: VERSION,
|
|
...metrics,
|
|
id: EDITOR_SESSION_ID,
|
|
}
|
|
debugConsole.log('/event/compile-metrics', JSON.stringify(leanMetrics))
|
|
sendMB('compile-metrics-v6', leanMetrics)
|
|
}
|