Metrics catalogue

View Source

RaftEx exposes metrics through two mechanisms:

  1. RaftEx.Infra.Observability.Counters — compatibility layer over the ETS-backed Metrics store.
  2. RaftEx.Infra.Observability.Metrics — always-available ETS-backed counters/gauges/histograms.

The canonical list of metric names and kinds lives in RaftEx.Infra.Observability.MetricNames.

ETS metrics (RaftEx.Infra.Observability.Metrics)

NameKindUnitDescription
:wal_flushescountercountNumber of WAL flush operations performed
:wal_flush_latency_mshistogrammsLatency of a WAL flush (ms), including fsync
:wal_bytes_writtencounterbytesBytes written to the WAL
:wal_segment_writescountercountNumber of WAL segment writes
:wal_fsyncscountercountNumber of WAL fsync/datasync calls
:elections_startedcountercountNumber of elections started
:elections_woncountercountNumber of elections won
:elections_lostcountercountNumber of elections lost
:term_changedcountercountNumber of term increments
:votes_grantedcountercountNumber of votes granted
:quorum_reachedcountercountNumber of times quorum was reached
:commit_advancedcountercountNumber of commit-index advancements
:commit_indexgaugeindexCurrent commit index
:replication_backpressurecountercountNumber of replication backpressure events
:append_entries_sentcountercountNumber of AppendEntries RPCs sent
:append_entries_ackedcountercountNumber of AppendEntries RPCs acknowledged
:replication_lag_msgaugemsPer-follower replication lag (keyed by follower id)
:snapshot_chunks_sentcountercountSnapshot chunks sent
:snapshot_chunks_receivedcountercountSnapshot chunks received
:snapshot_chunks_installedcountercountSnapshots installed
:snapshot_chunks_failedcountercountSnapshot chunk failures
:snapshot_transfer_duration_mshistogrammsSnapshot transfer duration
:leadership_transfers_initiatedcountercountLeadership transfers initiated
:leadership_transfers_completedcountercountLeadership transfers completed
:leadership_transfers_failedcountercountLeadership transfers failed

Reading metrics

RaftEx.Infra.Observability.Metrics.all()
RaftEx.Infra.Observability.Metrics.get(:wal_flushes)
RaftEx.Observability.metrics()
RaftEx.Observability.metric(:commit_index)

Stores

  • The ETS store is flat (metric name only) and always available.
  • Counters is a thin compatibility layer over the ETS store; there is no external dependency. counter_fields/0 lists the per-server field spec.

Atomicity

  • Counters use :ets.update_counter/4 with a default tuple, so concurrent increments are atomic and never lose an update.
  • Histogram count and sum are updated together through a single :ets.update_counter/4 call for integer observations; min and max are best-effort and may reflect a stale extreme under concurrency.
  • Metrics.init/0 is idempotent and retries table creation on a race.