npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@setu-ts/metrics-plugin

v0.11.0

Published

Prometheus counters, gauges, histograms, and summaries with built-in HTTP metrics

Readme

@setu-ts/metrics-plugin

Prometheus metrics. Registers an IMetricsService under CAPABILITIES.METRICS ('metrics') and serves the scrape endpoint at /metrics.

Zero dependencies — the Prometheus text-format 0.0.4 renderer is implemented in this package.

Label values are escaped per text format 0.0.4 (backslash, double quote, line feed). Any other control character (carriage return, NUL, the rest of C0 and DEL) has no escape in that format and is encoded in label values and HELP text as U+FFFD followed by its two hex digits (a lone UTF-16 surrogate as U+FFFD, u and four hex digits; a literal U+FFFD as two of them), so an application-supplied value cannot split an exposition line and two distinct values never render as the same sample line.

Installation

import { MetricsPlugin } from '@setu-ts/metrics-plugin';

Usage

import { createApplication } from '@setu-ts/kernel';
import { RuntimePlugin } from '@setu-ts/runtime';
import { MetricsPlugin } from '@setu-ts/metrics-plugin';
import { CAPABILITIES, type IMetricsService } from '@setu-ts/common';

const app = createApplication({
  plugins: [RuntimePlugin(), MetricsPlugin({ endpoint: '/metrics', httpMetrics: true })],
});
await app.start({ port: 3000 });

const metrics = app.services.get<IMetricsService>(CAPABILITIES.METRICS);
const signups = metrics.counter('app_signups_total', { help: 'Completed signups' });
signups.inc(1);

Options

| Option | Type | Default | Description | | ------------------ | --------------------- | ----------------------------------------------------------- | ---------------------------------------------- | | endpoint | string | '/metrics' | Scrape endpoint path. | | defaultMetrics | boolean | true | Register the built-in metric set. | | httpMetrics | boolean | true | Register the HTTP request-tracking middleware. | | customMetrics | NamedMetricConfig[] | [] | Metrics pre-registered declaratively. | | defaultBuckets | number[] | [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10] | Histogram bucket boundaries. | | defaultQuantiles | number[] | [0.5, 0.9, 0.99] | Summary quantiles. |

Instruments

counter, gauge, histogram, and summary, all over a shared base.

HTTP collectors

The metrics middleware runs at priority 20 — outermost, so it observes all ingress and the final response status. The record path is wrapped in try/finally, so a request that throws still decrements the active-requests gauge rather than leaking it.

HTTP series use only method and status labels. The case-sensitive known methods are GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, and PATCH; every other method uses _OTHER, including on thrown-error paths. This bounds method-label cardinality.

Exports

| Export | Kind | | ---------------------- | --------- | | MetricsPlugin | function | | Counter | class | | Gauge | class | | Histogram | class | | MetricsService | class | | Summary | class | | ICounter | interface | | IGauge | interface | | IHistogram | interface | | IMetric | interface | | IMetricsService | interface | | ISummary | interface | | MetricConfig | interface | | MetricOptions | interface | | MetricsPluginOptions | interface | | NamedMetricConfig | interface |

Generated from the package barrel by pnpm run docs:exports; pnpm run check:docs fails when it drifts.

Full API

Every export and option is documented in PUBLIC_API.md.