
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
measured-node-metrics
Advanced tools
Various metrics generators and http framework middlewares that can be used with a self reporting metrics registry to easily instrument metrics for a node app.
Various metrics generators and http framework middlewares that can be used with a self reporting metrics registry to easily instrument metrics for a node app.
npm install measured-node-metrics
See the docs for the main module to see the exported helper functions and maps of metric generators for various system and os metrics.
const express = require('express');
const { createProcessMetrics, createOSMetrics, createExpressMiddleware } = require('measured-node-metrics');
const registry = new SelfReportingMetricsRegistry(new SomeReporterImple());
// Create and register default OS metrics
createOSMetrics(registry);
// Create and register default process metrics
createProcessMetrics(registry);
// Use the express middleware
const app = express();
app.use(createExpressMiddleware(registry));
// Implement the rest of app
You can also create your own middleware if your not using express, (please contribute it)
const { onRequestStart, onRequestEnd } = require('measured-node-metrics');
/**
* Creates an Express middleware that reports a timer on request data.
* With this middleware you will get requests counts and latency percentiles all filterable by status codes, http method, and uri paths.
*
* @param {SelfReportingMetricsRegistry} metricsRegistry
* @param {number} [reportingIntervalInSeconds]
* @return {Function}
*/
createExpressMiddleware: (metricsRegistry, reportingIntervalInSeconds) => {
return (req, res, next) => {
const stopwatch = onRequestStart();
req.on('end', () => {
const { method } = req;
const { statusCode } = res;
// path variables should be stripped in order to avoid runaway time series creation,
// /v1/cars/:id should be one dimension rather than n, one for each id.
const uri = req.route ? req.route.path : '_unknown';
onRequestEnd(metricsRegistry, stopwatch, method, statusCode, uri, reportingIntervalInSeconds);
});
next();
};
}
FAQs
Various metrics generators and http framework middlewares that can be used with a self reporting metrics registry to easily instrument metrics for a node app.
The npm package measured-node-metrics receives a total of 349 weekly downloads. As such, measured-node-metrics popularity was classified as not popular.
We found that measured-node-metrics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.