Skip to content

Add helper to provide Puma worker PIDs

This is an adaptation of the Prometheus::Client::Support::Unicorn module but for Puma.

It works in the same way, first tries to obtain the worker index by matching the $PROGRAM_NAME with a RegExp and extracting the index match, if that fails, it obtains the index by obtaining an instance of Puma::Cluster::Worker using ObjectSpace and reading the index from the instance, if that fails, it uses the process PID.

Puma ran on clustered mode will return a worker_id_{index} value, on single mode, it will return a process_id_{pid} value.

Merge request reports