lib/prometheus/client/mmaped_value.rb in prometheus-client-mmap-0.7.0.beta12 vs lib/prometheus/client/mmaped_value.rb in prometheus-client-mmap-0.7.0.beta13

- old
+ new

@@ -1,18 +1,19 @@ +require 'prometheus/client' require 'prometheus/client/mmaped_dict' require 'json' module Prometheus module Client # A float protected by a mutex backed by a per-process mmaped file. class MmapedValue @@files = {} @@files_lock = Mutex.new - @@pid = Process.pid + @@pid = -1 def initialize(type, metric_name, name, labels, multiprocess_mode = '') - @pid = Process.pid + @pid = Prometheus::Client.pid @file_prefix = type.to_s @metric_name = metric_name @name = name @labels = labels if type == :gauge @@ -48,11 +49,11 @@ end def self.reset_on_pid_change @@files_lock.synchronize do if pid_changed? - @@pid = Process.pid + @@pid = Prometheus::Client.pid @@files = {} end end end @@ -60,19 +61,19 @@ reset_on_pid_change ObjectSpace.each_object(MmapedValue, &:reinitialize) end def self.pid_changed? - @@pid != Process.pid + @@pid != Prometheus::Client.pid end def self.multiprocess true end def reinitialize - if @pid != Process.pid - @pid = Process.pid + if @pid != Prometheus::Client.pid + @pid = Prometheus::Client.pid initialize_file end end def initialize_file