Skip to content

Commit

Permalink
feat: log memory on 10s interval
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 22, 2018
1 parent 4388cd3 commit 65430ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = wip

const sendLogs = require('./lib/logs/send')
const logMemoryUsage = require('./lib/logs/memory-usage.js')
const handlePullRequestChange = require('./lib/handle-pull-request-change')
const handleRequestedAction = require('./lib/handle-requested-action')
const handleMarketplacePurchase = require('./lib/handle-marketplace-purchase')
Expand All @@ -22,4 +23,5 @@ function wip (app) {
app.on('marketplace_purchase', handleMarketplacePurchase.bind(null, app))

sendLogs(app)
logMemoryUsage(app)
}
20 changes: 20 additions & 0 deletions lib/logs/memory-usage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* istanbul ignore file */
module.exports = logMemoryUsage

let lastMemory = {
rss: 0,
heapTotal: 0,
heapUsed: 0,
external: 0
}

/* istanbul ignore next */
function logMemoryUsage (app) {
const interval = 10000 // 10s
setInterval(() => {
const usage = process.memoryUsage()
const diff = usage.rss - lastMemory.rss
app.log.debug(usage, `Memory usage change: ${diff}`)
lastMemory = usage
}, interval) // 10s
}

1 comment on commit 65430ca

@vercel
Copy link

@vercel vercel bot commented on 65430ca Nov 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully aliased the URL https://wip-wssodwrglh.now.sh to the following alias.

Please sign in to comment.