diff --git a/services/clsi/app/js/ContentCacheMetrics.js b/services/clsi/app/js/ContentCacheMetrics.js index e22e93ea9c..fd24fb431b 100644 --- a/services/clsi/app/js/ContentCacheMetrics.js +++ b/services/clsi/app/js/ContentCacheMetrics.js @@ -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 { diff --git a/services/clsi/app/js/OutputCacheManager.js b/services/clsi/app/js/OutputCacheManager.js index 5654ef5893..2e1448b836 100644 --- a/services/clsi/app/js/OutputCacheManager.js +++ b/services/clsi/app/js/OutputCacheManager.js @@ -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') } }) },