prom-client adapter
If your app already uses prom-client (the de-facto Node /
Prometheus library) for its non-actor metrics, the
PromClientAdapter lets the framework’s metrics live in the
same prom-client registry — one /metrics endpoint, all
metrics together.
import { Registry } from 'prom-client';import { ActorSystem, MetricsExtensionId, PromClientAdapter } from 'actor-ts';
const promRegistry = new Registry();// ... register your existing prom-client metrics ...
const system = ActorSystem.create('my-app');const metrics = system.extension(MetricsExtensionId);
// Mirror framework metrics into the prom-client registry:const adapter = new PromClientAdapter({ source: metrics.registry, target: promRegistry,});
adapter.start();
// Now exposing prom-client's combined export includes framework metrics:get(async () => ({ status: 200, body: await promRegistry.metrics(), contentType: promRegistry.contentType,}));The adapter mirrors framework metrics into the prom-client registry on a periodic interval (configurable). Both registries work normally; the adapter syncs values between them.
When to use it
Section titled “When to use it”Two main reasons:
- Existing prom-client usage — your code has been emitting metrics via prom-client; you don’t want to maintain two registries.
- One scrape endpoint — your operators expect a single
/metricsURL combining all your metrics.
If you don’t already use prom-client, prefer the framework’s native Prometheus exporter — no extra dependency.
Configuration
Section titled “Configuration”interface PromClientAdapterSettings { source: MetricsRegistry; // the framework's registry target: Registry; // prom-client's syncIntervalMs?: number; // default 5000 prefix?: string; // optional name prefix}syncIntervalMs is the cadence at which framework values get
copied into the prom-client registry. For most scrape setups
(every 15-30 s), a 5-second sync is plenty.
prefix lets you namespace framework metrics:
new PromClientAdapter({ source: metrics.registry, target: promRegistry, prefix: 'actorts_',});
// → actorts_http_requests_total, actorts_sessions_active, ...Peer dependency
Section titled “Peer dependency”npm install prom-client# or: bun add prom-clientprom-client is a peer — only required if you use this
adapter.
Where to next
Section titled “Where to next”- Observability overview — the bigger picture.
- Core metrics — the framework’s metric primitives that get mirrored.
- Prometheus exporter — the framework-native alternative when you don’t need prom-client.
- OTel adapter — for OpenTelemetry-based pipelines.