| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Fastify plugin for sampling process metrics.
It uses the module @dnlup/doc behind the scenes.
It decorates the Fastify instance with a Sampler instance that you can use to get process metrics.
A new sample of the metrics is available when the Sampler emits a sample event.
See @dnlup/doc documentation for more details.
npm i @dnlup/fastify-docconst fastify = require('fastify')()
const metrics = require('@dnlup/fastify-doc')
fastify.register(metrics)
fastify.register(function myReporter (instance, opts, next) {
instance.metrics.on('sample', () => {
// sendCpuUsage(instance.metrics.cpu.usage)
// ...send other metrics as well
})
next()
})
fastify.get('/', (request, reply) => {
reply.send({ ok: true })
})
fastify.listen(3000)const fastify = require('fastify')()
const metrics = require('@dnlup/fastify-doc')
fastify.register(async function myReporter (instance, opts) {
await instance.register(metrics)
instance.metrics.on('sample', () => {
// sendCpuUsage(instance.metrics.cpu.usage)
// ...send other metrics as well
})
})
fastify.get('/', (request, reply) => {
reply.send({ ok: true })
})
fastify.listen(3000)The options are the same of @dnlup/doc (reported here for convenience):
If options.collect.resourceUsage is set to true, options.collect.cpu will be set to false because the cpu metric is already available in the resource usage metric.
A Sampler instance.
Whether the Node.js version in use supports the eventLoopUtilization metric.
Whether the Node.js version in use supports the resourceUsage metric.
Whether the Node.js version in use supports GC flags.
Stops the Sampler instance when closing the server.
| Back | FazBrowse Home | New Git URL |