Merge pull request #8946 from overleaf/jpa-pdf-caching-status

[clsi] add a single metric to describe the status of pdf caching

GitOrigin-RevId: c755b3c45ebb02296083a65e3753622787108776
This commit is contained in:
Jakob Ackermann 2022-07-20 09:33:44 +01:00 committed by Copybot
parent ac4d56403a
commit ebfe844fdf
2 changed files with 11 additions and 13 deletions

View file

@ -19,12 +19,6 @@ function getSystemLoad() {
const ONE_MB = 1024 * 1024
function emitPdfStats(stats, timings, request) {
if (stats['pdf-caching-timed-out']) {
Metrics.inc('pdf-caching-timed-out', 1, request.metricsOpts)
}
if (stats['pdf-caching-queue-limit-reached']) {
Metrics.inc('pdf-caching-queue-limit-reached', 1, request.metricsOpts)
}
if (timings['compute-pdf-caching']) {
emitPdfCachingStats(stats, timings, request)
} else {

View file

@ -196,7 +196,11 @@ module.exports = OutputCacheManager = {
outputFiles,
compileDir,
outputDir,
err => {
(err, status) => {
Metrics.inc('pdf-caching-status', 1, {
status,
...request.metricsOpts,
})
if (err) {
logger.warn(
{ err, outputDir, stats, timings },
@ -372,7 +376,7 @@ module.exports = OutputCacheManager = {
const cacheRoot = Path.join(outputDir, OutputCacheManager.CONTENT_SUBDIR)
// check if content dir exists
OutputCacheManager.ensureContentDir(cacheRoot, function (err, contentDir) {
if (err) return callback(err)
if (err) return callback(err, 'content-dir-unavailable')
const outputFile = outputFiles.find(x => x.path === 'output.pdf')
if (outputFile) {
@ -396,7 +400,7 @@ module.exports = OutputCacheManager = {
if (err && err instanceof QueueLimitReachedError) {
logger.warn({ err, outputDir }, 'pdf caching queue limit reached')
stats['pdf-caching-queue-limit-reached'] = 1
return callback(null)
return callback(null, 'queue-limit')
}
if (err && err instanceof TimedOutError) {
logger.warn(
@ -404,9 +408,9 @@ module.exports = OutputCacheManager = {
'pdf caching timed out'
)
stats['pdf-caching-timed-out'] = 1
return callback(null)
return callback(null, 'timed-out')
}
if (err) return callback(err)
if (err) return callback(err, 'failed')
const [
contentRanges,
newContentRanges,
@ -435,11 +439,11 @@ module.exports = OutputCacheManager = {
0
)
stats['pdf-caching-reclaimed-space'] = reclaimedSpace
callback(null)
callback(null, 'success')
}
)
} else {
callback(null)
callback(null, 'missing-pdf')
}
})
},