Ferricstore.PrefixMetricsCache (ferricstore v0.4.3)

Copy Markdown View Source

Cached Prometheus text for expensive per-prefix metrics.

Per-prefix key counts require folding every shard keydir ETS table. That is useful operationally, but too expensive to run directly inside every FERRICSTORE.METRICS command. This process owns a small ETS cache so scrapes read the last completed scan and only schedule refresh work when stale.

Summary

Functions

Returns a specification to start this module under a supervisor.

Rebuilds the prefix metrics cache synchronously.

Clears cached prefix metrics.

Starts the prefix metrics cache.

Returns the last completed prefix metrics text block.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

refresh_now(timeout \\ 30000)

@spec refresh_now(timeout()) :: :ok | {:error, :not_started}

Rebuilds the prefix metrics cache synchronously.

Tests and maintenance tooling can call this when they need a deterministic cache update.

reset()

@spec reset() :: :ok

Clears cached prefix metrics.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the prefix metrics cache.

text()

@spec text() :: binary()

Returns the last completed prefix metrics text block.

If the cache is missing or stale, this schedules a background refresh and returns the previous value immediately. The first scrape may therefore omit prefix metrics until the refresh completes.