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

@heraldserver/prometheus

v0.1.0

Published

MetricsCollector do Herald Protocol backed by prom-client — expõe GET /metrics em formato Prometheus/OpenMetrics.

Readme

@heraldserver/prometheus

MetricsCollector do Herald Protocol backed by prom-client — expõe GET /metrics (via @heraldserver/gateway) em formato de texto Prometheus/OpenMetrics em vez do JSON default do InMemoryMetricsCollector.

Pacote opcional, separado — @heraldserver/sdk e @heraldserver/gateway não dependem de prom-client (filosofia de dependência mínima do projeto). Só quem instala e usa este pacote traz prom-client como dependência real.

Uso

import { createHeraldGateway } from "@heraldserver/gateway";
import { PrometheusMetricsCollector } from "@heraldserver/prometheus";

const gateway = createHeraldGateway({
  discovery: { /* ... */ },
  policy: { /* ... */ },
  metrics: new PrometheusMetricsCollector(),
});

app.use(gateway.router);
// GET /metrics agora responde texto Prometheus (Content-Type: text/plain; version=...),
// não o JSON do InMemoryMetricsCollector — @heraldserver/gateway reconhece isso via
// renderPrometheus() (duck-typing, sem @heraldserver/gateway depender de prom-client).

Aponte um scrape_configs do Prometheus pra esse /metrics normalmente.

Métricas expostas

| Nome | Tipo | Labels | Origem | |---|---|---|---| | herald_requests_total | Counter | agent_type | incrementRequest | | herald_policy_decisions_total | Counter | result | recordPolicyDecision | | herald_formats_served_total | Counter | format | recordFormat | | herald_errors_total | Counter | agent_type, status_code | recordError | | herald_request_duration_ms | Histogram | agent_type | recordLatency |

Mais as métricas default do Node.js (collectDefaultMetrics do prom-client — heap, event loop lag, GC, etc.), num Registry próprio por instância (não polui o registry global do prom-client — seguro instanciar mais de um PrometheusMetricsCollector no mesmo processo).

Por que sem agent_id como label

InMemoryMetricsCollector (o default, em @heraldserver/sdk) agrega por agentId — cabe bem num objeto JS em memória, descartado a cada restart. Prometheus é diferente: cada combinação nova de valores de label vira uma série nova, permanente no TSDB até expirar pela retenção configurada. agentId é essencialmente ilimitado (uma string por bot/versão distinta observada, ex: "gptbot/4.2.1", "gptbot/4.2.2", ...) — usá-lo como label é o anti-padrão de "cardinalidade sem limite" documentado pelo próprio Prometheus, e derruba instâncias reais com tráfego de bots variado. Este pacote agrega só por agent_type (5 valores possíveis — RFC-0001 §4) — perde granularidade por agente individual (ainda disponível via outpost_reports no @heraldserver/server, se precisar), ganha um TSDB que não cresce sem controle.

Testes

npm install && npm run build && npm test

Sem dependência externa (Postgres, rede) — testes rodam contra Registry do próprio prom-client, in-process.