Sha256: ef926e10c121ef0c40b3af17eedff46f77ed02f31a8de35cb596b7a09ab14771

Contents?: true

Size: 788 Bytes

Versions: 188

Compression:

Stored size: 788 Bytes

Contents

module Prometheus
  module Client
    module Support
      module Unicorn
        def self.worker_pid_provider
          wid = worker_id
          if wid.nil?
            "process_id_#{Process.pid}"
          else
            "worker_id_#{wid}"
          end
        end

        def self.worker_id
          match = $0.match(/worker\[([^\]]+)\]/)
          if match
            match[1]
          else
            object_based_worker_id
          end
        end

        def self.object_based_worker_id
          return unless defined?(::Unicorn::Worker)

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

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

Version data entries

188 entries across 188 versions & 2 rubygems

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