
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
cloudflare-worker-metrics
Advanced tools
Lightweight metrics collection for Cloudflare Workers.
Metrics are aggregated during invocation and then finally flushed via logs. The cloudflare-worker-metrics-exporter then reads those logs and emits them to an OTEL endpoint.
import { metrics } from 'cloudflare-worker-metrics';
export default {
async fetch(request, env, ctx) {
metrics.count('http_requests', 1, { method: request.method });
metrics.gauge('connections_active', getActiveCount());
metrics.histogram('response_duration', elapsed, { endpoint: '/api' });
const response = await handleRequest(request);
metrics.flush();
return response;
},
};
Define a registry of metric names and their tag shapes, then create a typed metrics instance:
import { createMetrics } from 'cloudflare-worker-metrics';
type MyMetrics = {
http_request_count: { method: string; route: string }
http_response_duration_ms: { method: string; route: string; status: number }
db_query_duration_ms: { operation: string; table: string }
}
const metrics = createMetrics<MyMetrics>({
globalTags: { build_version: '1.0.0' },
});
metrics.count('http_request_count', 1, { method: 'GET', route: '/api/health' });
metrics.histogram('http_response_duration_ms', 42, { method: 'GET', route: '/api/health', status: 200 });
metrics.flush();
createMetrics<T>(options?)Create a typed metrics instance. T maps metric names to their expected tag shapes.
Only registered names are accepted and tags are type-checked per metric.
Options:
globalTags — tags automatically merged into every emission (metric-specific tags take precedence).metrics.count(name, value?, tags?)Increment a counter. Values with the same name+tags are summed.
metrics.gauge(name, value, tags?)Set a gauge. Last write wins for the same name+tags.
metrics.histogram(name, value, tags?)Record a histogram observation. Each call emits a raw histogram entry.
metrics.flush()Flush all metrics to console.log as cwm- prefixed JSON. Auto-splits at 250 KiB.
FAQs
Lightweight metrics collection for Cloudflare Workers
We found that cloudflare-worker-metrics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.