File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -31,16 +31,22 @@ def setup
31
31
::Prometheus ::Client . configure do |config |
32
32
config . multiprocess_files_dir = multiprocess_files_dir
33
33
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 .
35
35
# We cannot employ the same method directly because Unicorn and Pitchfork are not loaded simultaneously.
36
36
# 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.
37
38
38
39
if defined? ( Unicorn )
39
40
require "prometheus/client/support/unicorn"
40
41
pid_provider_method = ::Prometheus ::Client ::Support ::Unicorn . method ( :worker_pid_provider )
41
42
elsif defined? ( ::Pitchfork )
42
43
require "promenade/pitchfork/worker_pid_provider"
43
44
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 } " }
44
50
end
45
51
46
52
config . pid_provider = pid_provider_method
You can’t perform that action at this time.
0 commit comments