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.
To enable pool size metrics, you need to set the pool_size_metrics parameter to true on the pool initialization:
children = [
{Poolex,
pool_id: :worker_pool,
worker_module: SomeWorker,
workers_count: 5,
pool_size_metrics: true}
]
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 plugin that works with the PromEx library: Poolex.PromEx.
About installation of this plugin you can read here.