
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@platformatic/fastify-http-metrics
Advanced tools
The `fastify-http-metrics` package provides a simple way to collect prometheus metrics for your Fastify application.
The fastify-http-metrics package provides a simple way to collect prometheus metrics for your Fastify application.
npm install @platformatic/fastify-http-metrics
const { Registry } = require('prom-client')
const fastify = require('fastify')
const httpMetrics = require('@platformatic/fastify-http-metrics')
const app = fastify()
const registry = new Registry()
app.register(httpMetrics, { registry })
app.get('/metrics', async () => {
const metrics = await registry.metrics()
return metrics
})
app.get('/', async () => {
return 'Hello World'
})
app.listen({ port: 0 }, (err, address) => {
if (err) {
console.error(err)
process.exit(1)
}
console.log(`Server listening on ${address}`)
})
options <object> Options for configuring the metrics collection.
registry <Registry> The prom-client registry to use for collecting metrics.customLabels <array> A list of custom labels names to add to the metrics.getCustomLabels(req, res, server) <function> A function that returns an object of custom labels to add to the metrics. The function receives the request object as a first argument and a response object as a second argument.ignoreMethods <array> A list of HTTP methods to ignore when collecting metrics. Default: ['OPTIONS', 'HEAD', 'CONNECT', 'TRACE'].ignoreRoutes <array> A list of fastify routes to ignore when collecting metrics. Default: [].ignore(req, res, server) <function> A function that returns a boolean indicating whether to ignore the request when collecting metrics. The function receives the request object as a first argument and a response object as a second argument.histogram <object> prom-client histogram options. Use it if you want to customize the histogram.summary <object> prom-client summary options. Use it if you want to customize the summary.zeroFill <boolean> Whether to zero-fill the histogram and summary buckets. Default: false.Apache-2.0
FAQs
The `fastify-http-metrics` package provides a simple way to collect prometheus metrics for your Fastify application.
We found that @platformatic/fastify-http-metrics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers