mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
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:
parent
ac4d56403a
commit
ebfe844fdf
2 changed files with 11 additions and 13 deletions
|
@ -19,12 +19,6 @@ function getSystemLoad() {
|
||||||
const ONE_MB = 1024 * 1024
|
const ONE_MB = 1024 * 1024
|
||||||
|
|
||||||
function emitPdfStats(stats, timings, request) {
|
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']) {
|
if (timings['compute-pdf-caching']) {
|
||||||
emitPdfCachingStats(stats, timings, request)
|
emitPdfCachingStats(stats, timings, request)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -196,7 +196,11 @@ module.exports = OutputCacheManager = {
|
||||||
outputFiles,
|
outputFiles,
|
||||||
compileDir,
|
compileDir,
|
||||||
outputDir,
|
outputDir,
|
||||||
err => {
|
(err, status) => {
|
||||||
|
Metrics.inc('pdf-caching-status', 1, {
|
||||||
|
status,
|
||||||
|
...request.metricsOpts,
|
||||||
|
})
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
{ err, outputDir, stats, timings },
|
{ err, outputDir, stats, timings },
|
||||||
|
@ -372,7 +376,7 @@ module.exports = OutputCacheManager = {
|
||||||
const cacheRoot = Path.join(outputDir, OutputCacheManager.CONTENT_SUBDIR)
|
const cacheRoot = Path.join(outputDir, OutputCacheManager.CONTENT_SUBDIR)
|
||||||
// check if content dir exists
|
// check if content dir exists
|
||||||
OutputCacheManager.ensureContentDir(cacheRoot, function (err, contentDir) {
|
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')
|
const outputFile = outputFiles.find(x => x.path === 'output.pdf')
|
||||||
if (outputFile) {
|
if (outputFile) {
|
||||||
|
@ -396,7 +400,7 @@ module.exports = OutputCacheManager = {
|
||||||
if (err && err instanceof QueueLimitReachedError) {
|
if (err && err instanceof QueueLimitReachedError) {
|
||||||
logger.warn({ err, outputDir }, 'pdf caching queue limit reached')
|
logger.warn({ err, outputDir }, 'pdf caching queue limit reached')
|
||||||
stats['pdf-caching-queue-limit-reached'] = 1
|
stats['pdf-caching-queue-limit-reached'] = 1
|
||||||
return callback(null)
|
return callback(null, 'queue-limit')
|
||||||
}
|
}
|
||||||
if (err && err instanceof TimedOutError) {
|
if (err && err instanceof TimedOutError) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
@ -404,9 +408,9 @@ module.exports = OutputCacheManager = {
|
||||||
'pdf caching timed out'
|
'pdf caching timed out'
|
||||||
)
|
)
|
||||||
stats['pdf-caching-timed-out'] = 1
|
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 [
|
const [
|
||||||
contentRanges,
|
contentRanges,
|
||||||
newContentRanges,
|
newContentRanges,
|
||||||
|
@ -435,11 +439,11 @@ module.exports = OutputCacheManager = {
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
stats['pdf-caching-reclaimed-space'] = reclaimedSpace
|
stats['pdf-caching-reclaimed-space'] = reclaimedSpace
|
||||||
callback(null)
|
callback(null, 'success')
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
callback(null)
|
callback(null, 'missing-pdf')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue