How to use the @pm2/io.counter function in @pm2/io

To help you get started, we’ve selected a few @pm2/io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keymetrics / app-playground / app.js View on Github external
* Create a mock http server
 */

http.createServer((req, res) => {
  // Then mark it at every connections
  meter.mark()
  res.end('Thanks')
}).listen(5005)


/**
 * Probe system #4 - Counter
 *
 * Measure things that increment or decrement
 */
const counter = io.counter({
  name: 'Downloads'
})

/**
 * Now let's create some remote action
 * And act on the Counter probe we just created
 */
io.action('decrement', { comment: 'Increment downloads' }, (cb) => {
  counter.dec()
  cb({ success: true })
})

io.action('increment', { comment : 'Decrement downloads' }, (cb) => {
  // Increment the previous counter
  counter.inc()
  cb({ success: true })

@pm2/io

PM2.io NodeJS APM

Apache-2.0
Latest version published 1 month ago

Package Health Score

85 / 100
Full package analysis

Similar packages