View Source Working with metrics

You can quickly analyze and optimize your pool's production settings with the metrics presented by the library.

Pool size metrics

The Poolex library presents an idle/busy worker count metric. These metrics help estimate a pool load and the number of workers used.

Also, there is an overflow metric. It shows how long pools are forced to use additional workers.

You can handle them by using :telemetry.attach/4:

:telemetry.attach(
  "my-lovely-pool-size-metrics",
  [:poolex, :metrics, :pool_size],
  &MyApp.handle_event/4,
  nil
)

For example, your application can write metrics to the console: PoolexExample.MetricsHandler.

More about using telemetry here.

Integration with PromEx

There is a built-in plugin that works with the PromEx library.

To use this plugin, you need to add :prom_ex to your dependencies in mix.exs:

defp deps do
  [
    {:prom_ex, "~> 1.0"}
  ]
end

Then you need to add this plugin to plugins list in your PromEx configuration:

defmodule MyCoolApp.PromEx do
  use PromEx, otp_app: :my_cool_app

  @impl PromEx
  def plugins do
    [
      Poolex.PromEx
    ]
  end
end

After installation, poolex metrics will be added to your application metrics.

TODO: add some screenshots

Additional information about PromEx installation and configuration can be found in the PromEx documentation: https://hexdocs.pm/prom_ex/readme.html#installation.