From 7153bda6ead6420127cb90df044d05bccacddba8 Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 23 Feb 2021 10:48:29 +0100 Subject: [PATCH] SC-10763: added formatting for cached requests --- lib/plugins/output-filter/vercel-format.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/plugins/output-filter/vercel-format.js b/lib/plugins/output-filter/vercel-format.js index 3c87077a..b0a26ab9 100644 --- a/lib/plugins/output-filter/vercel-format.js +++ b/lib/plugins/output-filter/vercel-format.js @@ -22,15 +22,27 @@ function formatVercelLogsOutput (context, config, eventEmitter, log, callback) { console.log(e, log) } - callback(e, log) + callback(null, log) } } function parseVercelLog (log) { + // if the log is not from Lambda, return right away if (log && log.source && log.source !== 'lambda') { return log } + // if the log is a cached request, handle parsing here + if (log && log.proxy && log.proxy.cacheId) { + const { source, ...rest } = log + return { + message: `Cache hit for requestId: ${rest.proxy.cacheId}`, + source: 'cache', + ...rest + } + } + + // if the log is a Lambda request enrich log with metrics const { message, ...rest } = log const splitN = message.split('\n') const filtered = splitN.filter(f => f.startsWith('REPORT'))