Sha256: 17d09af0878992619e62503271b3885d86cad2592ed90e0aca0b4abc014a8170

Contents?: true

Size: 1020 Bytes

Versions: 82

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

82 entries across 82 versions & 2 rubygems

Version Path
prometheus-client-mmap-1.1.2 lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.1.2-x86_64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.1.2-x86_64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.1.2-arm64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.1.2-aarch64-linux lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6 lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6-x86_64-linux-musl lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6-x86_64-linux-gnu lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6-x86_64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6-arm64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6-aarch64-linux-musl lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.6-aarch64-linux-gnu lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5 lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5-x86_64-linux-musl lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5-x86_64-linux-gnu lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5-x86_64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5-arm64-darwin lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5-aarch64-linux-musl lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.5-aarch64-linux-gnu lib/prometheus/client/support/puma.rb
prometheus-client-mmap-1.2.4 lib/prometheus/client/support/puma.rb