Sha256: 17d09af0878992619e62503271b3885d86cad2592ed90e0aca0b4abc014a8170

Contents?: true

Size: 1020 Bytes

Versions: 96

Compression:

Stored size: 1020 Bytes

Contents

module Prometheus
  module Client
    module Support
      module Puma
        extend self

        def worker_pid_provider
          wid = worker_id
          if wid = worker_id
            wid
          else
            "process_id_#{Process.pid}"
          end
        end

        private

        def object_based_worker_id
          return unless defined?(::Puma::Cluster::Worker)

          workers = ObjectSpace.each_object(::Puma::Cluster::Worker)
          return if workers.nil?

          workers_first = workers.first
          workers_first.index unless workers_first.nil?
        end

        def program_name
          $PROGRAM_NAME
        end

        def worker_id
          if matchdata = program_name.match(/puma.*cluster worker ([0-9]+):/)
            "puma_#{matchdata[1]}"
          elsif object_worker_id = object_based_worker_id
            "puma_#{object_worker_id}"
          elsif program_name.include?('puma')
            'puma_master'
          end
        end
      end
    end
  end
end

Version data entries

96 entries across 96 versions & 2 rubygems

Version Path
prometheus-client-mmap-1.0.1-aarch64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.0.0 lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.0.0-x86_64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.0.0-x86_64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.0.0-arm64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.0.0-aarch64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.1 lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.1-x86_64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.1-x86_64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.1-arm64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.1-aarch64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.0 lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.0-x86_64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.0-x86_64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.0-arm64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-0.28.0-aarch64-linux lib/prometheus/client/support/puma.rb