Bier.PoolMonitor (bier v0.1.0)

Copy Markdown View Source

Per-instance poller that samples the Postgrex connection pool and emits the [:bier, :pool, :status] gauge event (see Bier.Telemetry).

PostgREST exposes its pool as the Prometheus gauges pgrst_db_pool_max, pgrst_db_pool_available and pgrst_db_pool_waiting. DBConnection's pool is sampled through DBConnection.get_connection_metrics/1 — a snapshot of ready connections and checkout-queue depth per pool source — so the event's measurements map onto those gauges:

  • :max — the configured pool_size;
  • :available — connections ready to be checked out (0 while the pool is busy);
  • :waiting — callers queued for a checkout.

One sample is emitted immediately on start (so an attached handler observes the pool without waiting a full interval), then every 5 seconds. A sample that finds the pool unreachable (e.g. mid-restart) is skipped — no event is emitted, and the poller stays alive for the next tick.

The counter half of PostgREST's pool metrics (pgrst_db_pool_timeouts_total) is event-driven, not polled: [:bier, :pool, :checkout_timeout] fires from Bier.Plugs.FallbackController when a request fails on a checkout-queue timeout.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(conf)