コンテンツにスキップ
日本語

Stock metrics

このコンテンツはまだ日本語訳がありません。

When the metrics extension is enabled, the framework automatically records a baseline of metrics covering the actor lifecycle, message handling, bounded mailboxes, and the cluster.

import { ActorSystem, MetricsExtensionId } from 'actor-ts';
const metrics = system.extension(MetricsExtensionId).enable();
// Stock metrics now record into the live registry — no further setup

These are the metrics you’d write yourself anyway. Shipping them out of the box lets you wire a dashboard immediately.

Actor-lifecycle and message-handling metrics, recorded across the whole system — each is a single unlabeled series:

MetricTypeLabelsMeaning
actor_created_totalcounterActors successfully started.
actor_terminated_totalcounterActors stopped (clean stop or post-failure).
actor_restarted_totalcounterSupervisor-driven restarts.
actor_messages_delivered_totalcounterUser messages delivered to onReceive.
actor_message_handler_secondshistogramTime spent inside onReceive handlers, in seconds.

actor_message_handler_seconds uses the default seconds-scale buckets; its p99 is your “how slow is a handler” signal.

MetricTypeLabelsMeaning
actor_mailbox_sizegaugeclass, pathQueued user messages, sampled. Only actors at or above 10 000 are represented.
actor_mailbox_dropped_totalcounterclass, path, reasonMessages dropped by a bounded mailbox’s overflow policy.

actor_mailbox_size is the backlog signal. Mailboxes are unbounded by default, so an actor that falls behind accumulates rather than sheds — and a series only exists once one crosses 10 000 queued messages. Its presence is therefore the alert: on a healthy system the metric is empty. A mailbox that drains back below the floor reads 0 rather than its last spike, and the same threshold produces a log warning (repeated at each doubling) whether or not metrics are on.

actor_mailbox_dropped_total is the shedding signal, and only appears for actors whose mailbox discards something — which, since the default is unbounded, means actors someone deliberately bounded. The reason label records the policy that fired (drop-head / drop-new). Both ways of bounding are covered: withMailboxCapacity, and a mailbox you build yourself and pass to withMailbox.

MetricTypeLabelsMeaning
cluster_members_upgaugeMembers currently in the up state (this node’s view).
cluster_gossip_rounds_totalcounterGossip-push rounds initiated by this node.
cluster_gossip_records_refused_totalcounterreasonGossiped member records a merge-path guard refused.

For monitoring cluster health:

  • cluster_members_up should equal your configured replica count; a persistent shortfall means members are down or unreachable.
  • cluster_gossip_rounds_total rate confirms gossip is flowing — a flat line means this node has stopped gossiping.
  • cluster_gossip_records_refused_total should sit at zero. Movement on reason="version-skew" means gossiped versions are further ahead of this node’s clock than maxVersionSkewMs — either a peer’s clock has drifted or someone is trying to pre-claim an address. Movement on reason="map-cap" means max-members / max-tombstones is full. The counter is incremented once per frame with that frame’s count, and the label set is closed at those two values.

The CRDT replicator’s quorum path — updateAsync / getAsync — and its wire decoder. Every label set here is fixed and tiny, so the four families contribute six series in total:

MetricTypeLabelsMeaning
distributed_data_quorum_pendinggaugeQuorum reads and writes currently awaiting peer replies on this replica.
distributed_data_quorum_timeouts_totalcounteroperationQuorum requests that hit their deadline before enough replicas replied.
distributed_data_quorum_rejected_totalcounteroperationQuorum requests refused because max-pending-quorum-requests was reached.
distributed_data_dropped_values_totalcounterPeer-supplied CRDT values this replica refused to decode.

operation is write or read — those two values and no others.

  • distributed_data_quorum_pending riding near your configured max-pending-quorum-requests means the next caller is about to be refused; either peers have stopped acking or the cap is too low for the workload.
  • distributed_data_quorum_rejected_total and ..._timeouts_total separate the two failure shapes: refused means the request never started, timed out means it started and nobody answered in time. See Quorum reads and writes.
  • distributed_data_dropped_values_total is not a tuning signal at all — a peer is sending payloads this replica cannot decode, which means a broken or hostile node.

There is no opt-out flag — stock metrics are always wired into the framework. Until you call .enable(), every instrumentation call resolves against a noop registry (a single object lookup that records nothing), so the cost is negligible. Enabling the extension swaps in the live registry and the same calls start capturing.