instrument
@rotorsoft/act-root / act-otel / instrument
Function: instrument()
instrument(
app,options?):Disposer
Defined in: libs/act-otel/src/index.ts:139
Subscribe to a built Act's lifecycle events and maintain the canonical Prometheus metric set:
| Metric | Type | Labels | Source event |
|---|---|---|---|
act_events_committed_total | counter | name | committed |
act_reactions_acked_total | counter | lane | acked |
act_reactions_blocked_total | counter | lane | blocked |
act_settled_total | counter | โ | settled |
act_streams_closed_total | counter | โ | closed |
act_events_forgotten_total | counter | โ | forgotten |
act_notifications_total | counter | โ | notified |
act_errors_total | counter | circuit | error |
act_streams_blocked | gauge | โ | blocked_streams() per scrape |
Label cardinality is bounded by design: event names come from the registry, lanes are declared at build, circuit states are three. There is deliberately no per-stream label โ stream ids are unbounded and would blow up a Prometheus instance.
The alerting split from the observability guide applies: a non-zero
act_streams_blocked and act_errors_total{circuit="open"} growth are
page-worthy; the rest are dashboard material.
Returns a Disposer that unsubscribes the listeners and removes
the metrics from the registry โ hand it to Act's dispose(...) registry
so Ctrl-C tears the bridge down with everything else:
Parametersโ
appโ
ActSurface
A built Act orchestrator
options?โ
InstrumentOptions = {}
Returnsโ
Disposer that detaches listeners and unregisters the metrics
Exampleโ
import { act, dispose } from "@rotorsoft/act";
import { instrument } from "@rotorsoft/act-otel";
import { register } from "prom-client";
const app = act().withState(Task).build();
dispose(instrument(app));
// serve the scrape endpoint on your HTTP surface
root.get("/metrics", async (c) => c.text(await register.metrics()));
Throwsโ
ZodError when options are out of range (misconfiguration surfaces at startup, not on the first scrape)