Skip to content

Commit

Permalink
Merge pull request #274 from sematext/sc-10763-fix-vercel-cache-logging
Browse files Browse the repository at this point in the history
SC-10763: Added formatting for cached requests
  • Loading branch information
Adnan Rahić authored Feb 23, 2021
2 parents abd1d1d + 7153bda commit bbe4e36
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/plugins/output-filter/vercel-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit bbe4e36

Please sign in to comment.