RaftEx.Infra.Observability.Metrics (raft_ex v0.6.0)

View Source

Lightweight, ETS-backed metrics for RaftEx.

Primary metrics store, backed by ETS. Values are kept in the :raft_ex_metrics ETS table (created by MetricsEts).

Supported metric kinds:

  • :counter - monotonically increasing integer
  • :gauge - settable integer/float
  • :histogram- accumulated sum + count (min/max tracked)

Summary

Functions

Read all metrics as a map.

Read a single metric value (counter/gauge) or histogram tuple.

Increment a counter by amount (default 1).

Ensure the backing table exists (idempotent).

Record a latency observation (milliseconds) into a histogram.

Reset all metrics.

Set a gauge value.

Functions

all()

@spec all() :: map()

Read all metrics as a map.

get(name)

@spec get(atom() | String.t()) :: term()

Read a single metric value (counter/gauge) or histogram tuple.

inc(name, amount \\ 1)

@spec inc(atom() | String.t(), number()) :: :ok

Increment a counter by amount (default 1).

init()

@spec init() :: :ok

Ensure the backing table exists (idempotent).

observe(name, value)

@spec observe(atom() | String.t(), number()) :: :ok

Record a latency observation (milliseconds) into a histogram.

reset()

@spec reset() :: :ok

Reset all metrics.

set(name, value)

@spec set(atom() | String.t(), number()) :: :ok

Set a gauge value.