Skip to content

Commit ba33233

Browse files
Use Puma method for PID provider compatibility, adding a fallback
1 parent 692a7f0 commit ba33233

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/promenade/setup.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,22 @@ def setup
3131
::Prometheus::Client.configure do |config|
3232
config.multiprocess_files_dir = multiprocess_files_dir
3333

34-
# This workaround enables us to utilize the same PID provider for both Unicorn and Pitchfork.
34+
# This workaround enables us to utilize the same PID provider for both Unicorn, Pitchfork and Puma.
3535
# We cannot employ the same method directly because Unicorn and Pitchfork are not loaded simultaneously.
3636
# Instead, we define a method that dynamically loads the appropriate PID provider based on the active server.
37+
# As a fallback, we use the process ID.
3738

3839
if defined?(Unicorn)
3940
require "prometheus/client/support/unicorn"
4041
pid_provider_method = ::Prometheus::Client::Support::Unicorn.method(:worker_pid_provider)
4142
elsif defined?(::Pitchfork)
4243
require "promenade/pitchfork/worker_pid_provider"
4344
pid_provider_method = Pitchfork::WorkerPidProvider.method(:fetch)
45+
elsif defined?(::Puma)
46+
require "prometheus/client/support/puma"
47+
pid_provider_method = ::Prometheus::Client::Support::Puma.method(:worker_pid_provider)
48+
else
49+
pid_provider_method = -> { "process_id_#{Process.pid}" }
4450
end
4551

4652
config.pid_provider = pid_provider_method

0 commit comments

Comments
 (0)