Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
measured-core
Advanced tools
The measured-core npm package provides a set of tools for measuring and monitoring various metrics in your Node.js applications. It includes features for creating counters, histograms, meters, and timers, which can be used to track performance and other metrics.
Counter
Counters are used to count events. You can increment or decrement the counter and retrieve the current count.
const { Counter } = require('measured-core');
const counter = new Counter();
counter.inc();
counter.dec();
console.log(counter.toJSON());
Histogram
Histograms measure the distribution of values in a stream of data. You can update the histogram with new values and retrieve statistical information about the distribution.
const { Histogram } = require('measured-core');
const histogram = new Histogram();
histogram.update(1);
histogram.update(2);
histogram.update(3);
console.log(histogram.toJSON());
Meter
Meters measure the rate of events over time. You can mark events and retrieve the rate of events per second.
const { Meter } = require('measured-core');
const meter = new Meter();
meter.mark();
meter.mark(2);
console.log(meter.toJSON());
Timer
Timers measure the duration of events. You can start and stop the timer to measure how long an operation takes and retrieve statistical information about the durations.
const { Timer } = require('measured-core');
const timer = new Timer();
const end = timer.start();
setTimeout(() => {
end();
console.log(timer.toJSON());
}, 1000);
The prom-client package is a Prometheus client for Node.js that provides similar functionality for measuring and monitoring metrics. It includes features for creating counters, gauges, histograms, and summaries. Compared to measured-core, prom-client is specifically designed to work with Prometheus, a popular monitoring and alerting toolkit.
The statsd-client package is a StatsD client for Node.js that allows you to send metrics to a StatsD server. It supports counters, timers, gauges, and sets. Compared to measured-core, statsd-client is designed to work with StatsD, a network daemon that listens for statistics and aggregates them for visualization.
The node-statsd package is another StatsD client for Node.js. It provides similar functionality to statsd-client, allowing you to send metrics to a StatsD server. It supports counters, timers, gauges, and sets. Compared to measured-core, node-statsd is also designed to work with StatsD for metric aggregation and visualization.
The core measured library that has the Metric interfaces and implementations.
npm install measured-core
The core library has the following metrics classes:
Values that can be read instantly via a supplied call back.
Just like a Gauge but its value is set directly rather than supplied by a callback.
Like a mix of the regular and settable Gauge it takes a call back that returns a promise that will resolve the cached value and an interval that it should call the callback on to update its cached value.
Counters are things that increment or decrement.
Timers are a combination of Meters and Histograms. They measure the rate as well as distribution of scalar events.
Keeps a reservoir of statistically relevant values to explore their distribution.
Things that are measured as events / interval.
The core library comes with a basic registry class
that is not aware of dimensions / tags and leaves reporting up to you.
See The measured-core modules for the full list of exports for require('measured-core').
Step 1: Add measurements to your code. For example, lets track the requests/sec of a http server:
var http = require('http');
var stats = require('measured').createCollection();
http.createServer(function(req, res) {
stats.meter('requestsPerSecond').mark();
res.end('Thanks');
}).listen(3000);
Step 2: Show the collected measurements (more advanced examples follow later):
setInterval(function() {
console.log(stats.toJSON());
}, 1000);
This will output something like this every second:
{ requestsPerSecond:
{ mean: 1710.2180279856818,
count: 10511,
'currentRate': 1941.4893498239829,
'1MinuteRate': 168.08263156623656,
'5MinuteRate': 34.74630977619571,
'15MinuteRate': 11.646507524106095 } }
Step 3: Aggregate the data into your backend of choice. Here are a few time series data aggregators.
FAQs
A Node library for measuring and reporting application-level metrics.
The npm package measured-core receives a total of 266,488 weekly downloads. As such, measured-core popularity was classified as popular.
We found that measured-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.